Skip to content

Commit 36286ca

Browse files
authored
Merge pull request #642 from openWB/feature-refactor-status
Feature refactor status
2 parents 66d3ef9 + b9c2c30 commit 36286ca

9 files changed

+54
-25
lines changed

src/components/status/BatteryCard.vue

+5
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ export default {
8888
props: {
8989
battery: { type: Object, required: true },
9090
},
91+
data() {
92+
return {
93+
mqttTopicsToSubscribe: [`openWB/bat/${this.battery.id}/get/+`],
94+
};
95+
},
9196
computed: {
9297
baseTopic: {
9398
get() {

src/components/status/BatterySumCard.vue

+5
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ export default {
8484
FontAwesomeIcon,
8585
},
8686
mixins: [ComponentState],
87+
data() {
88+
return {
89+
mqttTopicsToSubscribe: ["openWB/bat/get/+"],
90+
};
91+
},
8792
computed: {
8893
baseTopic: {
8994
get() {

src/components/status/ChargePointCard.vue

+13-4
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,20 @@ export default {
218218
installedChargePointKey: { type: String, required: true },
219219
installedChargePoint: { type: Object, required: true },
220220
},
221+
data() {
222+
return {
223+
mqttTopicsToSubscribe: [
224+
`openWB/chargepoint/${this.installedChargePoint.id}/get/+`,
225+
`"openWB/chargepoint/${this.installedChargePoint.id}/get/connected_vehicle/info`,
226+
`"openWB/chargepoint/${this.installedChargePoint.id}/set/+`,
227+
`"openWB/internal_chargepoint/${this.installedChargePoint.id}/data/phases_to_use`,
228+
],
229+
};
230+
},
221231
computed: {
222232
chargePointIndex: {
223233
get() {
224-
return parseInt(this.installedChargePointKey.match(/(?:\/)(\d+)(?=\/)/)[1]);
234+
return this.installedChargePoint.id;
225235
},
226236
},
227237
baseTopic: {
@@ -231,9 +241,8 @@ export default {
231241
},
232242
chargingStatus: {
233243
get() {
234-
let ID = this.chargePointIndex;
235-
let plugState = this.$store.state.mqtt["openWB/chargepoint/" + ID + "/get/plug_state"];
236-
let chargeState = this.$store.state.mqtt["openWB/chargepoint/" + ID + "/get/charge_state"];
244+
let plugState = this.$store.state.mqtt[this.baseTopic + "/get/plug_state"];
245+
let chargeState = this.$store.state.mqtt[this.baseTopic + "/get/charge_state"];
237246
238247
if (plugState == 1 && chargeState == 1) {
239248
return { icon: ["fas", "plug-circle-bolt"], text: "Fahrzeug angesteckt, Ladevorgang aktiv" };

src/components/status/ChargePointSumCard.vue

+11
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,17 @@ export default {
7676
FontAwesomeIcon,
7777
},
7878
mixins: [ComponentState],
79+
data() {
80+
return {
81+
mqttTopicsToSubscribe: [
82+
"openWB/chargepoint/get/power",
83+
"openWB/chargepoint/get/imported",
84+
"openWB/chargepoint/get/exported",
85+
"openWB/chargepoint/get/daily_imported",
86+
"openWB/chargepoint/get/daily_exported",
87+
],
88+
};
89+
},
7990
computed: {
8091
baseTopic: {
8192
get() {

src/components/status/CounterCard.vue

+5
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,11 @@ export default {
148148
props: {
149149
counter: { type: Object, required: true },
150150
},
151+
data() {
152+
return {
153+
mqttTopicsToSubscribe: [`openWB/counter/${this.counter.id}/get/+`],
154+
};
155+
},
151156
computed: {
152157
baseTopic: {
153158
get() {

src/components/status/InverterCard.vue

+5
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ export default {
8080
props: {
8181
inverter: { type: Object, required: true },
8282
},
83+
data() {
84+
return {
85+
mqttTopicsToSubscribe: [`openWB/pv/${this.inverter.id}/get/+`],
86+
};
87+
},
8388
computed: {
8489
baseTopic: {
8590
get() {

src/components/status/InverterSumCard.vue

+5
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ export default {
7676
FontAwesomeIcon,
7777
},
7878
mixins: [ComponentState],
79+
data() {
80+
return {
81+
mqttTopicsToSubscribe: ["openWB/pv/get/+"],
82+
};
83+
},
7984
computed: {
8085
baseTopic: {
8186
get() {

src/components/status/VehicleCard.vue

+5-1
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,14 @@ export default {
5757
},
5858
mixins: [ComponentState],
5959
props: {
60-
vehicle: { type: Object, required: false, default: undefined },
6160
vehicleKey: { type: String, required: true },
6261
vehicleName: { type: String, default: "" },
6362
},
63+
data() {
64+
return {
65+
mqttTopicsToSubscribe: ["openWB/vehicle/+/get/+"],
66+
};
67+
},
6468
computed: {
6569
vehicleIndex: {
6670
get() {

src/views/Status.vue

-20
Original file line numberDiff line numberDiff line change
@@ -81,30 +81,10 @@ export default {
8181
"openWB/general/extern",
8282
// components
8383
"openWB/system/device/+/component/+/config",
84-
// counter
85-
"openWB/counter/+/get/+",
86-
// pv
87-
"openWB/pv/get/+",
88-
"openWB/pv/+/get/+",
89-
// batteries
90-
"openWB/bat/get/+",
91-
"openWB/bat/+/get/+",
9284
// vehicles
9385
"openWB/vehicle/+/name",
94-
"openWB/vehicle/+/get/+",
95-
// charge points total
96-
"openWB/chargepoint/get/power",
97-
"openWB/chargepoint/get/imported",
98-
"openWB/chargepoint/get/exported",
99-
"openWB/chargepoint/get/daily_imported",
100-
"openWB/chargepoint/get/daily_exported",
10186
// individual charge points
102-
// these topics must be subscribed at last to avoid a buffer overflow
10387
"openWB/chargepoint/+/config",
104-
"openWB/chargepoint/+/get/+",
105-
"openWB/chargepoint/+/get/connected_vehicle/info",
106-
"openWB/chargepoint/+/set/+",
107-
"openWB/internal_chargepoint/+/data/phases_to_use",
10888
],
10989
};
11090
},

0 commit comments

Comments
 (0)