From 995f01cb686f350f5799c3783dfc31082a53d05c Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 25 Nov 2021 05:30:57 -0600 Subject: [PATCH] Fix exception in august if bridge is missing (#60316) --- homeassistant/components/august/__init__.py | 29 +++++++-------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/homeassistant/components/august/__init__.py b/homeassistant/components/august/__init__.py index 700b03a85da..474e69db435 100644 --- a/homeassistant/components/august/__init__.py +++ b/homeassistant/components/august/__init__.py @@ -272,19 +272,13 @@ class AugustData(AugustSubscriberMixin): def _remove_inoperative_doorbells(self): for doorbell in list(self.doorbells): device_id = doorbell.device_id - doorbell_is_operative = False - doorbell_detail = self._device_detail_by_id.get(device_id) - if doorbell_detail is None: - _LOGGER.info( - "The doorbell %s could not be setup because the system could not fetch details about the doorbell", - doorbell.device_name, - ) - else: - doorbell_is_operative = True - - if not doorbell_is_operative: - del self._doorbells_by_id[device_id] - del self._device_detail_by_id[device_id] + if self._device_detail_by_id.get(device_id): + continue + _LOGGER.info( + "The doorbell %s could not be setup because the system could not fetch details about the doorbell", + doorbell.device_name, + ) + del self._doorbells_by_id[device_id] def _remove_inoperative_locks(self): # Remove non-operative locks as there must @@ -292,7 +286,6 @@ class AugustData(AugustSubscriberMixin): # be usable for lock in list(self.locks): device_id = lock.device_id - lock_is_operative = False lock_detail = self._device_detail_by_id.get(device_id) if lock_detail is None: _LOGGER.info( @@ -304,14 +297,12 @@ class AugustData(AugustSubscriberMixin): "The lock %s could not be setup because it does not have a bridge (Connect)", lock.device_name, ) + del self._device_detail_by_id[device_id] # Bridge may come back online later so we still add the device since we will # have a pubnub subscription to tell use when it recovers else: - lock_is_operative = True - - if not lock_is_operative: - del self._locks_by_id[device_id] - del self._device_detail_by_id[device_id] + continue + del self._locks_by_id[device_id] def _save_live_attrs(lock_detail):