From fae4c4c87913b70daf96a8eb7f0a940c30a1765d Mon Sep 17 00:00:00 2001 From: Andre Basche Date: Tue, 16 May 2023 20:34:05 +0200 Subject: [PATCH] Check remote control only if available, fix #50 --- custom_components/hon/button.py | 2 +- custom_components/hon/number.py | 2 +- custom_components/hon/select.py | 2 +- custom_components/hon/switch.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/custom_components/hon/button.py b/custom_components/hon/button.py index ce8f9d4..b9063d0 100644 --- a/custom_components/hon/button.py +++ b/custom_components/hon/button.py @@ -69,7 +69,7 @@ class HonButtonEntity(HonEntity, ButtonEntity): """Return True if entity is available.""" return ( super().available - and self._device.get("remoteCtrValid") == "1" + and self._device.get("remoteCtrValid", "1") == "1" and self._device.get("attributes.lastConnEvent.category") != "DISCONNECTED" ) diff --git a/custom_components/hon/number.py b/custom_components/hon/number.py index 01aaac7..81e8d21 100644 --- a/custom_components/hon/number.py +++ b/custom_components/hon/number.py @@ -243,7 +243,7 @@ class HonNumberEntity(HonEntity, NumberEntity): else: return ( super().available - and self._device.get("remoteCtrValid") == "1" + and self._device.get("remoteCtrValid", "1") == "1" and self._device.get("attributes.lastConnEvent.category") != "DISCONNECTED" ) diff --git a/custom_components/hon/select.py b/custom_components/hon/select.py index 43b43ed..d769d3b 100644 --- a/custom_components/hon/select.py +++ b/custom_components/hon/select.py @@ -207,7 +207,7 @@ class HonSelectEntity(HonEntity, SelectEntity): else: return ( super().available - and self._device.get("remoteCtrValid") == "1" + and self._device.get("remoteCtrValid", "1") == "1" and self._device.get("attributes.lastConnEvent.category") != "DISCONNECTED" ) diff --git a/custom_components/hon/switch.py b/custom_components/hon/switch.py index b32ccba..5d58ef8 100644 --- a/custom_components/hon/switch.py +++ b/custom_components/hon/switch.py @@ -434,7 +434,7 @@ class HonSwitchEntity(HonEntity, SwitchEntity): else: return ( super().available - and self._device.get("remoteCtrValid") == "1" + and self._device.get("remoteCtrValid", "1") == "1" and self._device.get("attributes.lastConnEvent.category") != "DISCONNECTED" )