Small fixes, fix KeyError for switches #38

This commit is contained in:
Andre Basche 2023-05-08 19:17:08 +02:00
parent 44794c35ca
commit 240dc85ff3
6 changed files with 33 additions and 27 deletions

View file

@ -64,6 +64,11 @@ class HonButtonEntity(HonEntity, ButtonEntity):
async def async_press(self) -> None:
await self._device.commands[self.entity_description.key].send()
@property
def available(self) -> bool:
"""Return True if entity is available."""
return super().available and self._device.get("remoteCtrValid") == "1"
class HonFeatureRequestButton(HonEntity, ButtonEntity):
def __init__(self, hass, coordinator, entry, device: HonAppliance) -> None:
@ -80,8 +85,3 @@ class HonFeatureRequestButton(HonEntity, ButtonEntity):
pyhon_version = pkg_resources.get_distribution("pyhon").version
info = f"Device Info:\n{self._device.diagnose}pyhOnVersion: {pyhon_version}"
_LOGGER.error(info)
@property
def available(self) -> bool:
"""Return True if entity is available."""
return super().available and self._device.get("remoteCtrValid") == "1"