mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 09:47:13 +00:00
Speed up status updating in SimpliSafe (#22506)
* Speed up status updating in SimpliSafe * Linting * Member comments
This commit is contained in:
parent
424543f34a
commit
f4625fd561
@ -1,4 +1,5 @@
|
|||||||
"""Support for SimpliSafe alarm systems."""
|
"""Support for SimpliSafe alarm systems."""
|
||||||
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
@ -107,17 +108,18 @@ async def async_setup_entry(hass, config_entry):
|
|||||||
|
|
||||||
async def refresh(event_time):
|
async def refresh(event_time):
|
||||||
"""Refresh data from the SimpliSafe account."""
|
"""Refresh data from the SimpliSafe account."""
|
||||||
for system in systems:
|
tasks = [system.update() for system in systems]
|
||||||
_LOGGER.debug('Updating system data: %s', system.system_id)
|
results = await asyncio.gather(*tasks, return_exceptions=True)
|
||||||
|
for system, result in zip(systems, results):
|
||||||
try:
|
if isinstance(result, SimplipyError):
|
||||||
await system.update()
|
|
||||||
except SimplipyError as err:
|
|
||||||
_LOGGER.error(
|
_LOGGER.error(
|
||||||
'There was error updating "%s": %s', system.address, err)
|
'There was error updating "%s": %s', system.address,
|
||||||
|
result)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
async_dispatcher_send(hass, TOPIC_UPDATE.format(system.system_id))
|
_LOGGER.debug('Updated status of "%s"', system.address)
|
||||||
|
async_dispatcher_send(
|
||||||
|
hass, TOPIC_UPDATE.format(system.system_id))
|
||||||
|
|
||||||
if system.api.refresh_token_dirty:
|
if system.api.refresh_token_dirty:
|
||||||
_async_save_refresh_token(
|
_async_save_refresh_token(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user