Don't abuse loop variable

This commit is contained in:
Aaron Bach
2020-02-03 18:03:51 -07:00
parent 5ccf2aee07
commit b885bd9d63

View File

@@ -436,17 +436,9 @@ class SimpliSafe:
)
)
async def refresh(event_time):
"""Refresh data from the SimpliSafe account."""
await self.async_update()
self._hass.data[DOMAIN][DATA_LISTENER][
self._config_entry.entry_id
] = async_track_time_interval(self._hass, refresh, DEFAULT_SCAN_INTERVAL)
# Future events will come from the websocket, but since subscription to the
# websocket doesn't provide the most recent event, we grab it from the REST API
# to ensure event-related attributes aren't empty on startup:
# websocket doesn't provide the most recent event, we grab it from the REST
# API to ensure event-related attributes aren't empty on startup:
try:
most_recent_event = await system.get_latest_event()
except SimplipyError as err:
@@ -455,6 +447,14 @@ class SimpliSafe:
else:
self.initial_event_to_use[system.system_id] = most_recent_event
async def refresh(event_time):
"""Refresh data from the SimpliSafe account."""
await self.async_update()
self._hass.data[DOMAIN][DATA_LISTENER][
self._config_entry.entry_id
] = async_track_time_interval(self._hass, refresh, DEFAULT_SCAN_INTERVAL)
await self.async_update()
async def async_update(self):