Home Assistant Unofficial Reference 2024.12.1
coordinator.py
Go to the documentation of this file.
1 """Coordinator for the Garages Amsterdam integration."""
2 
3 from __future__ import annotations
4 
5 from odp_amsterdam import Garage, ODPAmsterdam, VehicleType
6 
7 from homeassistant.core import HomeAssistant
8 from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
9 
10 from .const import DOMAIN, LOGGER, SCAN_INTERVAL
11 
12 
14  """Class to manage fetching Garages Amsterdam data from single endpoint."""
15 
16  def __init__(
17  self,
18  hass: HomeAssistant,
19  client: ODPAmsterdam,
20  ) -> None:
21  """Initialize global Garages Amsterdam data updater."""
22  super().__init__(
23  hass,
24  LOGGER,
25  name=DOMAIN,
26  update_interval=SCAN_INTERVAL,
27  )
28  self.clientclient = client
29 
30  async def _async_update_data(self) -> dict[str, Garage]:
31  return {
32  garage.garage_name: garage
33  for garage in await self.clientclient.all_garages(vehicle=VehicleType.CAR)
34  }