Skip to content

Commit

Permalink
SMA: add battery control (#11368)
Browse files Browse the repository at this point in the history
  • Loading branch information
andig committed Jan 7, 2024
1 parent b6bfb1a commit 3ba0c8d
Show file tree
Hide file tree
Showing 5 changed files with 228 additions and 33 deletions.
3 changes: 1 addition & 2 deletions templates/definition/meter/sma-datamanager.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
template: sma-data-manager
covers:
- sma-data-manager-m-lite
covers: ["sma-data-manager-m-lite"]
products:
- brand: SMA
description:
Expand Down
5 changes: 4 additions & 1 deletion templates/definition/meter/sma-homemanager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ linked:
- template: sma-hybrid
usage: battery
multiple: true
- template: sma-inverter
- template: sma-inverter-speedwire
usage: battery
multiple: true
- template: sma-inverter-modbus
usage: battery
multiple: true
params:
Expand Down
149 changes: 122 additions & 27 deletions templates/definition/meter/sma-hybrid.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ products:
description:
de: Smart Energy Hybrid-Wechselrichter
en: Smart Energy Hybrid Inverter
capabilities: ["battery-control"]
params:
- name: usage
choice: ["pv", "battery"]
Expand All @@ -17,50 +18,144 @@ params:
de: Der Modbus TCP-Server muss an diesem Smart Energy Wechselrichter aktiviert sein
- name: capacity
advanced: true
- name: watchdog
type: duration
default: 60s
advanced: true
render: |
type: custom
power:
{{- if eq .usage "pv" }}
source: calc
add:
- source: modbus
{{- include "modbus" . | indent 6 }}
register: # manual non-sunspec register configuration
address: 30773 # SMA Modbus Profile: DC power input [1]
type: holding
decode: int32nan
- source: modbus
{{- include "modbus" . | indent 6 }}
register: # manual non-sunspec register configuration
address: 30961 # SMA Modbus Profile: DC power input [2]
type: holding
decode: int32nan
power:
source: modbus
{{- include "modbus" . | indent 2 }}
register:
address: 30773 # SMA Modbus Profile: DcMs.Watt
type: input
decode: int32nan
energy:
source: modbus
{{- include "modbus" . | indent 2 }}
register:
address: 30513 # SMA Modbus Profile: Metering.TotWhOut
type: holding
decode: uint64nan
scale: 0.001
{{- end }}
{{- if eq .usage "battery" }}
power:
source: calc
mul:
add:
- source: modbus
{{- include "modbus" . | indent 6 }}
register: # manual non-sunspec register configuration
address: 30851 # SMA Modbus Profile: Battery voltage
type: holding
register:
address: 31395 # SMA Modbus Profile: BatDsch.CurBatDsch
type: input
decode: uint32nan
scale: 0.01
- source: modbus
{{- include "modbus" . | indent 6 }}
register: # manual non-sunspec register configuration
address: 30843 # SMA Modbus Profile: Battery current
type: holding
decode: int32nan
scale: 0.001
register:
address: 31393 # SMA Modbus Profile: BatChrg.CurBatCha
type: input
decode: uint32nan
scale: -1
energy:
source: modbus
{{- include "modbus" . | indent 2 }}
register:
address: 31401 # SMA Modbus Profile: CmpBMS.GetBatDschWh
type: holding
decode: uint64nan
scale: 0.001
soc:
source: modbus
{{- include "modbus" . | indent 2 }}
register: # manual non-sunspec register configuration
address: 30845 # SMA Modbus Profile: Battery state of charge
register:
address: 30845 # SMA Modbus Profile: Bat.ChaStt
type: holding
decode: uint32nan
batterymode:
source: watchdog
timeout: {{ .watchdog }} # re-write at timeout/2
reset: 1 # reset watchdog on normal
set:
source: switch
switch:
- case: 1 # normal
set:
source: const
value: 10000 # Maximale Wirkleistung
set:
source: modbus
{{- include "modbus" . | indent 10 }}
timeout: {{ .timeout }}
register:
address: 44039 # SMA Modbus Profile: Inverter.WModCfg.WCtlComCfg.WSptMaxNom
type: writemultiple
decode: int32
- case: 2 # hold
set:
source: const
value: 0 # Maximale Wirkleistung
set:
source: modbus
{{- include "modbus" . | indent 10 }}
timeout: {{ .timeout }}
register:
address: 44039 # SMA Modbus Profile: Inverter.WModCfg.WCtlComCfg.WSptMaxNom
type: writemultiple
decode: int32
- case: 3 # charge
set:
source: const
value: -10000 # Maximale Wirkleistung
set:
source: modbus
{{- include "modbus" . | indent 10 }}
timeout: {{ .timeout }}
register:
address: 44039 # SMA Modbus Profile: Inverter.WModCfg.WCtlComCfg.WSptMaxNom
type: writemultiple
decode: int32
{{- if .capacity }}
capacity: {{ .capacity }} # kWh
{{- end }}
{{- end }}
{{- if eq .usage "grid" }}
power:
source: modbus
{{- include "modbus" . | indent 2 }}
register:
address: 30865 # SMA Modbus Profile: Metering.GridMs.TotWIn
type: input
decode: int32nan
energy:
source: modbus
{{- include "modbus" . | indent 2 }}
register:
address: 30581 # SMA Modbus Profile: Metering.GridMs.TotWhIn
type: holding
decode: int32nan
scale: 0.001
currents:
- source: modbus
{{- include "modbus" . | indent 4 }}
register:
address: 31435 # SMA Modbus Profile: Metering.GridMs.A.phsA
type: input
decode: int32nan
scale: 0.001
- source: modbus
{{- include "modbus" . | indent 4 }}
register:
address: 31437 # SMA Modbus Profile: Metering.GridMs.A.phsB
type: input
decode: int32nan
scale: 0.001
- source: modbus
{{- include "modbus" . | indent 4 }}
register:
address: 31439 # SMA Modbus Profile: Metering.GridMs.A.phsC
type: input
decode: int32nan
scale: 0.001
{{- end }}
97 changes: 97 additions & 0 deletions templates/definition/meter/sma-inverter-modbus.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
template: sma-inverter-modbus
products:
- brand: SMA
description:
generic: Sunny Island (Modbus)
- brand: SMA
description:
generic: Sunny Boy Storage (Modbus)
capabilities: ["battery-control"]
params:
- name: usage
choice: ["battery"]
- name: modbus
choice: ["tcpip"]
port: 502
id: 3
help:
en: The Modbus TCP-Server needs to be enabled on this inverter
de: Der Modbus TCP-Server muss an diesem Wechselrichter aktiviert sein
- name: capacity
advanced: true
- name: watchdog
type: duration
default: 60s
advanced: true
render: |
type: custom
power:
source: modbus
{{- include "modbus" . | indent 2 }}
register:
address: 30775 # SMA Modbus Profile: GridMs.TotW
type: input
decode: int32nan
energy:
source: modbus
{{- include "modbus" . | indent 2 }}
register:
address: 30513 # SMA Modbus Profile: Metering.TotWhOut
type: holding
decode: uint64nan
scale: 0.001
{{- if eq .usage "battery" }}
soc:
source: modbus
{{- include "modbus" . | indent 2 }}
register:
address: 30845 # SMA Modbus Profile: Bat.ChaStt
type: holding
decode: uint32nan
batterymode:
source: watchdog
timeout: {{ .watchdog }} # re-write at timeout/2
reset: 1 # reset watchdog on normal
set:
source: switch
switch:
- case: 1 # normal
set:
source: const
value: 10000 # Maximale Wirkleistung
set:
source: modbus
{{- include "modbus" . | indent 10 }}
timeout: {{ .timeout }}
register:
address: 44039 # SMA Modbus Profile: Inverter.WModCfg.WCtlComCfg.WSptMaxNom
type: writemultiple
decode: int32
- case: 2 # hold
set:
source: const
value: 0 # Maximale Wirkleistung
set:
source: modbus
{{- include "modbus" . | indent 10 }}
timeout: {{ .timeout }}
register:
address: 44039 # SMA Modbus Profile: Inverter.WModCfg.WCtlComCfg.WSptMaxNom
type: writemultiple
decode: int32
- case: 3 # charge
set:
source: const
value: -10000 # Maximale Wirkleistung
set:
source: modbus
{{- include "modbus" . | indent 10 }}
timeout: {{ .timeout }}
register:
address: 44039 # SMA Modbus Profile: Inverter.WModCfg.WCtlComCfg.WSptMaxNom
type: writemultiple
decode: int32
{{- if .capacity }}
capacity: {{ .capacity }} # kWh
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
template: sma-inverter
template: sma-inverter-speedwire
covers: ["sma-inverter"]
products:
- brand: SMA
description:
de: Wechselrichter
en: Inverter
de: Wechselrichter (Speedwire)
en: Inverter (Speedwire)
params:
- name: usage
choice: ["pv", "battery"]
Expand Down

0 comments on commit 3ba0c8d

Please sign in to comment.