Added ESS Battery Life State

This commit is contained in:
2022-09-30 13:12:04 +02:00
parent 17c2309a28
commit 36e39fe662

View File

@ -220,8 +220,8 @@ class BasePlugin:
if 33 not in Devices:
Options = { "Custom": "1;W" }
Domoticz.Device(Name="Battery Power", Unit=33, TypeName="Custom", Used=0, Options=Options).Create()
#if 34 not in Devices:
# ESS Batterylife
if 34 not in Devices:
Domoticz.Device(Name="ESS Battery Life State", Unit=34, TypeName="Text", Used=0).Create()
return
@ -525,6 +525,7 @@ class BasePlugin:
Devices[31].Update(1, "0")
Devices[32].Update(1, "0")
Devices[33].Update(1, "0")
Devices[34].Update(1, "0")
# Grid Power L1
data = victron.read_holding_registers(820, 1)
@ -590,6 +591,39 @@ class BasePlugin:
Domoticz.Debug(" = {}".format(value))
Devices[33].Update(1, str(value))
# ESS Battery State
data = victron.read_holding_registers(2900, 1)
Domoticz.Debug("Data from register 2900: "+str(data))
# Unsigned 16
decoder = BinaryPayloadDecoder.fromRegisters(data, byteorder=Endian.Big, wordorder=Endian.Big)
# Value
value = decoder.decode_16bit_int()
batterystate = "Unknown?"
if value == 0:
batterystate = "Unused, Battery Life Disabled"
elif value == 1:
batterystate = "Restarted"
elif value == 2:
batterystate = "Self-compsumption"
elif value == 3:
ratterystate = "Self-compsumption, SoC exceeds 85%"
elif value == 4:
batterystate = "Self-compsumption, SoC at 100%"
elif value == 5:
batterystate = "Discharge disabled"
elif value == 6:
batterystate = "Force Charge"
elif value == 7:
batterystate = "Sustain"
elif value == 9:
batterystate = "Keep batteries charged"
elif value == 10:
batterystate = "Battery Life disabled"
elif value == 11:
batterystate = "Battery Life disabled (low SoC)"
Devices[34].Update(1, str(value)+": "+batterystate)
# TODO: add a device to say on battery yes/no
global _plugin
_plugin = BasePlugin()