Fix exception in august if bridge is missing (#60316)

pull/60325/head
J. Nick Koston 2021-11-25 05:30:57 -06:00 committed by GitHub
parent 3372288c88
commit 995f01cb68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 19 deletions

View File

@ -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):