From 05e2281765c0bcbd5745d4c72289a6a2fb0060b3 Mon Sep 17 00:00:00 2001 From: andig Date: Sun, 4 Jun 2023 22:03:39 +0200 Subject: [PATCH] chore: simplify templates (#8304) --- templates/definition/charger/homematic.yaml | 8 ++++---- templates/definition/charger/keba-udp.yaml | 8 ++++---- templates/definition/charger/shelly.yaml | 8 ++++++-- templates/definition/charger/tasmota.yaml | 8 ++++---- templates/definition/meter/alpha-ess-smile.yaml | 2 +- templates/definition/meter/deye-hybrid.yaml | 10 +++++----- templates/definition/meter/e3dc.yaml | 2 +- templates/definition/meter/fronius-gen24.yaml | 2 +- templates/definition/meter/fronius-solarapi-v1.yaml | 2 +- templates/definition/meter/goodwe-hybrid.yaml | 2 +- templates/definition/meter/growatt-hybrid-tlxh.yaml | 2 +- templates/definition/meter/growatt-hybrid.yaml | 2 +- templates/definition/meter/homematic.yaml | 12 ++++++------ .../meter/huawei-sun2000-dongle-powersensor.yaml | 2 +- templates/definition/meter/huawei-sun2000-rs485.yaml | 2 +- templates/definition/meter/kostal-piko.yaml | 2 +- templates/definition/meter/kostal-plenticore.yaml | 2 +- templates/definition/meter/lg-ess-home-8-10.yaml | 2 +- templates/definition/meter/openems.yaml | 2 +- templates/definition/meter/rct-power.yaml | 2 +- templates/definition/meter/senec-home.yaml | 2 +- templates/definition/meter/shelly-1pm.yaml | 8 ++++++-- templates/definition/meter/shelly-pro-3em.yaml | 8 ++++++-- templates/definition/meter/sma-datamanager.yaml | 2 +- templates/definition/meter/sma-energymeter.yaml | 2 +- templates/definition/meter/sma-homemanager.yaml | 2 +- templates/definition/meter/sma-hybrid.yaml | 2 +- templates/definition/meter/sma-inverter.yaml | 4 ++-- templates/definition/meter/sofarsolar-g3.yaml | 2 +- templates/definition/meter/sofarsolar.yaml | 2 +- templates/definition/meter/solaredge-hybrid.yaml | 2 +- templates/definition/meter/solarmax-maxstorage.yaml | 2 +- .../definition/meter/solarwatt-myreserve-matrix.yaml | 2 +- templates/definition/meter/solarwatt.yaml | 2 +- templates/definition/meter/solax-hybrid-cloud.yaml | 2 +- templates/definition/meter/solax.yaml | 2 +- templates/definition/meter/sonnenbatterie.yaml | 2 +- templates/definition/meter/sungrow-hybrid.yaml | 2 +- templates/definition/meter/sunspec-hybrid.yaml | 2 +- templates/definition/meter/tibber-pulse.yaml | 2 +- templates/definition/meter/varta.yaml | 2 +- templates/definition/meter/victron-energy.yaml | 2 +- templates/definition/vehicle/fiat.yaml | 2 +- templates/definition/vehicle/niu-e-scooter.yaml | 2 +- templates/definition/vehicle/offline.yaml | 10 +++++----- templates/definition/vehicle/ovms.yaml | 2 +- templates/definition/vehicle/tesla.yaml | 4 ++-- templates/definition/vehicle/tronity.yaml | 4 ++-- 48 files changed, 88 insertions(+), 76 deletions(-) diff --git a/templates/definition/charger/homematic.yaml b/templates/definition/charger/homematic.yaml index 353fbd348..b90508a29 100644 --- a/templates/definition/charger/homematic.yaml +++ b/templates/definition/charger/homematic.yaml @@ -51,12 +51,12 @@ render: | type: homematic uri: {{ .host }}:{{ .port }} device: {{ .device }} - {{ if ne .user "" }} + {{- if .user }} user: {{ .user }} - {{ end }} - {{ if ne .password "" }} + {{- end }} + {{- if .password }} password: {{ .password }} - {{ end }} + {{- end }} meterchannel: {{ .meterchannel }} switchchannel: {{ .switchchannel }} {{ include "switchsocket" . }} diff --git a/templates/definition/charger/keba-udp.yaml b/templates/definition/charger/keba-udp.yaml index 74988c9eb..04a28b17f 100644 --- a/templates/definition/charger/keba-udp.yaml +++ b/templates/definition/charger/keba-udp.yaml @@ -27,10 +27,10 @@ params: render: | type: keba-udp uri: {{ .host }} - {{ if ne .rfid "" }} + {{- if .rfid }} rfid: tag: {{ .rfid }} - {{ end }} - {{ if ne .serial "" }} + {{- end }} + {{- if .serial }} serial: {{ .serial }} - {{ end }} + {{- end }} diff --git a/templates/definition/charger/shelly.yaml b/templates/definition/charger/shelly.yaml index 700ba02c4..366cc2b26 100644 --- a/templates/definition/charger/shelly.yaml +++ b/templates/definition/charger/shelly.yaml @@ -13,7 +13,11 @@ params: render: | type: shelly uri: http://{{ .host }} - {{ if ne .user "" }}user: {{ .user }}{{ end }} - {{ if ne .password "" }}password: {{ .password }}{{ end }} + {{- if .user }} + user: {{ .user }} + {{- end }} + {{- if .password }} + password: {{ .password }} + {{- end }} channel: {{ .channel }} # shelly device relay channel {{ include "switchsocket" . }} diff --git a/templates/definition/charger/tasmota.yaml b/templates/definition/charger/tasmota.yaml index 39f621fab..fe3e2d46e 100644 --- a/templates/definition/charger/tasmota.yaml +++ b/templates/definition/charger/tasmota.yaml @@ -26,11 +26,11 @@ params: render: | type: tasmota uri: http://{{ .host }} - {{ if ne .user "" }} + {{- if .user }} user: {{ .user }} - {{ end }} - {{ if ne .password "" }} + {{- end }} + {{- if .password }} password: {{ .password }} - {{ end }} + {{- end }} channel: {{ .channel }} # relay channel (allowed range: 1-8) {{ include "switchsocket" . }} diff --git a/templates/definition/meter/alpha-ess-smile.yaml b/templates/definition/meter/alpha-ess-smile.yaml index bac7a6358..4a81d6ded 100644 --- a/templates/definition/meter/alpha-ess-smile.yaml +++ b/templates/definition/meter/alpha-ess-smile.yaml @@ -133,7 +133,7 @@ render: | type: holding decode: uint16 scale: 0.1 - {{- if ne .capacity "" }} + {{- if .capacity }} capacity: {{ .capacity }} # kWh {{- end }} {{- end }} diff --git a/templates/definition/meter/deye-hybrid.yaml b/templates/definition/meter/deye-hybrid.yaml index 3e0eb5705..d5fdffd1c 100644 --- a/templates/definition/meter/deye-hybrid.yaml +++ b/templates/definition/meter/deye-hybrid.yaml @@ -23,7 +23,7 @@ render: | source: modbus {{- include "modbus" . | indent 2 }} register: # manual non-sunspec register configuration - address: 625 # Grid side total power + address: 625 # Grid side total power type: holding decode: int16 energy: @@ -41,21 +41,21 @@ render: | address: 613 # "Out-of-grid - current A" type: holding decode: int16 - scale: 0.01 + scale: 0.01 - source: modbus {{- include "modbus" . | indent 4 }} register: # manual non-sunspec register configuration address: 614 # "Out-of-grid - current B" type: holding decode: int16 - scale: 0.01 + scale: 0.01 - source: modbus {{- include "modbus" . | indent 4 }} register: # manual non-sunspec register configuration address: 615 # "Out-of-grid - current C" type: holding decode: int16 - scale: 0.01 + scale: 0.01 {{- end }} {{- if eq .usage "pv" }} power: @@ -109,7 +109,7 @@ render: | address: 588 # "battery capacity" type: holding decode: int16 - {{- if ne .capacity "" }} + {{- if .capacity }} capacity: {{ .capacity }} # kWh {{- end }} energy: diff --git a/templates/definition/meter/e3dc.yaml b/templates/definition/meter/e3dc.yaml index 81fd011e9..80614fdee 100644 --- a/templates/definition/meter/e3dc.yaml +++ b/templates/definition/meter/e3dc.yaml @@ -55,7 +55,7 @@ render: | address: 40082 # Batterie-SOC in % type: holding decode: uint16 - {{- if ne .capacity "" }} + {{- if .capacity }} capacity: {{ .capacity }} # kWh {{- end }} {{- end }} diff --git a/templates/definition/meter/fronius-gen24.yaml b/templates/definition/meter/fronius-gen24.yaml index 9f300d4b8..e4291da05 100644 --- a/templates/definition/meter/fronius-gen24.yaml +++ b/templates/definition/meter/fronius-gen24.yaml @@ -75,7 +75,7 @@ render: | id: 1 model: sunspec value: ChargeState - {{- if ne .capacity "" }} + {{- if .capacity }} capacity: {{ .capacity }} # kWh {{- end }} {{- end }} diff --git a/templates/definition/meter/fronius-solarapi-v1.yaml b/templates/definition/meter/fronius-solarapi-v1.yaml index 72c2b77cf..643f2eb0b 100644 --- a/templates/definition/meter/fronius-solarapi-v1.yaml +++ b/templates/definition/meter/fronius-solarapi-v1.yaml @@ -27,7 +27,7 @@ render: | source: http uri: http://{{ .host }}/solar_api/v1/GetPowerFlowRealtimeData.fcgi jq: .Body.Data.Inverters."1".SOC - {{- if ne .capacity "" }} + {{- if .capacity }} capacity: {{ .capacity }} # kWh {{- end }} {{- end }} diff --git a/templates/definition/meter/goodwe-hybrid.yaml b/templates/definition/meter/goodwe-hybrid.yaml index 04672560b..8804b3f6b 100644 --- a/templates/definition/meter/goodwe-hybrid.yaml +++ b/templates/definition/meter/goodwe-hybrid.yaml @@ -84,7 +84,7 @@ render: | address: 37007 # SOC First group battery capacity type: holding decode: uint16 - {{- if ne .capacity "" }} + {{- if .capacity }} capacity: {{ .capacity }} # kWh {{- end }} energy: diff --git a/templates/definition/meter/growatt-hybrid-tlxh.yaml b/templates/definition/meter/growatt-hybrid-tlxh.yaml index 838c56516..71bc44c56 100644 --- a/templates/definition/meter/growatt-hybrid-tlxh.yaml +++ b/templates/definition/meter/growatt-hybrid-tlxh.yaml @@ -84,7 +84,7 @@ render: | address: 3171 # SOC type: input decode: uint16 - {{- if ne .capacity "" }} + {{- if .capacity }} capacity: {{ .capacity }} # kWh {{- end }} energy: diff --git a/templates/definition/meter/growatt-hybrid.yaml b/templates/definition/meter/growatt-hybrid.yaml index 71e9ccf97..421776829 100644 --- a/templates/definition/meter/growatt-hybrid.yaml +++ b/templates/definition/meter/growatt-hybrid.yaml @@ -82,7 +82,7 @@ render: | address: 1014 # SOC type: input decode: uint16 - {{- if ne .capacity "" }} + {{- if .capacity }} capacity: {{ .capacity }} # kWh {{- end }} energy: diff --git a/templates/definition/meter/homematic.yaml b/templates/definition/meter/homematic.yaml index b023eb7bb..40ba5ccd6 100644 --- a/templates/definition/meter/homematic.yaml +++ b/templates/definition/meter/homematic.yaml @@ -35,12 +35,12 @@ params: render: | type: homematic usage: {{ .usage }} - uri: {{ .host }}:{{- if (eq .usage "grid")}}2001{{ else }}2010{{end}} + uri: {{ .host }}:{{- if (eq .usage "grid") }}2001{{ else }}2010{{ end }} device: {{ .device }} - meterchannel: {{ if (eq .usage "grid")}}1{{ else }}{{ .meterchannel }}{{end}} - {{ if ne .user "" }} + meterchannel: {{ if (eq .usage "grid") }}1{{ else }}{{ .meterchannel }}{{ end }} + {{- if .user }} user: {{ .user }} - {{ end }} - {{ if ne .password "" }} + {{- end }} + {{- if .password }} password: {{ .password }} - {{ end }} + {{- end }} diff --git a/templates/definition/meter/huawei-sun2000-dongle-powersensor.yaml b/templates/definition/meter/huawei-sun2000-dongle-powersensor.yaml index 51470462f..1c49a1901 100644 --- a/templates/definition/meter/huawei-sun2000-dongle-powersensor.yaml +++ b/templates/definition/meter/huawei-sun2000-dongle-powersensor.yaml @@ -139,7 +139,7 @@ render: | type: holding decode: uint32 scale: 0.01 - {{- if ne .capacity "" }} + {{- if .capacity }} capacity: {{ .capacity }} # kWh {{- end }} {{- end }} diff --git a/templates/definition/meter/huawei-sun2000-rs485.yaml b/templates/definition/meter/huawei-sun2000-rs485.yaml index b1c4f53b3..e3b31fbf4 100644 --- a/templates/definition/meter/huawei-sun2000-rs485.yaml +++ b/templates/definition/meter/huawei-sun2000-rs485.yaml @@ -116,7 +116,7 @@ render: | type: holding decode: uint32 scale: 0.01 - {{- if ne .capacity "" }} + {{- if .capacity }} capacity: {{ .capacity }} # kWh {{- end }} {{- end }} diff --git a/templates/definition/meter/kostal-piko.yaml b/templates/definition/meter/kostal-piko.yaml index 517989dfc..ef68a3e18 100644 --- a/templates/definition/meter/kostal-piko.yaml +++ b/templates/definition/meter/kostal-piko.yaml @@ -38,7 +38,7 @@ render: | uri: http://{{ .host }}/api/dxs.json?dxsEntries=33556229 # Battery SOC # | ----------------------------- Bat SOC% --------- | jq: (.dxsEntries[] | select(.dxsId==33556229) | .value ) - {{- if ne .capacity "" }} + {{- if .capacity }} capacity: {{ .capacity }} # kWh {{- end }} {{- end -}} diff --git a/templates/definition/meter/kostal-plenticore.yaml b/templates/definition/meter/kostal-plenticore.yaml index 99b712a8f..a8c1baa6e 100644 --- a/templates/definition/meter/kostal-plenticore.yaml +++ b/templates/definition/meter/kostal-plenticore.yaml @@ -44,7 +44,7 @@ render: | model: sunspec power: 802:W # sunspec model 802 battery soc: 802:SoC # sunspec model 802 battery - {{- if ne .capacity "" }} + {{- if .capacity }} capacity: {{ .capacity }} # kWh {{- end }} {{- end }} diff --git a/templates/definition/meter/lg-ess-home-8-10.yaml b/templates/definition/meter/lg-ess-home-8-10.yaml index 264c6df96..26883a86d 100644 --- a/templates/definition/meter/lg-ess-home-8-10.yaml +++ b/templates/definition/meter/lg-ess-home-8-10.yaml @@ -22,6 +22,6 @@ render: | # uri and password are only required once if multiple lgess usages are defined uri: https://{{ .host }} password: {{ .registration }} - {{- if ne .capacity "" }} + {{- if .capacity }} capacity: {{ .capacity }} # kWh {{- end }} diff --git a/templates/definition/meter/openems.yaml b/templates/definition/meter/openems.yaml index 07bcddaf3..6617572f9 100644 --- a/templates/definition/meter/openems.yaml +++ b/templates/definition/meter/openems.yaml @@ -40,7 +40,7 @@ render: | user: x password: {{ .password }} jq: .value - {{- if ne .capacity "" }} + {{- if .capacity }} capacity: {{ .capacity }} # kWh {{- end }} {{- end }} diff --git a/templates/definition/meter/rct-power.yaml b/templates/definition/meter/rct-power.yaml index cd5dae842..e777e9c3a 100644 --- a/templates/definition/meter/rct-power.yaml +++ b/templates/definition/meter/rct-power.yaml @@ -15,6 +15,6 @@ render: | uri: {{ .host }} usage: {{ .usage }} cache: 2s - {{- if ne .capacity "" }} + {{- if .capacity }} capacity: {{ .capacity }} # kWh {{- end }} diff --git a/templates/definition/meter/senec-home.yaml b/templates/definition/meter/senec-home.yaml index 340b1b3e9..4bcedc820 100644 --- a/templates/definition/meter/senec-home.yaml +++ b/templates/definition/meter/senec-home.yaml @@ -42,7 +42,7 @@ render: | jq: .ENERGY.GUI_BAT_DATA_FUEL_CHARGE | sub("fl_"; "") unpack: hex decode: float32 - {{- if ne .capacity "" }} + {{- if .capacity }} capacity: {{ .capacity }} # kWh {{- end }} {{- end }} diff --git a/templates/definition/meter/shelly-1pm.yaml b/templates/definition/meter/shelly-1pm.yaml index f65140608..fe63a45e0 100644 --- a/templates/definition/meter/shelly-1pm.yaml +++ b/templates/definition/meter/shelly-1pm.yaml @@ -15,6 +15,10 @@ params: render: | type: shelly uri: http://{{ .host }} # shelly device ip address (local) - {{ if ne .user "" }}user: {{ .user }}{{ end }} - {{ if ne .password "" }}password: {{ .password }}{{ end }} + {{- if .user }} + user: {{ .user }} + {{- end }} + {{- if .password }} + password: {{ .password }} + {{- end }} channel: {{ .channel }} # shelly device relay channel diff --git a/templates/definition/meter/shelly-pro-3em.yaml b/templates/definition/meter/shelly-pro-3em.yaml index 231b3f844..15b493bba 100644 --- a/templates/definition/meter/shelly-pro-3em.yaml +++ b/templates/definition/meter/shelly-pro-3em.yaml @@ -13,6 +13,10 @@ params: render: | type: shelly-energymeter uri: http://{{ .host }} # shelly device ip address (local) - {{ if ne .user "" }}user: {{ .user }}{{ end }} - {{ if ne .password "" }}password: {{ .password }}{{ end }} + {{- if .user }} + user: {{ .user }} + {{- end }} + {{- if .password }} + password: {{ .password }} + {{- end }} channel: 0 # shelly device relay channel diff --git a/templates/definition/meter/sma-datamanager.yaml b/templates/definition/meter/sma-datamanager.yaml index 3a4570d37..e80f6616d 100644 --- a/templates/definition/meter/sma-datamanager.yaml +++ b/templates/definition/meter/sma-datamanager.yaml @@ -83,7 +83,7 @@ render: | address: 30845 # Battery Soc, % type: holding decode: uint32nan - {{- if ne .capacity "" }} + {{- if .capacity }} capacity: {{ .capacity }} # kWh {{- end }} {{- end }} diff --git a/templates/definition/meter/sma-energymeter.yaml b/templates/definition/meter/sma-energymeter.yaml index 1cae6eae5..fa7d68406 100644 --- a/templates/definition/meter/sma-energymeter.yaml +++ b/templates/definition/meter/sma-energymeter.yaml @@ -11,7 +11,7 @@ params: render: | type: sma uri: {{ .host }} - {{- if ne .interface "" }} + {{- if .interface }} interface: {{ .interface }} {{- end }} {{- if eq .usage "pv" }} diff --git a/templates/definition/meter/sma-homemanager.yaml b/templates/definition/meter/sma-homemanager.yaml index 570719693..5a3d168fa 100644 --- a/templates/definition/meter/sma-homemanager.yaml +++ b/templates/definition/meter/sma-homemanager.yaml @@ -29,6 +29,6 @@ params: render: | type: sma uri: {{ .host }} - {{- if ne .interface "" }} + {{- if .interface }} interface: {{ .interface }} {{- end }} diff --git a/templates/definition/meter/sma-hybrid.yaml b/templates/definition/meter/sma-hybrid.yaml index c7e529e01..c0f153cff 100644 --- a/templates/definition/meter/sma-hybrid.yaml +++ b/templates/definition/meter/sma-hybrid.yaml @@ -60,7 +60,7 @@ render: | address: 30845 # SMA Modbus Profile: Battery state of charge type: holding decode: uint32nan - {{- if ne .capacity "" }} + {{- if .capacity }} capacity: {{ .capacity }} # kWh {{- end }} {{- end }} diff --git a/templates/definition/meter/sma-inverter.yaml b/templates/definition/meter/sma-inverter.yaml index 8b75ba6ee..958d78d6d 100644 --- a/templates/definition/meter/sma-inverter.yaml +++ b/templates/definition/meter/sma-inverter.yaml @@ -18,9 +18,9 @@ params: render: | type: sma uri: {{ .host }} # IP address or hostname - {{- if ne .password "" }} + {{- if .password }} password: {{ .password }} # optional {{- end }} - {{- if ne .capacity "" }} + {{- if .capacity }} capacity: {{ .capacity }} # kWh {{- end }} diff --git a/templates/definition/meter/sofarsolar-g3.yaml b/templates/definition/meter/sofarsolar-g3.yaml index ada3e74c4..a0131648b 100644 --- a/templates/definition/meter/sofarsolar-g3.yaml +++ b/templates/definition/meter/sofarsolar-g3.yaml @@ -144,7 +144,7 @@ render: | type: holding decode: uint32 scale: 0.1 - {{- if ne .capacity "" }} + {{- if .capacity }} capacity: {{ .capacity }} # kWh {{- end }} {{- end }} diff --git a/templates/definition/meter/sofarsolar.yaml b/templates/definition/meter/sofarsolar.yaml index c17dd6ebd..62b574261 100644 --- a/templates/definition/meter/sofarsolar.yaml +++ b/templates/definition/meter/sofarsolar.yaml @@ -91,7 +91,7 @@ render: | address: 0x0210 # The residual capacity of battery type: holding decode: uint16 - {{- if ne .capacity "" }} + {{- if .capacity }} capacity: {{ .capacity }} # kWh {{- end }} {{- end }} diff --git a/templates/definition/meter/solaredge-hybrid.yaml b/templates/definition/meter/solaredge-hybrid.yaml index d1ae3bea3..871f1219f 100644 --- a/templates/definition/meter/solaredge-hybrid.yaml +++ b/templates/definition/meter/solaredge-hybrid.yaml @@ -63,7 +63,7 @@ render: | address: 62852 # Battery 1 State of Energy (SOE) type: holding decode: float32s - {{- if ne .capacity "" }} + {{- if .capacity }} capacity: {{ .capacity }} # kWh {{- end }} {{- end }} diff --git a/templates/definition/meter/solarmax-maxstorage.yaml b/templates/definition/meter/solarmax-maxstorage.yaml index fbe84038e..dcee66214 100644 --- a/templates/definition/meter/solarmax-maxstorage.yaml +++ b/templates/definition/meter/solarmax-maxstorage.yaml @@ -47,7 +47,7 @@ render: | address: 122 # Batterie Soc type: input decode: int16 - {{- if ne .capacity "" }} + {{- if .capacity }} capacity: {{ .capacity }} # kWh {{- end }} {{- end }} diff --git a/templates/definition/meter/solarwatt-myreserve-matrix.yaml b/templates/definition/meter/solarwatt-myreserve-matrix.yaml index 960cc2126..6cf187e75 100644 --- a/templates/definition/meter/solarwatt-myreserve-matrix.yaml +++ b/templates/definition/meter/solarwatt-myreserve-matrix.yaml @@ -29,7 +29,7 @@ render: | source: http uri: http://{{ .host }}:{{ .port }}/ jq: .SData.SoC - {{- if ne .capacity "" }} + {{- if .capacity }} capacity: {{ .capacity }} # kWh {{- end }} {{- end }} diff --git a/templates/definition/meter/solarwatt.yaml b/templates/definition/meter/solarwatt.yaml index b30f37c7b..8b18d26b4 100644 --- a/templates/definition/meter/solarwatt.yaml +++ b/templates/definition/meter/solarwatt.yaml @@ -49,7 +49,7 @@ render: | source: http uri: http://{{ .host }}/rest/kiwigrid/wizard/devices # EnergyManager jq: .result.items[] | select(.deviceModel[].deviceClass == "com.kiwigrid.devices.location.Location" ) | .tagValues.WorkReleased.value / 1000 - {{- if ne .capacity "" }} + {{- if .capacity }} capacity: {{ .capacity }} # kWh {{- end }} {{- end }} diff --git a/templates/definition/meter/solax-hybrid-cloud.yaml b/templates/definition/meter/solax-hybrid-cloud.yaml index a3060cbd0..81c4cc132 100644 --- a/templates/definition/meter/solax-hybrid-cloud.yaml +++ b/templates/definition/meter/solax-hybrid-cloud.yaml @@ -70,7 +70,7 @@ render: | uri: https://www.solaxcloud.com/proxyApp/proxy/api/getRealtimeInfo.do?tokenId={{.tokenid}}&sn={{.serial}} jq: .result.soc # Solax API inverter.DC.battery.energy.SOC cache: 2m30s - {{- if ne .capacity "" }} + {{- if .capacity }} capacity: {{ .capacity }} # kWh {{- end }} {{- end }} diff --git a/templates/definition/meter/solax.yaml b/templates/definition/meter/solax.yaml index f58dc0155..cc833a6da 100644 --- a/templates/definition/meter/solax.yaml +++ b/templates/definition/meter/solax.yaml @@ -75,7 +75,7 @@ render: | address: 28 # 0x001C Battery Capacity type: input decode: uint16 - {{- if ne .capacity "" }} + {{- if .capacity }} capacity: {{ .capacity }} # kWh {{- end }} {{- end }} diff --git a/templates/definition/meter/sonnenbatterie.yaml b/templates/definition/meter/sonnenbatterie.yaml index 2d9b2c22b..0b5f489b5 100644 --- a/templates/definition/meter/sonnenbatterie.yaml +++ b/templates/definition/meter/sonnenbatterie.yaml @@ -31,7 +31,7 @@ render: | source: http uri: http://{{ .host }}:{{ .port }}/api/v1/status jq: .USOC - {{- if ne .capacity "" }} + {{- if .capacity }} capacity: {{ .capacity }} # kWh {{- end }} {{- end }} diff --git a/templates/definition/meter/sungrow-hybrid.yaml b/templates/definition/meter/sungrow-hybrid.yaml index 3ce1ee488..afd8dc70e 100644 --- a/templates/definition/meter/sungrow-hybrid.yaml +++ b/templates/definition/meter/sungrow-hybrid.yaml @@ -97,7 +97,7 @@ render: | type: input decode: int16 scale: 0.1 - {{- if ne .capacity "" }} + {{- if .capacity }} capacity: {{ .capacity }} # kWh {{- end }} {{- end }} diff --git a/templates/definition/meter/sunspec-hybrid.yaml b/templates/definition/meter/sunspec-hybrid.yaml index 78ca3ea33..d8de484bc 100644 --- a/templates/definition/meter/sunspec-hybrid.yaml +++ b/templates/definition/meter/sunspec-hybrid.yaml @@ -93,7 +93,7 @@ render: | {{- include "modbus" . | indent 2 }} model: sunspec value: ChargeState - {{- if ne .capacity "" }} + {{- if .capacity }} capacity: {{ .capacity }} # kWh {{- end }} {{- end }} diff --git a/templates/definition/meter/tibber-pulse.yaml b/templates/definition/meter/tibber-pulse.yaml index 10c53184d..8e91b87e2 100644 --- a/templates/definition/meter/tibber-pulse.yaml +++ b/templates/definition/meter/tibber-pulse.yaml @@ -15,6 +15,6 @@ params: render: | type: tibber-pulse token: {{ .token }} - {{- if ne .homeid "" }} + {{- if .homeid }} homeid: {{ .homeid }} {{- end }} diff --git a/templates/definition/meter/varta.yaml b/templates/definition/meter/varta.yaml index fd74c020e..e3c5d1ff4 100644 --- a/templates/definition/meter/varta.yaml +++ b/templates/definition/meter/varta.yaml @@ -49,7 +49,7 @@ render: | address: 1068 # SOC type: holding decode: int16 - {{- if ne .capacity "" }} + {{- if .capacity }} capacity: {{ .capacity }} # kWh {{- end }} {{- end }} diff --git a/templates/definition/meter/victron-energy.yaml b/templates/definition/meter/victron-energy.yaml index 4e74f19ae..822525d43 100644 --- a/templates/definition/meter/victron-energy.yaml +++ b/templates/definition/meter/victron-energy.yaml @@ -110,7 +110,7 @@ render: | address: 843 # Soc type: input decode: uint16 - {{- if ne .capacity "" }} + {{- if .capacity }} capacity: {{ .capacity }} # kWh {{- end }} {{- end }} diff --git a/templates/definition/vehicle/fiat.yaml b/templates/definition/vehicle/fiat.yaml index 4ec09e5a2..b1ae369c3 100644 --- a/templates/definition/vehicle/fiat.yaml +++ b/templates/definition/vehicle/fiat.yaml @@ -11,7 +11,7 @@ params: render: | type: fiat {{ include "vehicle-base" . }} - {{- if ne .pin "" }} + {{- if .pin }} pin: {{ .pin }} # mandatory to deep refresh Soc {{- end }} {{ include "vehicle-identify" . }} diff --git a/templates/definition/vehicle/niu-e-scooter.yaml b/templates/definition/vehicle/niu-e-scooter.yaml index 30bdaf18c..1654bad5b 100644 --- a/templates/definition/vehicle/niu-e-scooter.yaml +++ b/templates/definition/vehicle/niu-e-scooter.yaml @@ -26,7 +26,7 @@ render: | {{- if .title }} title: {{ .title }} {{- end }} - {{- if ne .icon "" }} + {{- if .icon }} icon: {{ .icon }} {{- end }} user: {{ .user }} # NIU app user diff --git a/templates/definition/vehicle/offline.yaml b/templates/definition/vehicle/offline.yaml index 700f395e2..135fe4d4f 100644 --- a/templates/definition/vehicle/offline.yaml +++ b/templates/definition/vehicle/offline.yaml @@ -26,7 +26,7 @@ render: | {{- if .title }} title: {{ .title }} {{- end }} - {{- if ne .icon "" }} + {{- if .icon }} icon: {{ .icon }} {{- end }} capacity: {{ .capacity }} # kWh @@ -37,18 +37,18 @@ render: | source: js script: 0; onIdentify: - {{- if (ne .mode "") }} + {{- if .mode }} mode: {{ .mode }} {{- end }} minSoc: 0 # fixed - no Soc available targetSoc: 100 # fixed - no Soc available - {{- if (ne .minCurrent "") }} + {{- if .minCurrent }} minCurrent: {{ .minCurrent }} {{- end }} - {{- if (ne .maxCurrent "") }} + {{- if .maxCurrent }} maxCurrent: {{ .maxCurrent }} {{- end }} - {{- if ne (len .identifiers) 0 }} + {{- if (len .identifiers) }} identifiers: {{- range .identifiers }} - {{ . }} diff --git a/templates/definition/vehicle/ovms.yaml b/templates/definition/vehicle/ovms.yaml index 237021792..c11222c38 100644 --- a/templates/definition/vehicle/ovms.yaml +++ b/templates/definition/vehicle/ovms.yaml @@ -29,7 +29,7 @@ render: | {{- if .title }} title: {{ .title }} {{- end }} - {{- if ne .icon "" }} + {{- if .icon }} icon: {{ .icon }} {{- end }} user: {{ .user }} diff --git a/templates/definition/vehicle/tesla.yaml b/templates/definition/vehicle/tesla.yaml index 1b5c93945..1ef527c10 100644 --- a/templates/definition/vehicle/tesla.yaml +++ b/templates/definition/vehicle/tesla.yaml @@ -43,7 +43,7 @@ render: | {{- if .title }} title: {{ .title }} {{- end }} - {{- if ne .icon "" }} + {{- if .icon }} icon: {{ .icon }} {{- end }} tokens: @@ -53,7 +53,7 @@ render: | {{- if .phases }} phases: {{ .phases }} {{- end }} - {{- if ne .vin "" }} + {{- if .vin }} vin: {{ .vin }} {{- end }} {{ include "vehicle-identify" . }} diff --git a/templates/definition/vehicle/tronity.yaml b/templates/definition/vehicle/tronity.yaml index 5adc14a08..c31e7158b 100644 --- a/templates/definition/vehicle/tronity.yaml +++ b/templates/definition/vehicle/tronity.yaml @@ -36,7 +36,7 @@ render: | {{- if .title }} title: {{ .title }} {{- end }} - {{- if ne .icon "" }} + {{- if .icon }} icon: {{ .icon }} {{- end }} credentials: @@ -46,7 +46,7 @@ render: | {{- if .phases }} phases: {{ .phases }} {{- end }} - {{- if ne .vin "" }} + {{- if .vin }} vin: {{ .vin }} {{- end }} {{ include "vehicle-identify" . }}