diff --git a/custom_components/solax_modbus/manifest.json b/custom_components/solax_modbus/manifest.json index 68ea4730..12ba9487 100644 --- a/custom_components/solax_modbus/manifest.json +++ b/custom_components/solax_modbus/manifest.json @@ -9,5 +9,5 @@ "iot_class": "local_polling", "issue_tracker": "https://github.com/wills106/homsassistant-solax-modbus/issues", "requirements": ["pymodbus>=3.6.8"], - "version": "2024.08.2" + "version": "2024.08.3" } diff --git a/custom_components/solax_modbus/plugin_growatt.py b/custom_components/solax_modbus/plugin_growatt.py index 487fa76b..addfc2c8 100644 --- a/custom_components/solax_modbus/plugin_growatt.py +++ b/custom_components/solax_modbus/plugin_growatt.py @@ -3328,6 +3328,22 @@ def value_function_combined_battery_power(initval, descr, datadict): ), # TL-X TL-XH + GrowattModbusSensorEntityDescription( + name = "Inverter State", + key = "inverter_state", + register = 3000, + unit = REGISTER_U8H, + scale = { 0: "Waiting", 3: "Fault", 4: "Flash", 5: "PV Bat Online", 6: "Bat Online", }, + allowedtypes = GEN3 | GEN4, + ), + GrowattModbusSensorEntityDescription( + name = "Run Mode", + key = "run_mode", + register = 3000, + unit = REGISTER_U8L, + scale = { 0: "Standby", 1: "Normal", 3: "Fault", 4: "Flash", }, + allowedtypes = GEN3 | GEN4, + ), GrowattModbusSensorEntityDescription( name = "Total PV Power", key = "total_pv_power", diff --git a/custom_components/solax_modbus/plugin_solax.py b/custom_components/solax_modbus/plugin_solax.py index 35a49f84..7d82172e 100644 --- a/custom_components/solax_modbus/plugin_solax.py +++ b/custom_components/solax_modbus/plugin_solax.py @@ -2537,7 +2537,7 @@ def value_function_software_version_air_g4(initval, descr, datadict): key = "registration_code_pocket", register = 0xAA, unit = REGISTER_STR, - wordcount=5, + wordcount = 5, entity_registry_enabled_default = False, allowedtypes = AC | HYBRID | GEN3 | GEN4 | GEN5, entity_category = EntityCategory.DIAGNOSTIC, @@ -2548,7 +2548,7 @@ def value_function_software_version_air_g4(initval, descr, datadict): key = "registration_code_lan", register = 0xAF, unit = REGISTER_STR, - wordcount=5, + wordcount = 5, entity_registry_enabled_default = False, allowedtypes = AC | HYBRID | GEN3, entity_category = EntityCategory.DIAGNOSTIC, @@ -2667,7 +2667,7 @@ def value_function_software_version_air_g4(initval, descr, datadict): key = "inverter_model_number", register = 0xE9, unit = REGISTER_STR, - wordcount=10, + wordcount = 10, allowedtypes = AC | HYBRID | GEN3, entity_registry_enabled_default = False, entity_category = EntityCategory.DIAGNOSTIC, @@ -7023,7 +7023,7 @@ def value_function_software_version_air_g4(initval, descr, datadict): key = "model_number", register = 0x1A00, unit = REGISTER_STR, - wordcount=8, + wordcount = 8, allowedtypes = MAX, entity_category = EntityCategory.DIAGNOSTIC, icon = "mdi:information", @@ -7033,7 +7033,7 @@ def value_function_software_version_air_g4(initval, descr, datadict): key = "serial_number", register = 0x1A10, unit = REGISTER_STR, - wordcount=8, + wordcount = 8, allowedtypes = MAX, entity_category = EntityCategory.DIAGNOSTIC, icon = "mdi:information", @@ -7043,7 +7043,7 @@ def value_function_software_version_air_g4(initval, descr, datadict): key = "software_version", register = 0x1A1C, unit = REGISTER_STR, - wordcount=3, + wordcount = 3, allowedtypes = MAX, icon = "mdi:information", ), diff --git a/custom_components/solax_modbus/plugin_solax_mega_forth.py b/custom_components/solax_modbus/plugin_solax_mega_forth.py index beaf1273..84ba3f4d 100644 --- a/custom_components/solax_modbus/plugin_solax_mega_forth.py +++ b/custom_components/solax_modbus/plugin_solax_mega_forth.py @@ -110,7 +110,34 @@ class SolaXModbusSensorEntityDescription(BaseModbusSensorEntityDescription): EXPORT_LIMIT_SCALE_EXCEPTIONS = [] -NUMBER_TYPES = [] +NUMBER_TYPES = [ + + SolaxModbusNumberEntityDescription( + name = "Active Power", + key = "active_power", + register = 0x2304, + fmt = "i", + native_min_value = 1, + native_max_value = 100, + native_step = 1, + scale = 0.1, + native_unit_of_measurement = PERCENTAGE, + allowedtypes = MAX | GEN2, + ), + SolaxModbusNumberEntityDescription( + name = "Reactive Power", + key = "reactive_power", + register = 0x2305, + fmt = "i", + native_min_value = 1, + native_max_value = 100, + native_step = 1, + scale = 0.1, + native_unit_of_measurement = PERCENTAGE, + allowedtypes = MAX | GEN2, + ), + +] # ================================= Select Declarations ============================================================ @@ -129,6 +156,26 @@ class SolaXModbusSensorEntityDescription(BaseModbusSensorEntityDescription): # Input Registers # ##### + SolaXModbusSensorEntityDescription( + name = "Model Type", + key = "model_type", + register = 0x12, + unit = REGISTER_STR, + wordcount = 8, + allowedtypes = MAX | GEN2, + entity_category = EntityCategory.DIAGNOSTIC, + icon = "mdi:information", + ), + SolaXModbusSensorEntityDescription( + name = "Software Version", + key = "software_version", + register = 0x22, + unit = REGISTER_STR, + wordcount = 8, + allowedtypes = MAX | GEN2, + entity_category = EntityCategory.DIAGNOSTIC, + icon = "mdi:information", + ), SolaXModbusSensorEntityDescription( name = "Grid Voltage L1", key = "grid_voltage_l1", @@ -213,26 +260,35 @@ class SolaXModbusSensorEntityDescription(BaseModbusSensorEntityDescription): device_class = SensorDeviceClass.CURRENT, register = 0x180, register_type = REG_INPUT, - scale = 0.01, - rounding = 2, + scale = 0.1, + rounding = 1, allowedtypes = MAX | GEN2, ), SolaXModbusSensorEntityDescription( - name = "Measured Power L1", - key = "measured_power_l1", - native_unit_of_measurement = UnitOfPower.WATT, - device_class = SensorDeviceClass.POWER, - state_class = SensorStateClass.MEASUREMENT, - register = 0x1003, + name = "Inverter Current L2", + key = "inverter_current_l2", + native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, + device_class = SensorDeviceClass.CURRENT, + register = 0x181, register_type = REG_INPUT, - unit = REGISTER_U32, scale = 0.1, rounding = 1, allowedtypes = MAX | GEN2, - ), + ), SolaXModbusSensorEntityDescription( - name = "Active Power", - key = "active_power", + name = "Inverter Current L3", + key = "inverter_current_l3", + native_unit_of_measurement = UnitOfElectricCurrent.AMPERE, + device_class = SensorDeviceClass.CURRENT, + register = 0x182, + register_type = REG_INPUT, + scale = 0.1, + rounding = 1, + allowedtypes = MAX | GEN2, + ), + SolaXModbusSensorEntityDescription( + name = "Active Power Energy", + key = "active_power_energy", native_unit_of_measurement = UnitOfPower.WATT, device_class = SensorDeviceClass.POWER, state_class = SensorStateClass.MEASUREMENT, @@ -257,10 +313,57 @@ class SolaXModbusSensorEntityDescription(BaseModbusSensorEntityDescription): key = "apparent_power", native_unit_of_measurement = UnitOfApparentPower.VOLT_AMPERE, device_class = SensorDeviceClass.APPARENT_POWER, - register = 0x223, + register = 0x187, + register_type = REG_INPUT, + unit = REGISTER_U32, + allowedtypes = MAX | GEN2, + ), + SolaXModbusSensorEntityDescription( + name = "Today's Energy", + key = "today_s_energy", + native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, + device_class = SensorDeviceClass.ENERGY, + state_class = SensorStateClass.TOTAL_INCREASING, + register = 0x189, + register_type = REG_INPUT, + scale = 0.1, + allowedtypes = MAX | GEN2, + ), + SolaXModbusSensorEntityDescription( + name = "Total Energy", + key = "total_energy", + native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR, + device_class = SensorDeviceClass.ENERGY, + state_class = SensorStateClass.TOTAL_INCREASING, + register = 0x18A, register_type = REG_INPUT, unit = REGISTER_U32, + scale = 0.1, + allowedtypes = MAX | GEN2, + ), + SolaXModbusSensorEntityDescription( + name = "Power Factor", + key = "power_factor", + native_unit_of_measurement = None, + device_class = SensorDeviceClass.POWER_FACTOR, + state_class = SensorStateClass.MEASUREMENT, + register = 0x18F, + unit = REGISTER_S16, + scale = 0.001, + allowedtypes = MAX | GEN2, + ), + SolaXModbusSensorEntityDescription( + name = "Inverter Temperature", + key = "inverter_temperature", + native_unit_of_measurement = UnitOfTemperature.CELSIUS, + device_class = SensorDeviceClass.TEMPERATURE, + state_class = SensorStateClass.MEASUREMENT, + register = 0x28F, + register_type = REG_INPUT, + unit = REGISTER_S16, + scale = 0.1, allowedtypes = MAX | GEN2, + entity_category = EntityCategory.DIAGNOSTIC, ), SolaXModbusSensorEntityDescription( name = "PV Voltage 1", @@ -269,6 +372,7 @@ class SolaXModbusSensorEntityDescription(BaseModbusSensorEntityDescription): device_class = SensorDeviceClass.VOLTAGE, register = 0x28B, register_type = REG_INPUT, + unit = REGISTER_S16, scale = 0.1, rounding = 1, allowedtypes = MAX | GEN2, @@ -280,6 +384,7 @@ class SolaXModbusSensorEntityDescription(BaseModbusSensorEntityDescription): device_class = SensorDeviceClass.CURRENT, register = 0x28C, register_type = REG_INPUT, + unit = REGISTER_S16, scale = 0.1, rounding = 1, allowedtypes = MAX | GEN2, @@ -293,7 +398,7 @@ class SolaXModbusSensorEntityDescription(BaseModbusSensorEntityDescription): state_class = SensorStateClass.MEASUREMENT, register = 0x28D, register_type = REG_INPUT, - unit = REGISTER_U32, + unit = REGISTER_S32, allowedtypes = MAX | GEN2, icon = "mdi:solar-power-variant", ), @@ -316,6 +421,7 @@ class SolaXModbusSensorEntityDescription(BaseModbusSensorEntityDescription): device_class = SensorDeviceClass.VOLTAGE, register = 0x292, register_type = REG_INPUT, + unit = REGISTER_S16, scale = 0.1, rounding = 1, allowedtypes = MAX | GEN2, @@ -327,6 +433,7 @@ class SolaXModbusSensorEntityDescription(BaseModbusSensorEntityDescription): device_class = SensorDeviceClass.CURRENT, register = 0x293, register_type = REG_INPUT, + unit = REGISTER_S16, scale = 0.1, rounding = 1, allowedtypes = MAX | GEN2, @@ -340,7 +447,7 @@ class SolaXModbusSensorEntityDescription(BaseModbusSensorEntityDescription): state_class = SensorStateClass.MEASUREMENT, register = 0x294, register_type = REG_INPUT, - unit = REGISTER_U32, + unit = REGISTER_S32, allowedtypes = MAX | GEN2, icon = "mdi:solar-power-variant", ), @@ -363,6 +470,7 @@ class SolaXModbusSensorEntityDescription(BaseModbusSensorEntityDescription): device_class = SensorDeviceClass.VOLTAGE, register = 0x299, register_type = REG_INPUT, + unit = REGISTER_S16, scale = 0.1, rounding = 1, allowedtypes = MAX | GEN2, @@ -374,6 +482,7 @@ class SolaXModbusSensorEntityDescription(BaseModbusSensorEntityDescription): device_class = SensorDeviceClass.CURRENT, register = 0x29A, register_type = REG_INPUT, + unit = REGISTER_S16, scale = 0.1, rounding = 1, allowedtypes = MAX | GEN2, @@ -387,7 +496,7 @@ class SolaXModbusSensorEntityDescription(BaseModbusSensorEntityDescription): state_class = SensorStateClass.MEASUREMENT, register = 0x29B, register_type = REG_INPUT, - unit = REGISTER_U32, + unit = REGISTER_S32, allowedtypes = MAX | GEN2, icon = "mdi:solar-power-variant", ), @@ -410,6 +519,7 @@ class SolaXModbusSensorEntityDescription(BaseModbusSensorEntityDescription): device_class = SensorDeviceClass.VOLTAGE, register = 0x2A0, register_type = REG_INPUT, + unit = REGISTER_S16, scale = 0.1, rounding = 1, allowedtypes = MAX | GEN2, @@ -421,6 +531,7 @@ class SolaXModbusSensorEntityDescription(BaseModbusSensorEntityDescription): device_class = SensorDeviceClass.CURRENT, register = 0x2A1, register_type = REG_INPUT, + unit = REGISTER_S16, scale = 0.1, rounding = 1, allowedtypes = MAX | GEN2, @@ -434,7 +545,7 @@ class SolaXModbusSensorEntityDescription(BaseModbusSensorEntityDescription): state_class = SensorStateClass.MEASUREMENT, register = 0x2A2, register_type = REG_INPUT, - unit = REGISTER_U32, + unit = REGISTER_S32, allowedtypes = MAX | GEN2, icon = "mdi:solar-power-variant", ), @@ -450,6 +561,20 @@ class SolaXModbusSensorEntityDescription(BaseModbusSensorEntityDescription): allowedtypes = MAX | GEN2, entity_category = EntityCategory.DIAGNOSTIC, ), + SolaXModbusSensorEntityDescription( + key = "active_power", + register = 0x2304, + scale = 0.1, + allowedtypes = MAX | GEN2, + internal = True, + ), + SolaXModbusSensorEntityDescription( + key = "reactive_power", + register = 0x2305, + scale = 0.1, + allowedtypes = MAX | GEN2, + internal = True, + ), ] # ============================ plugin declaration =================================================