mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 12:47:08 +00:00
Handle flaky SimpliSafe notification registration (#34475)
This commit is contained in:
parent
4a5cf5cd2b
commit
828f368323
@ -428,20 +428,19 @@ class SimpliSafe:
|
|||||||
# ready. If that's the case, skip:
|
# ready. If that's the case, skip:
|
||||||
return
|
return
|
||||||
|
|
||||||
old_notifications = self._system_notifications.get(system.system_id, [])
|
latest_notifications = set(system.notifications)
|
||||||
latest_notifications = system.notifications
|
|
||||||
|
|
||||||
# Save the latest notifications:
|
to_add = latest_notifications.difference(
|
||||||
self._system_notifications[system.system_id] = latest_notifications
|
self._system_notifications[system.system_id]
|
||||||
|
)
|
||||||
# Process any notifications that are new:
|
|
||||||
to_add = set(latest_notifications) - set(old_notifications)
|
|
||||||
|
|
||||||
if not to_add:
|
if not to_add:
|
||||||
return
|
return
|
||||||
|
|
||||||
_LOGGER.debug("New system notifications: %s", to_add)
|
_LOGGER.debug("New system notifications: %s", to_add)
|
||||||
|
|
||||||
|
self._system_notifications[system.system_id].update(to_add)
|
||||||
|
|
||||||
for notification in to_add:
|
for notification in to_add:
|
||||||
text = notification.text
|
text = notification.text
|
||||||
if notification.link:
|
if notification.link:
|
||||||
@ -463,6 +462,8 @@ class SimpliSafe:
|
|||||||
|
|
||||||
self.systems = await self._api.get_systems()
|
self.systems = await self._api.get_systems()
|
||||||
for system in self.systems.values():
|
for system in self.systems.values():
|
||||||
|
self._system_notifications[system.system_id] = set()
|
||||||
|
|
||||||
self._hass.async_create_task(
|
self._hass.async_create_task(
|
||||||
async_register_base_station(
|
async_register_base_station(
|
||||||
self._hass, system, self._config_entry.entry_id
|
self._hass, system, self._config_entry.entry_id
|
||||||
|
Loading…
x
Reference in New Issue
Block a user