From c136ebc2e0abcd013033e02ad5766cbe64a0df82 Mon Sep 17 00:00:00 2001 From: andig Date: Fri, 30 May 2025 11:47:51 +0200 Subject: [PATCH] UI: add unit property (#21396) --- assets/js/components/Config/PropertyEntry.vue | 4 +- assets/js/components/Config/PropertyField.vue | 3 - cmd/configure/helper.go | 4 + cmd/configure/survey.go | 7 +- templates/definition/charger/pulsatrix.yaml | 6 +- templates/definition/meter/sofarsolar-g3.yaml | 4 +- .../definition/meter/sonnenbatterie.yaml | 3 - tests/config-battery.spec.js | 2 +- util/templates/defaults.yaml | 132 ++++++++++-------- util/templates/documentation.tpl | 10 +- util/templates/types.go | 1 + 11 files changed, 105 insertions(+), 71 deletions(-) diff --git a/assets/js/components/Config/PropertyEntry.vue b/assets/js/components/Config/PropertyEntry.vue index d91d580f1..2f29f11b9 100644 --- a/assets/js/components/Config/PropertyEntry.vue +++ b/assets/js/components/Config/PropertyEntry.vue @@ -10,10 +10,11 @@ @@ -37,6 +38,7 @@ export default { Help: String, Example: String, Type: String, + Unit: String, Mask: Boolean, Choice: Array, modelValue: [String, Number, Boolean, Object], diff --git a/assets/js/components/Config/PropertyField.vue b/assets/js/components/Config/PropertyField.vue index 6f20f4690..2ccf8de0b 100644 --- a/assets/js/components/Config/PropertyField.vue +++ b/assets/js/components/Config/PropertyField.vue @@ -163,9 +163,6 @@ export default { if (this.unit) { return this.unit; } - if (this.property === "capacity") { - return "kWh"; - } return null; }, icons() { diff --git a/cmd/configure/helper.go b/cmd/configure/helper.go index 419f3a221..f49bb267a 100644 --- a/cmd/configure/helper.go +++ b/cmd/configure/helper.go @@ -438,6 +438,10 @@ func (c *CmdConfigure) processInputConfig(param templates.Param) string { label = langLabel } + if param.Unit != "" { + label = fmt.Sprintf("%s (%s)", label, param.Unit) + } + value := c.askValue(question{ label: label, defaultValue: param.Default, diff --git a/cmd/configure/survey.go b/cmd/configure/survey.go index 09268fce3..7e58723f2 100644 --- a/cmd/configure/survey.go +++ b/cmd/configure/survey.go @@ -129,8 +129,13 @@ func (c *CmdConfigure) askParam(p templates.Param) string { required = *p.Required } + label := p.Description.String(c.lang) + if p.Unit != "" { + label = fmt.Sprintf("%s (%s)", label, p.Unit) + } + return c.askValue(question{ - label: p.Description.String(c.lang), + label: label, valueType: p.Type, choice: p.Choice, mask: mask, diff --git a/templates/definition/charger/pulsatrix.yaml b/templates/definition/charger/pulsatrix.yaml index f9d79399f..6f3b42596 100644 --- a/templates/definition/charger/pulsatrix.yaml +++ b/templates/definition/charger/pulsatrix.yaml @@ -6,9 +6,9 @@ requirements: params: - name: host #IP address or hostname (can be found on 3rd page of SECC display) required: true - description: - en: IP address or hostname (can be found on 3rd page of SECC display) - de: IP-Adresse oder Hostname (wird auf der dritten Displayseite des SECC angezeigt) + help: + en: Shown on 3rd page of SECC display + de: Wird auf der dritten Displayseite des SECC angezeigt render: | type: pulsatrix host: {{ .host }} diff --git a/templates/definition/meter/sofarsolar-g3.yaml b/templates/definition/meter/sofarsolar-g3.yaml index 841a6117d..d6ef9734e 100644 --- a/templates/definition/meter/sofarsolar-g3.yaml +++ b/templates/definition/meter/sofarsolar-g3.yaml @@ -38,8 +38,8 @@ params: - name: maxacpower - name: defaultmode help: - de: Standardmodus für die aktive Batteriesteuerung. Gültige Werte sind 0 (Eigenbedarfsmodus), 1 (Nutzungszeitmodus), 2 (Zeitmodus), 4 (Peak-shaving Modus) - en: Default mode for battery control. Valid values are 0 (self use), 1 (time of use), 2 (timing mode), 4 (peak-shaving mode) + de: Gültige Werte sind 0 (Eigenbedarfsmodus), 1 (Nutzungszeitmodus), 2 (Zeitmodus), 4 (Peak-shaving Modus) + en: Valid values are 0 (self use), 1 (time of use), 2 (timing mode), 4 (peak-shaving mode) default: 0 # self use advanced: true # battery control diff --git a/templates/definition/meter/sonnenbatterie.yaml b/templates/definition/meter/sonnenbatterie.yaml index 428e5ecef..f108bd7e9 100644 --- a/templates/definition/meter/sonnenbatterie.yaml +++ b/templates/definition/meter/sonnenbatterie.yaml @@ -38,9 +38,6 @@ params: default: self-consumption required: true advanced: true - help: - de: Standardmodus für die aktive Batteriesteuerung - en: Default mode for active battery control usages: ["battery"] - name: chargepower deprecated: true diff --git a/tests/config-battery.spec.js b/tests/config-battery.spec.js index f06e6fcb7..4f269c28a 100644 --- a/tests/config-battery.spec.js +++ b/tests/config-battery.spec.js @@ -49,7 +49,7 @@ test.describe("battery meter", async () => { // edit #1 await page.getByTestId("battery").getByRole("button", { name: "edit" }).click(); await expectModalVisible(meterModal); - await meterModal.getByLabel("Battery capacity (kWh)").fill("20"); + await meterModal.getByLabel("Battery capacity").fill("20"); await meterModal.getByRole("button", { name: "Validate & save" }).click(); await expectModalHidden(meterModal); diff --git a/util/templates/defaults.yaml b/util/templates/defaults.yaml index 5fc69ae0a..326373a2a 100644 --- a/util/templates/defaults.yaml +++ b/util/templates/defaults.yaml @@ -51,9 +51,6 @@ params: description: de: Port en: Port - help: - de: Port - en: Port type: int - name: interface description: @@ -66,27 +63,29 @@ params: de: Benutzerkonto en: Username help: - de: Benutzerkonto (bspw. E-Mail Adresse, User Id, etc.) - en: User account (e.g. email address, user id, etc.) + de: bspw. E-Mail Adresse, User Id, etc. + en: e.g. email address, user id, etc. - name: password description: de: Passwort en: Password help: - de: Passwort des Benutzerkontos (bei führenden Nullen bitte in einfache Hochkommata setzen) - en: Password of the user account (use single quotes in case of leading zeros) + de: Bei führenden Nullen bitte in einfache Hochkommata setzen + en: Use single quotes in case of leading zeros mask: true - name: capacity + unit: kWh description: - de: Akkukapazität (kWh) - en: Battery capacity (kWh) + de: Akkukapazität + en: Battery capacity example: 50 type: float usages: ["vehicle", "battery"] - name: maxacpower + unit: W description: - de: Maximale AC Leistung des Hybrid-Wechselrichters (W) - en: Maximum AC power of the hybrid inverter (W) + de: Maximale AC Leistung des Hybrid-Wechselrichters + en: Maximum AC power of the hybrid inverter default: 0 example: 5000 type: float @@ -97,8 +96,8 @@ params: de: Fahrzeugidentifikationsnummer en: Vehicle Identification Number help: - de: Erforderlich, wenn mehrere Fahrzeuge des Herstellers vorhanden sind - en: Required if you own multiple vehicles of the same brand + de: Wenn mehrere Fahrzeuge eines Herstellers vorhanden sind + en: If you own multiple vehicles from the same manufacturer example: W... - name: phases description: @@ -140,36 +139,40 @@ params: en: Possible values are Off, Now, MinPV and PV, or empty if none should be set type: chargemodes - name: minsoc + unit: "%" description: - de: Minimaler Ladestand (%) - en: Minimum charge (%) + de: Minimaler Ladestand + en: Minimum charge help: - de: Untere Grenze beim Entladen der Batterie (normaler Betrieb) - en: Lower limit when discharging the battery (normal operation) + de: Untere Grenze beim Entladen der Batterie im normalen Betrieb + en: Lower limit when discharging the battery in normal operation example: 25 type: int - name: maxsoc + unit: "%" description: - de: Maximaler Ladestand (%) - en: Maximum charge (%) + de: Maximaler Ladestand + en: Maximum charge help: de: Oberes Limit beim Laden der Batterie aus dem Netz en: Upper limit when charging the battery from the grid example: 95 type: int - name: mincurrent + unit: A description: - de: Minimale Stromstärke in Ampere (A) - en: Minimum amperage (A) + de: Minimale Stromstärke + en: Minimum amperage help: de: Definiert die minimale Stromstärke pro angeschlossener Phase mit welcher das Fahrzeug geladen werden soll en: The minimum amperage per connected phase with which the car should be charged example: 6 type: int - name: maxcurrent + unit: A description: - de: Maximale Stromstärke in Ampere (A) - en: Maximum amperage (A) + de: Maximale Stromstärke + en: Maximum amperage help: de: Definiert die maximale Stromstärke pro angeschlossener Phase mit welcher das Fahrzeug geladen werden soll en: The maximum amperage per connected phase with which the car shuold be charged @@ -192,9 +195,10 @@ params: en: Priority of the loadpoint or vehicle in relation to other loadpoints or vehicles for allocating pv energy type: int - name: standbypower + unit: W description: - de: Standby-Leistung (W) - en: Standby power (W) + de: Standby-Leistung + en: Standby power help: de: Leistung oberhalb des angegebenen Wertes wird als Ladeleistung gewertet en: Power values above this value will be considered as charging power @@ -203,9 +207,6 @@ params: description: de: Sprache en: Language - help: - de: "'de' für Deutsch und 'en' für Englisch" - en: "'en' for English and 'de' for German" default: en type: choice choice: ["en", "de"] @@ -214,8 +215,8 @@ params: de: Icon en: Icon help: - de: "Icon in der Benutzeroberfläche" - en: "Icon as shown in user interface" + de: Wird in der Benutzeroberfläche angezeigt + en: Will be displayed in the user interface type: choice choice: - car @@ -264,8 +265,8 @@ params: en: Subject Key Identifier (SKI) de: Identifikationsschlüssel (SKI) help: - en: The SKI of the wallbox, usually found on the web interface of the wallbox - de: Die SKI der Wallbox, üblicherweise im Web Interface der Wallbox zu finden + en: Usually found on the web interface of the wallbox + de: Üblicherweise im Web Interface der Wallbox zu finden - name: uri description: generic: URI @@ -279,8 +280,8 @@ params: en: Actor Identification Number (AIN) de: Aktoridentifikationsnummer (AIN) help: - en: The AIN is printed on the type label on the back of the device. Embed it in double quotes in case of leading zeroes. - de: Die AIN ist auf dem Typenschild auf der Geräterückseite aufgedruckt. Bei führenden Nullen bitte in doppelte Hochkommata setzen. + en: Printed on the type label on the back of the device. Embed it in double quotes in case of leading zeroes. + de: Ist auf dem Typenschild auf der Geräterückseite aufgedruckt. Bei führenden Nullen bitte in doppelte Hochkommata setzen. - name: coarsecurrent type: bool help: @@ -304,27 +305,29 @@ params: de: Standardmodus für die aktive Batteriesteuerung en: Default mode for battery control help: - de: Standardmodus für die aktive Batteriesteuerung auf die der Wechselrichter wieder nach einem Laden des Speichers oder Unterbinden der Entladung zurückfällt. - en: Default mode for battery control to which the inverter falls back after charging the battery or after stopping discharge. + de: Wechselrichter fällt nach einem Laden des Speichers oder Unterbinden der Entladung zurück auf diesen Modus. + en: Inverter falls back to this mode after charging the battery or after stopping discharge. - name: maxchargepower + unit: W type: int usages: ["battery"] description: - en: Maximum charge power (W) - de: Maximale Ladeleistung (W) + en: Maximum charge power + de: Maximale Ladeleistung help: - en: Maximum charge power for forced charging of the battery in watts. - de: Maximale Ladeleistung für erzwungenes Laden des Speichers in Watt. + en: For forced charging of the battery in watts. + de: Für erzwungenes Laden des Speichers in Watt. advanced: true - name: maxchargerate + unit: "%" type: int usages: ["battery"] description: - en: Maximum charge power (%) - de: Maximale Ladeleistung (%) + en: Maximum charge power + de: Maximale Ladeleistung help: - en: Maximum charge power for forced charging of the battery in percent in relation to the maximum charge power of the battery inverter. - de: Maximale Leistung für erzwungenes Laden des Speichers in Prozent in Relation zur maximalen Ladeleistung des Batteriewechselrichters. + en: For forced charging of the battery in percent in relation to the maximum charge power of the battery inverter. + de: Für erzwungenes Laden des Speichers in Prozent in Relation zur maximalen Ladeleistung des Batteriewechselrichters. default: 100 advanced: true @@ -389,17 +392,26 @@ presets: - name: charges type: int advanced: true + description: + en: Charge + de: Aufschlag help: de: Zusätzlicher fester Aufschlag pro kWh (z.B. 0.05 für 5 Cent) en: Additional fixed charge per kWh (e.g. 0.05 for 5 cents) - name: tax type: int advanced: true + description: + en: Tax + de: Steuer help: de: Zusätzlicher prozentualer Aufschlag (z.B. 0.2 für 20%) en: Additional percentage charge (e.g. 0.2 for 20%) - name: formula type: string + description: + en: Formula + de: Formel advanced: true help: de: Individuelle Formel zur Berechnung des Preises @@ -433,8 +445,9 @@ presets: required: true - name: kwp description: - en: Maximum generator power [kWp] - de: Maximale Generatorleistung [kWp] + en: Maximum generator power + de: Maximale Generatorleistung + unit: kWp type: float example: 9.8 required: true @@ -442,9 +455,6 @@ presets: eebus: params: - name: ski - help: - de: SKI (Subject Key Identifier) - en: SKI (Subject Key Identifier) - name: ip switchsocket: params: @@ -453,29 +463,41 @@ presets: - name: integrateddevice type: bool advanced: true + description: + en: Integrated device + de: Integriertes Gerät help: - de: Integriertes Gerät (keine Fahrzeugverbindung) - en: Integrated device (no vehicle connection) + de: Fest angeschlossenes Gerät. Keine Ladevorgänge + en: Integrated device. No charging sessions - name: heating type: bool advanced: true + description: + en: Heating device + de: Wärmeerzeuger help: - de: Wärmeerzeuger (°C anstatt %) - en: Heating device (°C instead of %) + de: Zeigt °C anstatt % an + en: Shows °C instead of % - name: icon advanced: true ocpp: params: - name: stationid type: string + description: + en: Station ID + de: Station ID help: en: "Station ID of the charging point. Only required if multiple OCPP charging stations are set up to assign them correctly. A single OCPP charging station can also be automatically assigned. Note: In exceptional cases, it may be necessary to manually append this ID to the OCPP URL of the charging station in the form ws://:8887/. Most charging stations automatically add the ID internally." de: "Station ID des Ladepunktes. Nur erforderlich wenn mehrere OCPP-Ladestationen eingerichtet sind um diese korrekt zuzuweisen. Eine einzelne OCPP-Ladestation kann auch automatisch zugeordnet werden. Hinweis: In Ausnahmefällen kann es erforderlich sein, diese ID manuell an die OCPP-URL der Ladestation in der Form ws://:8887/ anzuhängen. Die meisten Ladestationen fügen die ID intern automatisch hinzu." example: EVB-P12354 - name: connector + description: + en: Connector number + de: Anschlussnummer help: - de: Anschlussnummer bei Ladestationen mit mehreren Anschlüssen. Die Zählung beginnt bei 1 für den ersten Anschluss. - en: Connector number for charging stations with multiple connectors. Counting starts at 1 for the first connector. + de: Bei Ladestationen mit mehreren Anschlüssen. Die Zählung beginnt bei 1 für den ersten Anschluss. + en: For charging stations with multiple connectors. Counting starts at 1 for the first connector. default: 1 - name: remotestart advanced: true diff --git a/util/templates/documentation.tpl b/util/templates/documentation.tpl index 74a0af840..5a7941fcf 100644 --- a/util/templates/documentation.tpl +++ b/util/templates/documentation.tpl @@ -3,14 +3,20 @@ {{- range .Values }} - {{ . }} {{- end }} + {{- $unit := .Unit -}} + {{- $description := localize .Description | replace "\n" " " -}} {{- $help := localize .Help | replace "\n" " " -}} {{- $choices := join ", " .Choice -}} {{- $optional := not .IsRequired -}} - {{- if or $help $choices $optional }} # {{end}} + {{- if or $help $choices $optional $description }} # {{end}} + {{- if $description }}{{ $description }} + {{- if $unit }} ({{ $unit }}){{- end }} + {{- if or $help $choices $optional }}, {{end}} + {{- end}} {{- if $help }}{{ $help }} {{end}} {{- if $choices }}[{{ $choices }}] {{end}} {{- if $optional }} - {{- if or $help $choices }}(optional){{ else }}optional{{end }} + {{- if or $help $choices }}(optional){{ else }}optional{{end }} {{- end }} {{- end }} diff --git a/util/templates/types.go b/util/templates/types.go index c08454114..1569c4fb9 100644 --- a/util/templates/types.go +++ b/util/templates/types.go @@ -186,6 +186,7 @@ type Param struct { Example string `json:",omitempty"` // cli example value Value string `json:"-"` // user provided value via cli configuration Values []string `json:",omitempty"` // user provided list of values e.g. for Type "list" + Unit string `json:",omitempty"` // unit of the value, e.g. "kW", "kWh", "A", "V" Usages []string `json:",omitempty"` // restrict param to these usage types, e.g. "battery" for home battery capacity Type ParamType // string representation of the value type, "string" is default Choice []string `json:",omitempty"` // defines a set of choices, e.g. "grid", "pv", "battery", "charge" for "usage"