Sungrow Hybrid: fix charge sign (again) (#18473)

This commit is contained in:
premultiply 2025-02-10 11:15:21 +01:00 • committed by GitHub
parent 0516b5c807
commit 84b5037c64
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -110,34 +110,41 @@ render: |
{{- end }}
{{- if eq .usage "battery" }}
power:
source: calc
mul:
- source: calc
abs:
source: go # handling old and new firmware
script: |
res := float64(bp)
if (brs&0x2 > 0 || bc < 0) && bp >= 0 {
res = float64(-bp)
}
res
in:
- name: brs
type: int
config:
source: modbus
{{- include "modbus" . | indent 6 }}
register:
type: input
address: 13000 # Battery running state
decode: uint16
- name: bc
type: int
config:
source: modbus
{{- include "modbus" . | indent 6 }}
register:
type: input
address: 13020 # Battery current
decode: int16
- name: bp
type: int
config:
source: modbus
{{- include "modbus" . | indent 6 }}
timeout: {{ .timeout }}
register:
type: input
address: 13021 # Battery power
decode: int16
- source: calc
add:
- source: modbus
{{- include "modbus" . | indent 6 }}
register:
type: input
address: 13000 # Battery running state
decode: bool16
bitmask: 2 # Charging
scale: -1
- source: modbus
{{- include "modbus" . | indent 6 }}
register:
type: input
address: 13000 # Battery running state
decode: bool16
bitmask: 4 # Discharging
energy:
source: modbus
{{- include "modbus" . | indent 2 }}