Home Assistant Unofficial Reference 2024.12.1
coordinator.py
Go to the documentation of this file.
1 """Coordinator for Plaato devices."""
2 
3 from datetime import timedelta
4 import logging
5 
6 from pyplaato.plaato import Plaato, PlaatoDeviceType
7 
8 from homeassistant.const import Platform
9 from homeassistant.core import HomeAssistant
10 from homeassistant.helpers import aiohttp_client
11 from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
12 
13 from .const import DOMAIN
14 
15 _LOGGER = logging.getLogger(__name__)
16 
17 
19  """Class to manage fetching data from the API."""
20 
21  def __init__(
22  self,
23  hass: HomeAssistant,
24  auth_token: str,
25  device_type: PlaatoDeviceType,
26  update_interval: timedelta,
27  ) -> None:
28  """Initialize."""
29  self.apiapi = Plaato(auth_token=auth_token)
30  self.hasshasshass = hass
31  self.device_typedevice_type = device_type
32  self.platforms: list[Platform] = []
33 
34  super().__init__(
35  hass,
36  _LOGGER,
37  name=DOMAIN,
38  update_interval=update_interval,
39  )
40 
41  async def _async_update_data(self):
42  """Update data via library."""
43  return await self.apiapi.get_data(
44  session=aiohttp_client.async_get_clientsession(self.hasshasshass),
45  device_type=self.device_typedevice_type,
46  )
None __init__(self, HomeAssistant hass, str auth_token, PlaatoDeviceType device_type, timedelta update_interval)
Definition: coordinator.py:27