diff --git a/provider/modbus_sunspec.go b/provider/modbus_sunspec.go index 5f16b44f47..a4887f0fd2 100644 --- a/provider/modbus_sunspec.go +++ b/provider/modbus_sunspec.go @@ -183,8 +183,10 @@ func (m *ModbusSunspec) FloatSetter(_ string) (func(float64) error, error) { switch typ { case typelabel.Float32: point.SetFloat32(float32(val)) + case typelabel.Uint16: + point.SetUint16(uint16(val)) default: - return fmt.Errorf("invalid point type: %s", typ) + return fmt.Errorf("invalid point type: %s, tried to write float value %f", typ, val) } return block.Write(m.op.Point) diff --git a/templates/definition/meter/sunspec-hybrid.yaml b/templates/definition/meter/sunspec-hybrid.yaml index fb12fc94c0..5e1bf4c9cc 100644 --- a/templates/definition/meter/sunspec-hybrid.yaml +++ b/templates/definition/meter/sunspec-hybrid.yaml @@ -13,6 +13,13 @@ params: choice: ["tcpip", "rs485"] - name: capacity advanced: true + # battery control (model 802) + - name: minsoc + type: number + advanced: true + - name: maxsoc + type: number + advanced: true render: | type: custom # sunspec model 203 (int+sf)/ 213 (float) meter @@ -80,48 +87,36 @@ render: | - 213:WphC {{- end }} {{- if eq .usage "pv" }} + # sunspec model 103 Inverter (Three-Phase) + type: custom power: - source: calc - add: - - source: sunspec - {{- include "modbus" . | indent 6 }} - value: 160:1:DCW # mppt 1 - - source: sunspec - {{- include "modbus" . | indent 6 }} - value: 160:2:DCW # mppt 2 + source: sunspec + {{- include "modbus" . | indent 2 }} + value: 103:DCW energy: - source: calc - add: - - source: sunspec - {{- include "modbus" . | indent 6 }} - value: 160:1:DCWH # mppt 1 - scale: 0.001 - - source: sunspec - {{- include "modbus" . | indent 6 }} - value: 160:2:DCWH # mppt 2 - scale: 0.001 + source: sunspec + {{- include "modbus" . | indent 2 }} + value: 103:WH {{- end }} {{- if eq .usage "battery" }} power: - source: calc - add: - - source: sunspec - {{- include "modbus" . | indent 6 }} - value: 160:3:DCW # mppt 3 (charge) - scale: -1 - - source: sunspec - {{- include "modbus" . | indent 6 }} - value: 160:4:DCW # mppt 4 (discharge) - energy: source: sunspec {{- include "modbus" . | indent 2 }} - value: 160:4:DCWH # mppt 4 (discharge) - scale: 0.001 + value: 802:W + scale: -1 soc: source: sunspec {{- include "modbus" . | indent 2 }} - value: - - 124:ChaState - - 802:SoC + value: 802:SoC + limitsoc: + source: sunspec + {{- include "modbus" . | indent 2 }} + value: 802:SoCRsvMin + minsoc: {{ .minsoc }} # % + maxsoc: {{ .maxsoc }} # % capacity: {{ .capacity }} # kWh + # source: sunspec + # { {- include "modbus" . | indent 2 }} + # value: 802:WHRtg + # scale: 0.001 {{- end }}