Skip to content

Commit

Permalink
fix battery control
Browse files Browse the repository at this point in the history
  • Loading branch information
premultiply committed Nov 21, 2024
1 parent 735d75e commit 3847d9e
Show file tree
Hide file tree
Showing 3 changed files with 350 additions and 73 deletions.
164 changes: 142 additions & 22 deletions templates/definition/meter/sma-hybrid.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ params:
- name: maxacpower
- name: watchdog
type: duration
default: 30s
default: 60s
advanced: true
usages: ["battery"]
- name: chargepower
default: 100000 # 100kW, inverter will use it's maximum by default
default: 4200 # W
advanced: true
help:
de: Ladeleistung für Netzladen in W
en: Charging power for grid charging in W
de: Maximale Ladeleistung für erzwungenes Laden des Speichers in Watt
en: Maximum charging power for forced charging of the battery in Watt
usages: ["battery"]
render: |
type: custom
Expand Down Expand Up @@ -138,57 +139,176 @@ render: |
switch:
- case: 1 # normal
set:
source: const
value: 803 # inaktiv (Ina)
source: sequence
set:
source: modbus
{{- include "modbus" . | indent 10 }}
register:
address: 40151 # SMA Modbus Profile: Inverter.WModCfg.WCtlComCfg.WCtlComAct
type: writemultiple
decode: uint32
- source: const
value: 2424 # Voreinstellung (Dft)
set:
source: modbus
{{- include "modbus" . | indent 12 }}
register:
address: 40236 # CmpBMS.OpMod - Betriebsart des BMS
type: writemultiple
decode: uint32
- source: const
value: 0
set:
source: modbus
{{- include "modbus" . | indent 12 }}
register:
address: 40793 # CmpBMS.BatChaMinW - Minimale Batterieladeleistung
type: writemultiple
decode: uint32
- source: const
value: {{ .chargepower }}
set:
source: modbus
{{- include "modbus" . | indent 12 }}
register:
address: 40795 # CmpBMS.BatChaMaxW - Maximale Batterieladeleistung
type: writemultiple
decode: uint32
- source: const
value: 0
set:
source: modbus
{{- include "modbus" . | indent 12 }}
register:
address: 40797 # CmpBMS.BatDschMinW - Minimale Batterieentladeleistung
type: writemultiple
decode: uint32
- source: const
value: {{ .chargepower }}
set:
source: modbus
{{- include "modbus" . | indent 12 }}
register:
address: 40799 # CmpBMS.BatDschMaxW - Maximale Batterieentladeleistung
type: writemultiple
decode: uint32
- source: const
value: 0
set:
source: modbus
{{- include "modbus" . | indent 12 }}
register:
address: 40801 # CmpBMS.GridWSpt - Sollwert der Netzaustauschleistung
type: writemultiple
decode: uint32
- case: 2 # hold
set:
source: sequence
set:
- source: const
value: 0 # Wirkleistungsvorgabe
value: 2424 # Voreinstellung (Dft)
set:
source: modbus
{{- include "modbus" . | indent 12 }}
register:
address: 40236 # CmpBMS.OpMod - Betriebsart des BMS
type: writemultiple
decode: uint32
- source: const
value: 0
set:
source: modbus
{{- include "modbus" . | indent 12 }}
register:
address: 40149 # SMA Modbus Profile: Inverter.WModCfg.WCtlComCfg.WSpt
address: 40793 # CmpBMS.BatChaMinW - Minimale Batterieladeleistung
type: writemultiple
decode: int32
decode: uint32
- source: const
value: {{ .chargepower }}
set:
source: modbus
{{- include "modbus" . | indent 12 }}
register:
address: 40795 # CmpBMS.BatChaMaxW - Maximale Batterieladeleistung
type: writemultiple
decode: uint32
- source: const
value: 0
set:
source: modbus
{{- include "modbus" . | indent 12 }}
register:
address: 40797 # CmpBMS.BatDschMinW - Minimale Batterieentladeleistung
type: writemultiple
decode: uint32
- source: const
value: 802 # aktiv (Act)
value: 0
set:
source: modbus
{{- include "modbus" . | indent 12 }}
register:
address: 40151 # SMA Modbus Profile: Inverter.WModCfg.WCtlComCfg.WCtlComAct
address: 40799 # CmpBMS.BatDschMaxW - Maximale Batterieentladeleistung
type: writemultiple
decode: uint32
- source: const
value: 0
set:
source: modbus
{{- include "modbus" . | indent 12 }}
register:
address: 40801 # CmpBMS.GridWSpt - Sollwert der Netzaustauschleistung
type: writemultiple
decode: uint32
- case: 3 # charge
set:
source: sequence
set:
- source: const
value: -{{ .chargepower }} # Wirkleistungsvorgabe
value: 2289 # Batterie laden (BatChaMod)
set:
source: modbus
{{- include "modbus" . | indent 12 }}
register:
address: 40149 # SMA Modbus Profile: Inverter.WModCfg.WCtlComCfg.WSpt
address: 40236 # CmpBMS.OpMod - Betriebsart des BMS
type: writemultiple
decode: int32
decode: uint32
- source: const
value: {{ .chargepower }}
set:
source: modbus
{{- include "modbus" . | indent 12 }}
register:
address: 40793 # CmpBMS.BatChaMinW - Minimale Batterieladeleistung
type: writemultiple
decode: uint32
- source: const
value: {{ .chargepower }}
set:
source: modbus
{{- include "modbus" . | indent 12 }}
register:
address: 40795 # CmpBMS.BatChaMaxW - Maximale Batterieladeleistung
type: writemultiple
decode: uint32
- source: const
value: 0
set:
source: modbus
{{- include "modbus" . | indent 12 }}
register:
address: 40797 # CmpBMS.BatDschMinW - Minimale Batterieentladeleistung
type: writemultiple
decode: uint32
- source: const
value: {{ .chargepower }}
set:
source: modbus
{{- include "modbus" . | indent 12 }}
register:
address: 40799 # CmpBMS.BatDschMaxW - Maximale Batterieentladeleistung
type: writemultiple
decode: uint32
- source: const
value: 802 # aktiv (Act)
value: 0
set:
source: modbus
{{- include "modbus" . | indent 12 }}
register:
address: 40151 # SMA Modbus Profile: Inverter.WModCfg.WCtlComCfg.WCtlComAct
address: 40801 # CmpBMS.GridWSpt - Sollwert der Netzaustauschleistung
type: writemultiple
decode: uint32
capacity: {{ .capacity }} # kWh
Expand Down
Loading

0 comments on commit 3847d9e

Please sign in to comment.