Ensure existing SimpliSafe notifications trigger event on HASS startup (#34232)

* Ensure existing SimpliSafe notifications trigger event on HASS startup

* Don't redefine a standing function each loop iteration

* Wait until HASS state is "running"

* Linting

* Linting

* Code review

* Code review

* Simplify

* Code review

* Cleanup
pull/30283/head^2
Aaron Bach 2020-04-19 19:41:16 -06:00 committed by GitHub
parent 6d7fb9f46a
commit 675525f47c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -24,7 +24,7 @@ from homeassistant.const import (
CONF_TOKEN,
CONF_USERNAME,
)
from homeassistant.core import callback
from homeassistant.core import CoreState, callback
from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers import (
aiohttp_client,
@ -422,6 +422,12 @@ class SimpliSafe:
@callback
def _async_process_new_notifications(self, system):
"""Act on any new system notifications."""
if self._hass.state != CoreState.running:
# If HASS isn't fully running yet, it may cause the SIMPLISAFE_NOTIFICATION
# event to fire before dependent components (like automation) are fully
# ready. If that's the case, skip:
return
old_notifications = self._system_notifications.get(system.system_id, [])
latest_notifications = system.notifications