Home Assistant Unofficial Reference 2024.12.1
coordinator.py
Go to the documentation of this file.
1 """Zeversolar coordinator."""
2 
3 from __future__ import annotations
4 
5 from datetime import timedelta
6 import logging
7 
8 import zeversolar
9 
10 from homeassistant.config_entries import ConfigEntry
11 from homeassistant.const import CONF_HOST
12 from homeassistant.core import HomeAssistant
13 from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
14 
15 from .const import DOMAIN
16 
17 _LOGGER = logging.getLogger(__name__)
18 
19 
20 class ZeversolarCoordinator(DataUpdateCoordinator[zeversolar.ZeverSolarData]):
21  """Data update coordinator."""
22 
23  def __init__(self, hass: HomeAssistant, entry: ConfigEntry) -> None:
24  """Initialize the coordinator."""
25  super().__init__(
26  hass,
27  _LOGGER,
28  name=DOMAIN,
29  update_interval=timedelta(minutes=1),
30  )
31  self._client_client = zeversolar.ZeverSolarClient(host=entry.data[CONF_HOST])
32 
33  async def _async_update_data(self) -> zeversolar.ZeverSolarData:
34  """Fetch the latest data from the source."""
35  return await self.hasshass.async_add_executor_job(self._client_client.get_data)
None __init__(self, HomeAssistant hass, ConfigEntry entry)
Definition: coordinator.py:23