From 89d90bfb1b118457b047dd64bf4498546ef4bfe0 Mon Sep 17 00:00:00 2001 From: Felipe Martins Diel <41558831+felipediel@users.noreply.github.com> Date: Fri, 4 Jun 2021 18:03:13 -0300 Subject: [PATCH] Use a single job to ping all devices in the Broadlink integration (#51466) --- homeassistant/components/broadlink/heartbeat.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/broadlink/heartbeat.py b/homeassistant/components/broadlink/heartbeat.py index 282df3ae6a8..b4deffa5b81 100644 --- a/homeassistant/components/broadlink/heartbeat.py +++ b/homeassistant/components/broadlink/heartbeat.py @@ -44,11 +44,15 @@ class BroadlinkHeartbeat: """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: