From a8424b043c076b3aa0c9d707b2b913a91a70a663 Mon Sep 17 00:00:00 2001 From: andig Date: Sun, 28 Jan 2024 16:41:07 +0100 Subject: [PATCH] Sunspec: add battery control (#10933) --- .../meter/sunspec-battery-control.yaml | 51 ++++++++ .../meter/sunspec-inverter-control.yaml | 109 ++++++++++++++++++ 2 files changed, 160 insertions(+) create mode 100644 templates/definition/meter/sunspec-battery-control.yaml create mode 100644 templates/definition/meter/sunspec-inverter-control.yaml diff --git a/templates/definition/meter/sunspec-battery-control.yaml b/templates/definition/meter/sunspec-battery-control.yaml new file mode 100644 index 0000000000..31271bc571 --- /dev/null +++ b/templates/definition/meter/sunspec-battery-control.yaml @@ -0,0 +1,51 @@ +template: sunspec-battery-control +products: + - description: + de: Sunspec Batterie (Model 802) + en: Sunspec Battery (Model 802) +capabilities: ["battery-control"] +group: generic +params: + - name: usage + choice: ["battery"] + - name: modbus + choice: ["tcpip", "rs485"] + - name: capacity + advanced: true + # battery control (model 802) + - name: minsoc + type: number + advanced: true + - name: maxsoc + type: number + advanced: true +render: | + {{- if eq .usage "battery" }} + type: custom + power: + source: calc + add: + - source: sunspec + {{- include "modbus" . | indent 4 }} + value: 160:3:DCW # mppt 3 (charge) + scale: -1 + - source: sunspec + {{- include "modbus" . | indent 4 }} + value: 160:4:DCW # mppt 4 (discharge) + energy: + source: sunspec + {{- include "modbus" . | indent 2 }} + value: 160:4:DCWH # mppt 4 (discharge) + scale: 0.001 + soc: + source: sunspec + {{- include "modbus" . | indent 2 }} + value: 802:0:SoC + limitsoc: # model 802 + source: sunspec + {{- include "modbus" . | indent 2 }} + value: 802:0:SoCRsvMin + capacity: {{ .capacity }} # kWh + minsoc: {{ .minsoc }} # % + maxsoc: {{ .maxsoc }} # % + {{- end }} diff --git a/templates/definition/meter/sunspec-inverter-control.yaml b/templates/definition/meter/sunspec-inverter-control.yaml new file mode 100644 index 0000000000..30ff31ff4f --- /dev/null +++ b/templates/definition/meter/sunspec-inverter-control.yaml @@ -0,0 +1,109 @@ +template: sunspec-inverter-control +products: + - description: + de: Sunspec Batterie (Model 124) + en: Sunspec Battery (Model 124) +capabilities: ["battery-control"] +group: generic +params: + - name: usage + choice: ["battery"] + - name: modbus + choice: ["tcpip", "rs485"] + - name: capacity + advanced: true +render: | + {{- if eq .usage "battery" }} + type: custom + power: + source: calc + add: + - source: sunspec + {{- include "modbus" . | indent 4 }} + value: 160:3:DCW # mppt 3 (charge) + scale: -1 + - source: sunspec + {{- include "modbus" . | indent 4 }} + value: 160:4:DCW # mppt 4 (discharge) + energy: + source: sunspec + {{- include "modbus" . | indent 2 }} + value: 160:4:DCWH # mppt 4 (discharge) + scale: 0.001 + soc: + source: sunspec + {{- include "modbus" . | indent 2 }} + value: 124:0:ChaState + batterymode: # model 124 + source: switch + switch: + - case: 1 # normal + set: + source: sequence + set: + - source: const + value: 0 # off + set: + source: sunspec + {{- include "modbus" . | indent 10 }} + value: 124:0:ChaGriSet + - source: const + value: 0 + set: + source: sunspec + {{- include "modbus" . | indent 10 }} + value: 124:0:StorCtl_Mod + - source: const + value: 100 # % + set: + source: sunspec + {{- include "modbus" . | indent 10 }} + value: 124:0:OutWRte + - case: 2 # hold + set: + source: sequence + set: + - source: const + value: 0 # off + set: + source: sunspec + {{- include "modbus" . | indent 10 }} + value: 124:0:ChaGriSet + - source: const + value: 2 + set: + source: sunspec + {{- include "modbus" . | indent 10 }} + value: 124:0:StorCtl_Mod + - source: const + value: 0 # % + set: + source: sunspec + {{- include "modbus" . | indent 10 }} + value: 124:0:OutWRte + - case: 3 # charge + set: + source: sequence + set: + - source: const + value: 1 # off + set: + source: sunspec + {{- include "modbus" . | indent 10 }} + value: 124:0:ChaGriSet + - source: const + value: 2 + set: + source: sunspec + {{- include "modbus" . | indent 10 }} + value: 124:0:StorCtl_Mod + - source: const + value: -100 # % + set: + source: sunspec + {{- include "modbus" . | indent 10 }} + value: 124:0:OutWRte + {{- if .capacity }} + capacity: {{ .capacity }} # kWh + {{- end }} + {{- end }}