Home Assistant Unofficial Reference 2024.12.1
coordinator.py
Go to the documentation of this file.
1 """Data update coordinator for the Skybell integration."""
2 
3 from datetime import timedelta
4 
5 from aioskybell import SkybellDevice, SkybellException
6 
7 from homeassistant.config_entries import ConfigEntry
8 from homeassistant.core import HomeAssistant
9 from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
10 
11 from .const import LOGGER
12 
13 
15  """Data update coordinator for the Skybell integration."""
16 
17  config_entry: ConfigEntry
18 
19  def __init__(self, hass: HomeAssistant, device: SkybellDevice) -> None:
20  """Initialize the coordinator."""
21  super().__init__(
22  hass=hass,
23  logger=LOGGER,
24  name=device.name,
25  update_interval=timedelta(seconds=30),
26  )
27  self.devicedevice = device
28 
29  async def _async_update_data(self) -> None:
30  """Fetch data from API endpoint."""
31  try:
32  await self.devicedevice.async_update()
33  except SkybellException as err:
34  raise UpdateFailed(f"Failed to communicate with device: {err}") from err
None __init__(self, HomeAssistant hass, SkybellDevice device)
Definition: coordinator.py:19