Skip to content

Commit

Permalink
Config UI: show circuit status (#15110)
Browse files Browse the repository at this point in the history
  • Loading branch information
naltatis authored Jul 31, 2024
1 parent 582f0c0 commit 1042b80
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 12 deletions.
24 changes: 17 additions & 7 deletions assets/js/components/Config/DeviceTags.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
</div>
<div
class="value overflow-hidden text-truncate"
:class="{ 'value--error': hasError(entry), 'value--muted': entry.value === false }"
:class="{
'value--error': !!entry.error,
'value--warning': entry.warning,
'value--muted': entry.muted || entry.value === false,
}"
>
{{ fmtDeviceValue(entry) }}
</div>
Expand All @@ -29,15 +33,14 @@ export default {
mixins: [formatter],
computed: {
entries() {
return Object.entries(this.tags).map(([name, { value, error, options }]) => {
return { name, value, error, options };
});
return Object.entries(this.tags).map(
([name, { value, error, warning, muted, options }]) => {
return { name, value, error, warning, muted, options };
}
);
},
},
methods: {
hasError(entry) {
return !!entry.error;
},
fmtDeviceValue(entry) {
const { name, value, options = {} } = entry;
if (value === null || value === undefined) {
Expand Down Expand Up @@ -71,6 +74,10 @@ export default {
return this.fmtPricePerKWh(value, options.currency, true);
case "co2":
return this.fmtCo2Short(value);
case "powerRange":
return `${this.fmtKw(value[0])} / ${this.fmtKw(value[1])}`;
case "currentRange":
return `${this.fmtNumber(value[0], 1)} A / ${this.fmtNumber(value[1], 1)} A`;
case "configured":
return value
? this.$t("config.deviceValue.yes")
Expand Down Expand Up @@ -101,6 +108,9 @@ export default {
.value--error {
color: var(--bs-danger);
}
.value--warning {
color: var(--bs-warning);
}
.value--muted {
color: var(--evcc-gray) !important;
}
Expand Down
8 changes: 4 additions & 4 deletions assets/js/components/Config/defaultYaml/circuits.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# - name: main # unique name, used as reference, e.g. as parent in other circuits
# title: Main Circuit # used in the UI
# maxcurrent: 63 # 63A main circuit breaker (optional)
# maxpower: 30000 # 30kW (optional)
# maxPower: 30000 # 30kW (optional)
# meter: grid # associated meter to monitor the power consumption (optional)
# parent: # no parent, this is the root circuit
# - name: garage # unique name, used as reference, e.g. to associate loadpoints
# title: Garage # used in the UI
# maxcurrent: 24 # allow individual phase use up to 24A
# maxpower: 11000 # limit total power to 11kW
# maxPower: 11000 # limit total power to 11kW
# meter: garage # dedicated meter for the garage
# parent: main # parent to the main circuit
# - name: carport # unique name, used as reference, e.g. to associate loadpoints
# title: Carport # used in the UI
# maxcurrent: 32 # 32A circuit breaker
# maxpower: # no limit, only check current
# maxCurrent: 32 # 32A circuit breaker
# maxPower: # no limit, only check current
# meter: # no meter, using data from loadpoints
# parent: main # parent to the main circuit
42 changes: 41 additions & 1 deletion assets/js/views/Config.vue
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,22 @@
>
<template #icon><CircuitsIcon /></template>
<template #tags>
<DeviceTags :tags="yamlTags('circuits')" />
<DeviceTags
v-if="circuits.length == 0"
:tags="yamlTags('circuits')"
/>
<template
v-else
v-for="(circuit, idx) in circuits"
:key="circuit.name"
>
<hr v-if="idx > 0" />
<p class="my-2 fw-bold">
{{ circuit.config.title }}
<code>({{ circuit.name }})</code>
</p>
<DeviceTags :tags="circuitTags(circuit)" />
</template>
</template>
</DeviceCard>
<DeviceCard
Expand Down Expand Up @@ -365,6 +380,7 @@ export default {
return {
vehicles: [],
meters: [],
circuits: [],
selectedVehicleId: undefined,
selectedMeterId: undefined,
selectedMeterType: undefined,
Expand Down Expand Up @@ -455,6 +471,7 @@ export default {
await this.loadVehicles();
await this.loadMeters();
await this.loadSite();
await this.loadCircuits();
await this.loadDirty();
await this.updateValues();
await this.updateYamlConfigState();
Expand All @@ -473,6 +490,10 @@ export default {
const response = await api.get("/config/devices/meter");
this.meters = response.data?.result || [];
},
async loadCircuits() {
const response = await api.get("/config/devices/circuit");
this.circuits = response.data?.result || [];
},
async loadSite() {
const response = await api.get("/config/site", {
validateStatus: (status) => status < 500,
Expand Down Expand Up @@ -615,6 +636,25 @@ export default {
yamlTags(key) {
return { configured: { value: this.yamlConfigState[key] } };
},
circuitTags(circuit) {
const data = store.state?.circuits[circuit.name] || {};
const result = {};
if (data.maxPower) {
result.powerRange = {
value: [data.power || 0, data.maxPower],
warning: data.power >= data.maxPower,
};
} else {
result.power = { value: data.power || 0, muted: true };
}
if (data.maxCurrent) {
result.currentRange = {
value: [data.current || 0, data.maxCurrent],
warning: data.current >= data.maxCurrent,
};
}
return result;
},
deviceError(type, name) {
const fatal = store.state?.fatal || {};
return fatal.class === type && fatal.device === name;
Expand Down
2 changes: 2 additions & 0 deletions i18n/de.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ co2 = "Netz-CO₂"
configured = "Konfiguriert"
currency = "Währung"
current = "Strom"
currentRange = "Strom"
enabled = "Aktiviert"
energy = "Energie"
feedinPrice = "Einspeisevergütung"
Expand All @@ -66,6 +67,7 @@ phaseCurrents = "Strom L1..L3"
phasePowers = "Leistung L1..L3"
phaseVoltages = "Spannung L1..L3"
power = "Leistung"
powerRange = "Leistung"
range = "Reichweite"
soc = "SoC"
socLimit = "SoC Begrenzung"
Expand Down
2 changes: 2 additions & 0 deletions i18n/en.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ co2 = "Grid CO₂"
configured = "Configured"
currency = "Currency"
current = "Current"
currentRange = "Current"
enabled = "Enabled"
energy = "Energy"
feedinPrice = "Feed-in price"
Expand All @@ -66,6 +67,7 @@ phaseCurrents = "Current L1..L3"
phasePowers = "Power L1..L3"
phaseVoltages = "Voltage L1..L3"
power = "Power"
powerRange = "Power"
range = "Range"
soc = "SoC"
socLimit = "Limit"
Expand Down

0 comments on commit 1042b80

Please sign in to comment.