Skip to content

Commit 828f368

Browse files
authored
Handle flaky SimpliSafe notification registration (#34475)
1 parent 4a5cf5c commit 828f368

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

homeassistant/components/simplisafe/__init__.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -428,20 +428,19 @@ def _async_process_new_notifications(self, system):
428428
# ready. If that's the case, skip:
429429
return
430430

431-
old_notifications = self._system_notifications.get(system.system_id, [])
432-
latest_notifications = system.notifications
431+
latest_notifications = set(system.notifications)
433432

434-
# Save the latest notifications:
435-
self._system_notifications[system.system_id] = latest_notifications
436-
437-
# Process any notifications that are new:
438-
to_add = set(latest_notifications) - set(old_notifications)
433+
to_add = latest_notifications.difference(
434+
self._system_notifications[system.system_id]
435+
)
439436

440437
if not to_add:
441438
return
442439

443440
_LOGGER.debug("New system notifications: %s", to_add)
444441

442+
self._system_notifications[system.system_id].update(to_add)
443+
445444
for notification in to_add:
446445
text = notification.text
447446
if notification.link:
@@ -463,6 +462,8 @@ async def async_init(self):
463462

464463
self.systems = await self._api.get_systems()
465464
for system in self.systems.values():
465+
self._system_notifications[system.system_id] = set()
466+
466467
self._hass.async_create_task(
467468
async_register_base_station(
468469
self._hass, system, self._config_entry.entry_id

0 commit comments

Comments
 (0)