mirror of
https://github.com/home-assistant/core.git
synced 2025-08-10 08:05:06 +02:00
Don't abuse loop variable
This commit is contained in:
@@ -436,6 +436,17 @@ class SimpliSafe:
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# 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:
|
||||||
|
try:
|
||||||
|
most_recent_event = await system.get_latest_event()
|
||||||
|
except SimplipyError as err:
|
||||||
|
_LOGGER.error("Error while fetching initial event: %s", err)
|
||||||
|
self.initial_event_to_use[system.system_id] = {}
|
||||||
|
else:
|
||||||
|
self.initial_event_to_use[system.system_id] = most_recent_event
|
||||||
|
|
||||||
async def refresh(event_time):
|
async def refresh(event_time):
|
||||||
"""Refresh data from the SimpliSafe account."""
|
"""Refresh data from the SimpliSafe account."""
|
||||||
await self.async_update()
|
await self.async_update()
|
||||||
@@ -444,17 +455,6 @@ class SimpliSafe:
|
|||||||
self._config_entry.entry_id
|
self._config_entry.entry_id
|
||||||
] = async_track_time_interval(self._hass, refresh, DEFAULT_SCAN_INTERVAL)
|
] = 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:
|
|
||||||
try:
|
|
||||||
most_recent_event = await system.get_latest_event()
|
|
||||||
except SimplipyError as err:
|
|
||||||
_LOGGER.error("Error while fetching initial event: %s", err)
|
|
||||||
self.initial_event_to_use[system.system_id] = {}
|
|
||||||
else:
|
|
||||||
self.initial_event_to_use[system.system_id] = most_recent_event
|
|
||||||
|
|
||||||
await self.async_update()
|
await self.async_update()
|
||||||
|
|
||||||
async def async_update(self):
|
async def async_update(self):
|
||||||
|
Reference in New Issue
Block a user