Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 deletions custom_components/solaredge_modbus_multi/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ async def async_setup_entry(
entities.append(ACPower(meter, config_entry, coordinator, "A"))
entities.append(ACPower(meter, config_entry, coordinator, "B"))
entities.append(ACPower(meter, config_entry, coordinator, "C"))
entities.append(ACPowerInverted(meter, config_entry, coordinator))
entities.append(ACVoltAmp(meter, config_entry, coordinator))
entities.append(ACVoltAmp(meter, config_entry, coordinator, "A"))
entities.append(ACVoltAmp(meter, config_entry, coordinator, "B"))
Expand Down Expand Up @@ -603,6 +604,26 @@ def suggested_display_precision(self):
return abs(self._platform.decoded_model["AC_Power_SF"])


class ACPowerInverted(ACPower):
def __init__(self, platform, config_entry, coordinator):
super().__init__(platform, config_entry, coordinator)

@property
def unique_id(self) -> str:
return f"{super().unique_id}_inverted"

@property
def name(self) -> str:
return f"{super().name} Inverted"

@property
def native_value(self):
value = super().native_value
if value is None:
return None
return -value


class ACFrequency(SolarEdgeSensorBase):
device_class = SensorDeviceClass.FREQUENCY
state_class = SensorStateClass.MEASUREMENT
Expand Down Expand Up @@ -1385,14 +1406,12 @@ def extra_state_attributes(self):


class SolarEdgeGlobalPowerControlBlock(SolarEdgeSensorBase):

@property
def available(self) -> bool:
return super().available and self._platform.global_power_control


class SolarEdgeRRCR(SolarEdgeGlobalPowerControlBlock):

@property
def unique_id(self) -> str:
return f"{self._platform.uid_base}_rrcr"
Expand Down Expand Up @@ -2138,7 +2157,6 @@ class SolarEdgeBatteryPowerBase(SolarEdgeSensorBase):


class SolarEdgeBatteryMaxChargePower(SolarEdgeBatteryPowerBase):

@property
def unique_id(self) -> str:
return f"{self._platform.uid_base}_max_charge_power"
Expand All @@ -2164,7 +2182,6 @@ def native_value(self):


class SolarEdgeBatteryMaxChargePeakPower(SolarEdgeBatteryPowerBase):

@property
def unique_id(self) -> str:
return f"{self._platform.uid_base}_max_charge_peak_power"
Expand All @@ -2190,7 +2207,6 @@ def native_value(self):


class SolarEdgeBatteryMaxDischargePower(SolarEdgeBatteryPowerBase):

@property
def unique_id(self) -> str:
return f"{self._platform.uid_base}_max_discharge_power"
Expand All @@ -2216,7 +2232,6 @@ def native_value(self):


class SolarEdgeBatteryMaxDischargePeakPower(SolarEdgeBatteryPowerBase):

@property
def unique_id(self) -> str:
return f"{self._platform.uid_base}_max_discharge_peak_power"
Expand Down Expand Up @@ -2343,7 +2358,6 @@ def native_value(self):


class SolarEdgeAdvancedPowerControlBlock(SolarEdgeSensorBase):

@property
def available(self) -> bool:
return super().available and self._platform.advanced_power_control
Expand Down