1 """Heartbeats for Broadlink devices."""
6 import broadlink
as blk
12 from .const
import DOMAIN
14 _LOGGER = logging.getLogger(__name__)
18 """Manages heartbeats in the Broadlink integration.
20 Some devices reboot when they cannot reach the cloud. This mechanism
21 feeds their watchdog timers so they can be used offline.
24 HEARTBEAT_INTERVAL = dt.timedelta(minutes=2)
26 def __init__(self, hass: HomeAssistant) ->
None:
27 """Initialize the heartbeat."""
29 self.
_unsubscribe_unsubscribe: CALLBACK_TYPE |
None =
None
32 """Set up the heartbeat."""
40 """Unload the heartbeat."""
46 """Send packets to feed watchdog timers."""
47 hass = self.
_hass_hass
48 config_entries = hass.config_entries.async_entries(DOMAIN)
49 hosts: set[str] = {entry.data[CONF_HOST]
for entry
in config_entries}
50 await hass.async_add_executor_job(self.
heartbeatheartbeat, hosts)
54 """Send packets to feed watchdog timers."""
58 except OSError
as err:
59 _LOGGER.debug(
"Failed to send heartbeat to %s: %s", host, err)
61 _LOGGER.debug(
"Heartbeat sent to %s", host)
None __init__(self, HomeAssistant hass)
None async_heartbeat(self, dt.datetime _)
None heartbeat(set[str] hosts)