From 77a4c4dd53bc459c02ed9d83330c289f8cefb1ac Mon Sep 17 00:00:00 2001 From: TonyMathiesen <95135900+TonyMathiesen@users.noreply.github.com> Date: Tue, 15 Oct 2024 20:18:54 +0200 Subject: [PATCH 1/3] Fix missing scaling in "Total Grid Power" --- custom_components/solax_modbus/plugin_growatt.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/custom_components/solax_modbus/plugin_growatt.py b/custom_components/solax_modbus/plugin_growatt.py index 15c911ca..cc2f4340 100644 --- a/custom_components/solax_modbus/plugin_growatt.py +++ b/custom_components/solax_modbus/plugin_growatt.py @@ -4029,7 +4029,7 @@ def value_function_combined_battery_power(initval, descr, datadict): state_class = SensorStateClass.MEASUREMENT, register = 3023, register_type = REG_INPUT, - unit = REGISTER_U32, + unit = REGISTER_S32, scale = 0.1, rounding = 1, allowedtypes = GEN4 | X1, @@ -4042,7 +4042,9 @@ def value_function_combined_battery_power(initval, descr, datadict): state_class = SensorStateClass.MEASUREMENT, register = 3023, register_type = REG_INPUT, - unit = REGISTER_U32, + unit = REGISTER_S32, + scale = 0.1, + rounding = 1, allowedtypes = GEN4 | X3, ), GrowattModbusSensorEntityDescription( From cdb525d5743e0b03ed0839ed93da6d4db98d6a45 Mon Sep 17 00:00:00 2001 From: TonyMathiesen <95135900+TonyMathiesen@users.noreply.github.com> Date: Tue, 15 Oct 2024 20:52:53 +0200 Subject: [PATCH 2/3] Change to Total Grid Power (VA) --- .../solax_modbus/plugin_growatt.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/custom_components/solax_modbus/plugin_growatt.py b/custom_components/solax_modbus/plugin_growatt.py index cc2f4340..687a3347 100644 --- a/custom_components/solax_modbus/plugin_growatt.py +++ b/custom_components/solax_modbus/plugin_growatt.py @@ -113,6 +113,9 @@ def value_function_today_s_solar_energy(initval, descr, datadict): def value_function_combined_battery_power(initval, descr, datadict): return datadict.get('battery_charge_power', 0) - datadict.get('battery_discharge_power',0) +def value_function_total_grid_power(initval, descr, datadict): + return datadict.get('grid_power_l1', 0) + datadict.get('grid_power_l2', 0) + datadict.get('grid_power_l3', 0) + # ================================= Button Declarations ============================================================ BUTTON_TYPES = [ @@ -4027,24 +4030,36 @@ def value_function_combined_battery_power(initval, descr, datadict): native_unit_of_measurement = UnitOfPower.WATT, device_class = SensorDeviceClass.POWER, state_class = SensorStateClass.MEASUREMENT, - register = 3023, + register = 3023, #is output power register_type = REG_INPUT, unit = REGISTER_S32, scale = 0.1, rounding = 1, + entity_registry_enabled_default = False, allowedtypes = GEN4 | X1, ), + GrowattModbusSensorEntityDescription( + name = "Total Grid Power", + key = "total_grid_power_va", + native_unit_of_measurement = UnitOfApparentPower.VOLT_AMPERE, + device_class = SensorDeviceClass.APPARENT_POWER, + state_class = SensorStateClass.MEASUREMENT, + value_function = value_function_total_grid_power, + rounding = 1, + allowedtypes = GEN4 | X3, + ), GrowattModbusSensorEntityDescription( name = "Total Grid Power", key = "total_grid_power", native_unit_of_measurement = UnitOfPower.WATT, device_class = SensorDeviceClass.POWER, state_class = SensorStateClass.MEASUREMENT, - register = 3023, + register = 3023, #is output power register_type = REG_INPUT, unit = REGISTER_S32, scale = 0.1, rounding = 1, + entity_registry_enabled_default = False, allowedtypes = GEN4 | X3, ), GrowattModbusSensorEntityDescription( From 36ca50565c6f5e6cb3df480b2830f6cbaafa1428 Mon Sep 17 00:00:00 2001 From: TonyMathiesen <95135900+TonyMathiesen@users.noreply.github.com> Date: Tue, 15 Oct 2024 21:57:29 +0200 Subject: [PATCH 3/3] Update plugin_growatt.py --- custom_components/solax_modbus/plugin_growatt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/solax_modbus/plugin_growatt.py b/custom_components/solax_modbus/plugin_growatt.py index 687a3347..8b084218 100644 --- a/custom_components/solax_modbus/plugin_growatt.py +++ b/custom_components/solax_modbus/plugin_growatt.py @@ -4039,7 +4039,7 @@ def value_function_total_grid_power(initval, descr, datadict): allowedtypes = GEN4 | X1, ), GrowattModbusSensorEntityDescription( - name = "Total Grid Power", + name = "Grid Power Total", key = "total_grid_power_va", native_unit_of_measurement = UnitOfApparentPower.VOLT_AMPERE, device_class = SensorDeviceClass.APPARENT_POWER,