Skip to content

Commit

Permalink
Update plugin_solax.py - adding state_class for long-term stats
Browse files Browse the repository at this point in the history
Adding state_class to some sensors (such as Battery SOC etc.) to enable long-term statistics in HA.
  • Loading branch information
TheDK authored Nov 10, 2024
1 parent 1243dc8 commit d1fd5a8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions custom_components/solax_modbus/plugin_solax.py
Original file line number Diff line number Diff line change
Expand Up @@ -4032,6 +4032,7 @@ def value_function_battery_voltage_cell_difference(initval, descr, datadict):
key = "battery_capacity",
native_unit_of_measurement = PERCENTAGE,
device_class = SensorDeviceClass.BATTERY,
state_class = SensorStateClass.MEASUREMENT,
register = 0x1C,
register_type = REG_INPUT,
allowedtypes = AC | HYBRID | GEN2 | GEN3 | GEN4,
Expand Down Expand Up @@ -4703,6 +4704,7 @@ def value_function_battery_voltage_cell_difference(initval, descr, datadict):
key = "eps_yield_total",
native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR,
device_class = SensorDeviceClass.ENERGY,
state_class = SensorStateClass.TOTAL_INCREASING,
register = 0x8E,
register_type = REG_INPUT,
unit = REGISTER_U32,
Expand All @@ -4715,6 +4717,7 @@ def value_function_battery_voltage_cell_difference(initval, descr, datadict):
key = "eps_yield_total",
native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR,
device_class = SensorDeviceClass.ENERGY,
state_class = SensorStateClass.TOTAL_INCREASING,
register = 0x8E,
register_type = REG_INPUT,
unit = REGISTER_U32,
Expand All @@ -4725,6 +4728,7 @@ def value_function_battery_voltage_cell_difference(initval, descr, datadict):
key = "eps_yield_today",
native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR,
device_class = SensorDeviceClass.ENERGY,
state_class = SensorStateClass.MEASUREMENT,
register = 0x90,
register_type = REG_INPUT,
scale = 0.1,
Expand Down Expand Up @@ -5017,6 +5021,7 @@ def value_function_battery_voltage_cell_difference(initval, descr, datadict):
key = "battery_soh",
icon = "mdi:battery-heart",
native_unit_of_measurement = PERCENTAGE,
state_class = SensorStateClass.MEASUREMENT,
register = 0xBF,
register_type = REG_INPUT,
entity_registry_enabled_default = False,
Expand Down Expand Up @@ -5236,6 +5241,7 @@ def value_function_battery_voltage_cell_difference(initval, descr, datadict):
key = "remaining_battery_capacity",
native_unit_of_measurement = UnitOfEnergy.WATT_HOUR,
device_class = SensorDeviceClass.ENERGY,
state_class = SensorStateClass.MEASUREMENT,
entity_registry_enabled_default = False,
register = 0x118,
register_type = REG_INPUT,
Expand Down Expand Up @@ -5524,6 +5530,7 @@ def value_function_battery_voltage_cell_difference(initval, descr, datadict):
key = "pm_battery_current_charge",
native_unit_of_measurement = UnitOfElectricCurrent.AMPERE,
device_class = SensorDeviceClass.CURRENT,
state_class = SensorStateClass.MEASUREMENT,
register = 0x1FC,
scale = 0.01,
register_type = REG_INPUT,
Expand Down

0 comments on commit d1fd5a8

Please sign in to comment.