Skip to content

Commit

Permalink
Merge pull request #1098 from TonyMathiesen/Fix-total-grid-power-scaling
Browse files Browse the repository at this point in the history
Growatt TL3-XH: Fix missing scaling in "Total Grid Power" and change to VA
  • Loading branch information
wills106 authored Oct 21, 2024
2 parents 897f90e + c3f6169 commit 0c762e0
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions custom_components/solax_modbus/plugin_growatt.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@ 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)

def value_function_firmware_control_version(initval, descr, datadict):
fw_ascii = datadict.get('firmware_control_version_ascii', 0)
Expand Down Expand Up @@ -283,7 +285,6 @@ def value_function_run_mode(initval, descr, datadict):
}
return run_mode_dict.get(run_mode)


# ================================= Button Declarations ============================================================

BUTTON_TYPES = [
Expand Down Expand Up @@ -4348,22 +4349,36 @@ def value_function_run_mode(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_U32,
unit = REGISTER_S32,
scale = 0.1,
rounding = 1,
entity_registry_enabled_default = False,
allowedtypes = GEN4 | X1,
),
GrowattModbusSensorEntityDescription(
name = "Grid Power Total",
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_U32,
unit = REGISTER_S32,
scale = 0.1,
rounding = 1,
entity_registry_enabled_default = False,
allowedtypes = GEN4 | X3,
),
GrowattModbusSensorEntityDescription(
Expand Down

0 comments on commit 0c762e0

Please sign in to comment.