Set switches unavailable if not changable
This commit is contained in:
parent
c0d25a4efe
commit
a687c7715d
1 changed files with 10 additions and 5 deletions
|
@ -405,11 +405,16 @@ class HonSwitchEntity(HonEntity, SwitchEntity):
|
||||||
@property
|
@property
|
||||||
def available(self) -> bool:
|
def available(self) -> bool:
|
||||||
"""Return True if entity is available."""
|
"""Return True if entity is available."""
|
||||||
return (
|
if not super().available:
|
||||||
super().available
|
return False
|
||||||
and int(self._device.get("remoteCtrValid", 1)) == 1
|
if not self._device.get("remoteCtrValid", 1) == 1:
|
||||||
and self._device.get("attributes.lastConnEvent.category") != "DISCONNECTED"
|
return False
|
||||||
)
|
if self._device.get("attributes.lastConnEvent.category") == "DISCONNECTED":
|
||||||
|
return False
|
||||||
|
setting = self._device.settings[f"settings.{self.entity_description.key}"]
|
||||||
|
if isinstance(setting, HonParameterRange) and len(setting.values) < 2:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def _handle_coordinator_update(self, update=True) -> None:
|
def _handle_coordinator_update(self, update=True) -> None:
|
||||||
|
|
Loading…
Reference in a new issue