Home Assistant Unofficial Reference 2024.12.1
coordinator.py
Go to the documentation of this file.
1 """DataUpdateCoordinator for the renson integration."""
2 
3 from __future__ import annotations
4 
5 import asyncio
6 from datetime import timedelta
7 import logging
8 from typing import Any
9 
10 from renson_endura_delta.renson import RensonVentilation
11 
12 from homeassistant.core import HomeAssistant
13 from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
14 
15 _LOGGER = logging.getLogger(__name__)
16 
17 
19  """Data update coordinator for Renson."""
20 
21  def __init__(
22  self,
23  name: str,
24  hass: HomeAssistant,
25  api: RensonVentilation,
26  update_interval=timedelta(seconds=30),
27  ) -> None:
28  """Initialize my coordinator."""
29  super().__init__(
30  hass,
31  _LOGGER,
32  # Name of the data. For logging purposes.
33  name=name,
34  # Polling interval. Will only be polled if there are subscribers.
35  update_interval=update_interval,
36  )
37  self.apiapi = api
38 
39  async def _async_update_data(self) -> dict[str, Any]:
40  """Fetch data from API endpoint."""
41  async with asyncio.timeout(30):
42  return await self.hasshass.async_add_executor_job(self.apiapi.get_all_data)
None __init__(self, str name, HomeAssistant hass, RensonVentilation api, update_interval=timedelta(seconds=30))
Definition: coordinator.py:27