From 7dfa0db409a043af8f0cdd70eda302526f25ebb8 Mon Sep 17 00:00:00 2001 From: G Johansson Date: Mon, 20 Dec 2021 11:59:15 +0100 Subject: [PATCH] Fix lock update --- custom_components/sector/lock.py | 4 +++- custom_components/sector/switch.py | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/custom_components/sector/lock.py b/custom_components/sector/lock.py index 6a8608b..fe0527b 100644 --- a/custom_components/sector/lock.py +++ b/custom_components/sector/lock.py @@ -34,6 +34,8 @@ async def async_setup_entry( return locks = await sector_hub.get_locks() + if not locks: + return lockdevices: list = [] for lock in locks: name = await sector_hub.get_name(lock, "lock") @@ -122,6 +124,6 @@ async def async_lock(self, **kwargs) -> None: def _handle_coordinator_update(self) -> None: """Handle updated data from the coordinator.""" self._attr_is_locked = bool( - self._hub.lock_state[self.entity_description.key] == STATE_LOCKED + self._hub.lock_state[self.entity_description.key] == "lock" ) self.async_write_ha_state() diff --git a/custom_components/sector/switch.py b/custom_components/sector/switch.py index 0a9a514..b038c98 100644 --- a/custom_components/sector/switch.py +++ b/custom_components/sector/switch.py @@ -32,6 +32,8 @@ async def async_setup_entry( ] switches = await sector_hub.get_switches() + if not switches: + return switchlist: list = [] for switch in switches: name = await sector_hub.get_name(switch, "switch")