Skip to content
Merged
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
37 changes: 28 additions & 9 deletions custom_components/solaredge_modbus_multi/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ async def async_setup_entry(
entities.append(SolarEdgeCosPhi(inverter, config_entry, coordinator))

""" Power Control Block """
if hub.option_detect_extras and inverter.advanced_power_control:
if hub.option_detect_extras:
entities.append(
SolarEdgeCommitControlSettings(inverter, config_entry, coordinator)
)
Expand Down Expand Up @@ -1344,12 +1344,6 @@ def extra_state_attributes(self):
return attrs


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


class StatusVendor(SolarEdgeSensorBase):
entity_category = EntityCategory.DIAGNOSTIC

Expand Down Expand Up @@ -1390,6 +1384,12 @@ def extra_state_attributes(self):
return None


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:
Expand Down Expand Up @@ -2336,7 +2336,13 @@ def native_value(self):
return self._platform.decoded_model["B_SOE"]


class SolarEdgeCommitControlSettings(SolarEdgeSensorBase):
class SolarEdgeAdvancedPowerControlBlock(SolarEdgeSensorBase):
@property
def available(self) -> bool:
return super().available and self._platform.advanced_power_control


class SolarEdgeCommitControlSettings(SolarEdgeAdvancedPowerControlBlock):
"""Entity to show the results of Commit Power Control Settings button."""

entity_category = EntityCategory.DIAGNOSTIC
Expand All @@ -2350,6 +2356,12 @@ def unique_id(self) -> str:
def name(self) -> str:
return "Commit Power Settings"

@property
def available(self) -> bool:
return (
super().available and "CommitPwrCtlSettings" in self._platform.decoded_model
)

@property
def native_value(self):
return self._platform.decoded_model["CommitPwrCtlSettings"]
Expand All @@ -2375,7 +2387,7 @@ def extra_state_attributes(self):
return attrs


class SolarEdgeDefaultControlSettings(SolarEdgeSensorBase):
class SolarEdgeDefaultControlSettings(SolarEdgeAdvancedPowerControlBlock):
"""Entity to show the results of Restore Power Control Default Settings button."""

entity_category = EntityCategory.DIAGNOSTIC
Expand All @@ -2389,6 +2401,13 @@ def unique_id(self) -> str:
def name(self) -> str:
return "Default Power Settings"

@property
def available(self) -> bool:
return (
super().available
and "RestorePwrCtlDefaults" in self._platform.decoded_model
)

@property
def native_value(self):
return self._platform.decoded_model["RestorePwrCtlDefaults"]
Expand Down