1 """DataUpdateCoordinator for the uptimerobot integration."""
3 from __future__
import annotations
5 from pyuptimerobot
import (
7 UptimeRobotAuthenticationException,
18 from .const
import API_ATTR_OK, COORDINATOR_UPDATE_INTERVAL, DOMAIN, LOGGER
22 """Data update coordinator for UptimeRobot."""
24 config_entry: ConfigEntry
30 dev_reg: dr.DeviceRegistry,
33 """Initialize coordinator."""
38 update_interval=COORDINATOR_UPDATE_INTERVAL,
47 response = await self.
apiapi.async_get_monitors()
48 except UptimeRobotAuthenticationException
as exception:
50 except UptimeRobotException
as exception:
53 if response.status != API_ATTR_OK:
56 monitors: list[UptimeRobotMonitor] = response.data
59 list(device.identifiers)[0][1]
60 for device
in dr.async_entries_for_config_entry(
64 new_monitors = {
str(monitor.id)
for monitor
in monitors}
65 if stale_monitors := current_monitors - new_monitors:
66 for monitor_id
in stale_monitors:
68 identifiers={(DOMAIN, monitor_id)}
74 if self.
datadata
and new_monitors - {
str(monitor.id)
for monitor
in self.
datadata}:
75 self.
hasshass.async_create_task(
list[UptimeRobotMonitor] _async_update_data(self)
None __init__(self, HomeAssistant hass, str config_entry_id, dr.DeviceRegistry dev_reg, UptimeRobot api)