Skip to content

Commit

Permalink
Merge pull request #1167 from gec75/main
Browse files Browse the repository at this point in the history
add proper rounding to some sensors
  • Loading branch information
wills106 authored Dec 22, 2024
2 parents 3d180b4 + 899108e commit 0b8b7c3
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions custom_components/solax_modbus/plugin_solinteg.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"""
Gabriel C.
Plugin for Solinteg inverter, using ModbusTCP
Only basic functionality for now
Also works for identical devices: M-TEC Energy Butler, Wattsonic
Most basic functionality implemented
"""

""" ============================================================================================
Expand Down Expand Up @@ -563,7 +564,6 @@ def __init__(self, **kwargs):
device_class = SensorDeviceClass.POWER,
state_class = SensorStateClass.MEASUREMENT,
register = 11062,
#scale = 0.001,
unit = REGISTER_U32,
scan_group = SCAN_GROUP_MPPT,
icon = "mdi:solar-power-variant",
Expand Down Expand Up @@ -785,6 +785,7 @@ def __init__(self, **kwargs):
device_class = SensorDeviceClass.BATTERY,
register = 33000,
scale = 0.01,
rounding = 2,
allowedtypes = HYBRID,
scan_group = SCAN_GROUP_MEDIUM,
),
Expand All @@ -794,6 +795,7 @@ def __init__(self, **kwargs):
native_unit_of_measurement = PERCENTAGE,
register = 33001,
scale = 0.01,
rounding = 2,
allowedtypes = HYBRID,
icon = "mdi:battery-heart",
entity_category = EntityCategory.DIAGNOSTIC,
Expand All @@ -820,6 +822,16 @@ def __init__(self, **kwargs):
icon = "mdi:information",
entity_category = EntityCategory.DIAGNOSTIC,
),
SolintegModbusSensorEntityDescription(
name = "Battery Hardware",
key = "battery_hardware",
register = 32004,
#unit = REGISTER_U16,
scale = lambda v, *a: _bytes_str(v.to_bytes(2)),
allowedtypes = HYBRID,
icon = "mdi:information",
entity_category = EntityCategory.DIAGNOSTIC,
),
SolintegModbusSensorEntityDescription(
name = "Battery Rated Capacity",
key = "battery_rated_capacity",
Expand All @@ -836,6 +848,7 @@ def __init__(self, **kwargs):
native_unit_of_measurement = UnitOfElectricPotential.VOLT,
register = 33015,
scale = 0.001,
rounding = 3,
allowedtypes = HYBRID,
icon = "mdi:battery-heart",
entity_registry_enabled_default = False,
Expand All @@ -844,6 +857,7 @@ def __init__(self, **kwargs):
SolintegModbusSensorEntityDescription(
name = "Bat. Min Cell Voltage ID",
key = "battery_min_cell_voltage_id",
native_unit_of_measurement = "",
register = 33014,
allowedtypes = HYBRID,
entity_registry_enabled_default = False,
Expand All @@ -855,6 +869,7 @@ def __init__(self, **kwargs):
native_unit_of_measurement = UnitOfElectricPotential.VOLT,
register = 33013,
scale = 0.001,
rounding = 3,
allowedtypes = HYBRID,
icon = "mdi:battery-heart",
entity_registry_enabled_default = False,
Expand All @@ -863,6 +878,7 @@ def __init__(self, **kwargs):
SolintegModbusSensorEntityDescription(
name = "Bat. Max Cell Voltage ID",
key = "battery_max_cell_voltage_id",
native_unit_of_measurement = "",
register = 33012,
allowedtypes = HYBRID,
entity_registry_enabled_default = False,
Expand Down Expand Up @@ -1070,6 +1086,7 @@ def __init__(self, **kwargs):
register = 11004, #0?
unit = REGISTER_U32,
scale = 0.01,
rounding = 2,
entity_registry_enabled_default = False,
icon = "mdi:home-import-outline",
),
Expand All @@ -1082,6 +1099,7 @@ def __init__(self, **kwargs):
register = 11002, #0?
unit = REGISTER_U32,
scale = 0.01,
rounding = 2,
entity_registry_enabled_default = False,
icon = "mdi:home-export-outline",
),
Expand Down

0 comments on commit 0b8b7c3

Please sign in to comment.