From 5650c2702f4a9429691325f4990e7e4960725d89 Mon Sep 17 00:00:00 2001 From: h3llrais3r Date: Thu, 16 Jan 2025 07:49:33 +0100 Subject: [PATCH] Add battery control (Work in progress) --- templates/definition/meter/saj-h1.yaml | 116 +++++++++++++++++++++++++ 1 file changed, 116 insertions(+) diff --git a/templates/definition/meter/saj-h1.yaml b/templates/definition/meter/saj-h1.yaml index d84a3c1ad4..ebe2414ee3 100644 --- a/templates/definition/meter/saj-h1.yaml +++ b/templates/definition/meter/saj-h1.yaml @@ -12,6 +12,17 @@ params: default: 5s - name: capacity advanced: true + # battery control + - name: defaultmode + default: 0 # (0=self-use,1=time-of-use,2=backup,3=passive) + advanced: true + - name: holdmode + default: 2 # (0=self-use,1=time-of-use,2=backup,3=passive) + advanced: true + - name: backupsoc + type: int + default: 20 # used when backup mode is used as defaultmode to control the default backup soc + advanced: true render: | type: custom {{- if eq .usage "grid" }} @@ -79,5 +90,110 @@ render: | type: holding decode: uint16 scale: 0.01 + batterymode: + source: switch + switch: + - case: 1 # normal + set: + source: sequence + set: + - source: const + value: {{ .defaultmode }} + set: + source: modbus + {{- include "modbus" . | indent 10 }} + timeout: {{ .timeout }} + register: + address: 0x3247 # AppMode + type: writeholding + decode: int16 + - source: const + value: {{ .backupsoc }} # use backupsoc value when using backup mode as defaultmode + set: + source: modbus + {{- include "modbus" . | indent 10 }} + timeout: {{ .timeout }} + register: + address: 0x3271 # BackModSOCRetain + type: writeholding + decode: int16 + - case: 2 # hold + set: + source: sequence + set: + - source: const + value: {{ .holdmode }} + set: + source: modbus + {{- include "modbus" . | indent 10 }} + timeout: {{ .timeout }} + register: + address: 0x3247 # AppMode + type: writeholding + decode: int16 + - source: const + value: {{ .soc }} # hold on current soc value when using backup mode as holdmode + set: + source: modbus + {{- include "modbus" . | indent 10 }} + timeout: {{ .timeout }} + register: + address: 0x3271 # BackModSOCRetain + type: writeholding + decode: int16 + - case: 3 # charge + set: + source: sequence + set: + - source: const + value: 1 # Time-Of-Use + set: + source: modbus + {{- include "modbus" . | indent 10 }} + timeout: {{ .timeout }} + register: + address: 0x3247 # AppMode + type: writeholding + decode: int16 + - source: const + value: 1 # enable + set: + source: modbus + {{- include "modbus" . | indent 10 }} + timeout: {{ .timeout }} + register: + address: 0x3604 # Charge time enable control + type: writeholding + decode: int16 + - source: const + value: 0 # start time (00:00) + set: + source: modbus + {{- include "modbus" . | indent 10 }} + timeout: {{ .timeout }} + register: + address: 0x3606 # Battery first charging time (start) + type: writeholding + decode: int16 + - source: const + value: 0x173B # end time (23:59) + set: + source: modbus + {{- include "modbus" . | indent 10 }} + timeout: {{ .timeout }} + register: + address: 0x3607 # Battery first charging time (end) + type: writeholding + decode: int16 + - source: const + value: 0x7F64 # every day (0x7f) at 100% (0x64) + set: + source: modbus + {{- include "modbus" . | indent 10 }} + timeout: {{ .timeout }} + register: + address: 0x3608 # Battery first charging time (power) + type: writeholding + decode: int16 capacity: {{ .capacity }} # kWh {{- end }}