From 6935f5f07f729d78627d16003f74f3552af47d7e Mon Sep 17 00:00:00 2001 From: Andre Basche Date: Sun, 7 May 2023 19:12:45 +0200 Subject: [PATCH] Deactivate contols when remotectrl disabled, fixes #28 --- README.md | 2 -- custom_components/hon/binary_sensor.py | 16 ---------------- custom_components/hon/button.py | 5 +++++ custom_components/hon/switch.py | 8 ++++++++ 4 files changed, 13 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 2073bf6..6c137cd 100644 --- a/README.md +++ b/README.md @@ -209,7 +209,6 @@ I moved the api related stuff into the package [pyhOn](https://github.com/Andre0 | Pan Status | `pot-mix` | `binary_sensor` | `panStatus` | | Power | `lightning-bolt` | `sensor` | `power` | | Remaining Time | `timer` | `sensor` | `remainingTimeMM` | -| Remote Control | `remote` | `binary_sensor` | `attributes.parameters.remoteCtrValid` | | Temperature | `thermometer` | `sensor` | `temp` | ### Oven @@ -231,7 +230,6 @@ I moved the api related stuff into the package [pyhOn](https://github.com/Andre0 | Connection | `wifi` | `binary_sensor` | `attributes.lastConnEvent.category` | | On | `power-cycle` | `binary_sensor` | `attributes.parameters.onOffStatus` | | Remaining Time | `timer` | `sensor` | `remainingTimeMM` | -| Remote Control | `remote` | `binary_sensor` | `attributes.parameters.remoteCtrValid` | | Start Time | `clock-start` | `sensor` | `delayTime` | | Temperature | `thermometer` | `sensor` | `temp` | | Temperature Selected | `thermometer` | `sensor` | `tempSel` | diff --git a/custom_components/hon/binary_sensor.py b/custom_components/hon/binary_sensor.py index e024fd0..f7c0437 100644 --- a/custom_components/hon/binary_sensor.py +++ b/custom_components/hon/binary_sensor.py @@ -99,14 +99,6 @@ BINARY_SENSORS: dict[str, tuple[HonBinarySensorEntityDescription, ...]] = { icon="mdi:wifi", translation_key="connection", ), - HonBinarySensorEntityDescription( - key="attributes.parameters.remoteCtrValid", - name="Remote Control", - device_class=BinarySensorDeviceClass.CONNECTIVITY, - on_value="1", - icon="mdi:remote", - translation_key="remote_control", - ), HonBinarySensorEntityDescription( key="attributes.parameters.onOffStatus", name="On", @@ -125,14 +117,6 @@ BINARY_SENSORS: dict[str, tuple[HonBinarySensorEntityDescription, ...]] = { icon="mdi:wifi", translation_key="connection", ), - HonBinarySensorEntityDescription( - key="attributes.parameters.remoteCtrValid", - name="Remote Control", - device_class=BinarySensorDeviceClass.CONNECTIVITY, - on_value="1", - icon="mdi:remote", - translation_key="remote_control", - ), HonBinarySensorEntityDescription( key="attributes.parameters.onOffStatus", name="On", diff --git a/custom_components/hon/button.py b/custom_components/hon/button.py index 79759b5..5cf0497 100644 --- a/custom_components/hon/button.py +++ b/custom_components/hon/button.py @@ -80,3 +80,8 @@ 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" diff --git a/custom_components/hon/switch.py b/custom_components/hon/switch.py index a6e6989..9b751c3 100644 --- a/custom_components/hon/switch.py +++ b/custom_components/hon/switch.py @@ -379,3 +379,11 @@ class HonSwitchEntity(HonEntity, SwitchEntity): await self.coordinator.async_refresh() else: await self._device.commands[self.entity_description.turn_off_key].send() + + @property + def available(self) -> bool: + """Return True if entity is available.""" + if self.entity_category == EntityCategory.CONFIG: + return super().available + else: + return super().available and self._device.get("remoteCtrValid") == "1"