Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix sunspec-hybrid #16291

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion provider/modbus_sunspec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
61 changes: 28 additions & 33 deletions templates/definition/meter/sunspec-hybrid.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }}
Loading