Skip to content

Add available properties to commit and restore sensors #824

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 28, 2025
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