mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Use a single job to ping all devices in the Broadlink integration (#51466)
This commit is contained in:
parent
7bf45f7bf7
commit
89d90bfb1b
@ -44,11 +44,15 @@ class BroadlinkHeartbeat:
|
|||||||
"""Send packets to feed watchdog timers."""
|
"""Send packets to feed watchdog timers."""
|
||||||
hass = self._hass
|
hass = self._hass
|
||||||
config_entries = hass.config_entries.async_entries(DOMAIN)
|
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:
|
@staticmethod
|
||||||
host = entry.data[CONF_HOST]
|
def heartbeat(hosts):
|
||||||
|
"""Send packets to feed watchdog timers."""
|
||||||
|
for host in hosts:
|
||||||
try:
|
try:
|
||||||
await hass.async_add_executor_job(blk.ping, host)
|
blk.ping(host)
|
||||||
except OSError as err:
|
except OSError as err:
|
||||||
_LOGGER.debug("Failed to send heartbeat to %s: %s", host, err)
|
_LOGGER.debug("Failed to send heartbeat to %s: %s", host, err)
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user