Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speed up status updating in SimpliSafe #22506

Merged
merged 3 commits into from
Mar 29, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions homeassistant/components/simplisafe/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Support for SimpliSafe alarm systems."""
import asyncio
import logging
from datetime import timedelta

Expand Down Expand Up @@ -107,17 +108,18 @@ async def async_setup_entry(hass, config_entry):

async def refresh(event_time):
"""Refresh data from the SimpliSafe account."""
for system in systems:
_LOGGER.debug('Updating system data: %s', system.system_id)

try:
await system.update()
except SimplipyError as err:
tasks = [system.update() for system in systems]
results = await asyncio.gather(*tasks, return_exceptions=True)
for system, result in zip(systems, results):
if isinstance(result, SimplipyError):
_LOGGER.error(
'There was error updating "%s": %s', system.address, err)
'There was error updating "%s": %s', system.address,
result)
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:
_async_save_refresh_token(
Expand Down