Skip to content

Commit

Permalink
Revert "Solax Gen4 meter direction and core meter direction fix"
Browse files Browse the repository at this point in the history
  • Loading branch information
wills106 authored Oct 13, 2024
1 parent 1f746b7 commit b63e6b3
Showing 1 changed file with 6 additions and 73 deletions.
79 changes: 6 additions & 73 deletions custom_components/solax_modbus/plugin_solax.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,19 +201,6 @@ def value_function_hardware_version_g4(initval, descr, datadict):
def value_function_hardware_version_g5(initval, descr, datadict):
return f"Gen5"

# Function to apply meter direction to raw power measurements
def value_function_measured_power(initval, descr, datadict):
meter_1_direction = datadict.get('meter_1_direction', 'Negativ')
_LOGGER.debug(f"meter_1_direction: {meter_1_direction}")

# If meter is set to Positiv direction it reports imported energy as negative values
# If meter is set to Negative direction it reports imported energy as positive values
measured_power = datadict.get('measured_power_raw', 0)
measured_power = measured_power if meter_1_direction == 'Negativ' else -(measured_power)
_LOGGER.debug(f"measured_power: {measured_power}")

return measured_power

def value_function_house_load(initval, descr, datadict):
return ( datadict.get('inverter_power', 0) - datadict.get('measured_power', 0) + datadict.get('meter_2_measured_power', 0) )

Expand Down Expand Up @@ -1382,32 +1369,6 @@ def value_function_battery_voltage_cell_difference(initval, descr, datadict):
entity_registry_enabled_default = False,
icon = "mdi:meter-electric",
),
SolaxModbusSelectEntityDescription(
name = "Meter 1 Direction",
key = "meter_1_direction",
register = 0x010B,
option_dict = {
0: "Positive",
1: "Negative",
},
allowedtypes = AC | HYBRID | GEN4,
entity_category = EntityCategory.CONFIG,
entity_registry_enabled_default = False,
icon = "mdi:meter-electric",
),
SolaxModbusSelectEntityDescription(
name = "Meter 2 Direction",
key = "meter_2_direction",
register = 0x010C,
option_dict = {
0: "Positive",
1: "Negative",
},
allowedtypes = AC | HYBRID | GEN4,
entity_category = EntityCategory.CONFIG,
entity_registry_enabled_default = False,
icon = "mdi:meter-electric",
),
SolaxModbusSelectEntityDescription(
name = "Device Lock",
key = "device_lock",
Expand Down Expand Up @@ -3181,22 +3142,6 @@ def value_function_battery_voltage_cell_difference(initval, descr, datadict):
allowedtypes = AC | HYBRID | GEN3,
internal = True,
),
SolaXModbusSensorEntityDescription(
key = "meter_1_direction",
register = 0x010B ,
scale = { 0: "Positive",
1: "Negative", },
allowedtypes = AC | HYBRID | GEN4,
internal = True,
),
SolaXModbusSensorEntityDescription(
key = "meter_2_direction",
register = 0x010C,
scale = { 0: "Positive",
1: "Negative", },
allowedtypes = AC | HYBRID | GEN4,
internal = True,
),
SolaXModbusSensorEntityDescription(
name = "FVRT Function",
key = "fvrt_function",
Expand Down Expand Up @@ -4222,16 +4167,15 @@ def value_function_battery_voltage_cell_difference(initval, descr, datadict):
allowedtypes = AC | HYBRID | GEN4 | GEN5,
),
SolaXModbusSensorEntityDescription(
name = "Measured Power Raw",
key = "measured_power_raw",
name = "Measured Power",
key = "measured_power",
native_unit_of_measurement = UnitOfPower.WATT,
device_class = SensorDeviceClass.POWER,
state_class = SensorStateClass.MEASUREMENT,
register = 0x46,
register_type = REG_INPUT,
unit = REGISTER_S32,
allowedtypes = AC | HYBRID | GEN2 | GEN3 | GEN4 | GEN5,
internal = True,
),
SolaXModbusSensorEntityDescription(
name = "Grid Export Total",
Expand Down Expand Up @@ -6012,15 +5956,6 @@ def value_function_battery_voltage_cell_difference(initval, descr, datadict):
# Computed
#
#####
SolaXModbusSensorEntityDescription(
name = "Measured Power",
key = "measured_power",
native_unit_of_measurement = UnitOfPower.WATT,
device_class = SensorDeviceClass.POWER,
state_class = SensorStateClass.MEASUREMENT,
value_function = value_function_measured_power,
allowedtypes = MIC | GEN2 | GEN3 | GEN4 | GEN5,
),
SolaXModbusSensorEntityDescription(
name = "Grid Export",
key = "grid_export",
Expand Down Expand Up @@ -6436,16 +6371,15 @@ def value_function_battery_voltage_cell_difference(initval, descr, datadict):
entity_category = EntityCategory.DIAGNOSTIC,
),
SolaXModbusSensorEntityDescription(
name = "Measured Power Raw",
key = "measured_power_raw",
name = "Measured Power",
key = "measured_power",
native_unit_of_measurement = UnitOfPower.WATT,
device_class = SensorDeviceClass.POWER,
state_class = SensorStateClass.MEASUREMENT,
register = 0x40E,
#newblock = True,
register_type = REG_INPUT,
allowedtypes = MIC | GEN | GEN2,
internal = True,
),
SolaXModbusSensorEntityDescription(
name = "Run Mode",
Expand Down Expand Up @@ -6907,15 +6841,14 @@ def value_function_battery_voltage_cell_difference(initval, descr, datadict):
allowedtypes = MIC | GEN4,
),
SolaXModbusSensorEntityDescription(
name = "Measured Power Raw",
key = "measured_power_raw",
name = "Measured Power",
key = "measured_power",
native_unit_of_measurement = UnitOfPower.WATT,
device_class = SensorDeviceClass.POWER,
state_class = SensorStateClass.MEASUREMENT,
register = 0x409,
register_type = REG_INPUT,
allowedtypes = MIC | GEN4 | GEN5,
internal = True,
),
SolaXModbusSensorEntityDescription(
name = "PV Voltage 1",
Expand Down

0 comments on commit b63e6b3

Please sign in to comment.