1 """Coordinator for the Switcher integration."""
3 from __future__
import annotations
5 from datetime
import timedelta
8 from aioswitcher.device
import SwitcherBase
16 from .const
import DOMAIN, MAX_UPDATE_INTERVAL_SEC, SIGNAL_DEVICE_ADD
18 _LOGGER = logging.getLogger(__name__)
22 update_coordinator.DataUpdateCoordinator[SwitcherBase]
24 """Switcher device data update coordinator."""
26 config_entry: ConfigEntry
34 """Initialize the Switcher device coordinator."""
40 update_interval=
timedelta(seconds=MAX_UPDATE_INTERVAL_SEC),
43 self.
tokentoken = entry.data.get(CONF_TOKEN)
46 """Mark device offline if no data."""
47 raise update_coordinator.UpdateFailed(
48 f
"Device {self.name} did not send update for"
49 f
" {MAX_UPDATE_INTERVAL_SEC} seconds"
54 """Switcher device model."""
55 return self.
datadata.device_type.value
59 """Switcher device id."""
60 return self.
datadata.device_id
64 """Switcher device mac address."""
65 return self.
datadata.mac_address
69 """Set up the coordinator."""
70 dev_reg = dr.async_get(self.hass)
71 dev_reg.async_get_or_create(
72 config_entry_id=self.config_entry.entry_id,
73 connections={(dr.CONNECTION_NETWORK_MAC, self.
mac_addressmac_address)},
74 identifiers={(DOMAIN, self.
device_iddevice_id)},
75 manufacturer=
"Switcher",
77 model=self.
modelmodel,
None __init__(self, HomeAssistant hass, ConfigEntry entry, SwitcherBase device)
SwitcherBase _async_update_data(self)
None async_dispatcher_send(HomeAssistant hass, str signal, *Any args)