Skip to content

Commit

Permalink
Use a single job to ping all devices in the Broadlink integration (#5…
Browse files Browse the repository at this point in the history
  • Loading branch information
felipediel committed Jun 4, 2021
1 parent 7bf45f7 commit 89d90bf
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions homeassistant/components/broadlink/heartbeat.py
Expand Up @@ -44,11 +44,15 @@ async def async_heartbeat(self, now):
"""Send packets to feed watchdog timers."""
hass = self._hass
config_entries = hass.config_entries.async_entries(DOMAIN)
hosts = {entry.data[CONF_HOST] for entry in config_entries}
await hass.async_add_executor_job(self.heartbeat, hosts)

for entry in config_entries:
host = entry.data[CONF_HOST]
@staticmethod
def heartbeat(hosts):
"""Send packets to feed watchdog timers."""
for host in hosts:
try:
await hass.async_add_executor_job(blk.ping, host)
blk.ping(host)
except OSError as err:
_LOGGER.debug("Failed to send heartbeat to %s: %s", host, err)
else:
Expand Down

0 comments on commit 89d90bf

Please sign in to comment.