Home Assistant Unofficial Reference 2024.12.1
coordinator.py
Go to the documentation of this file.
1 """DataUpdateCoordinator for coolmaster integration."""
2 
3 import logging
4 
5 from homeassistant.components.climate import SCAN_INTERVAL
6 from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
7 
8 from .const import DOMAIN
9 
10 _LOGGER = logging.getLogger(__name__)
11 
12 
14  """Class to manage fetching Coolmaster data."""
15 
16  def __init__(self, hass, coolmaster):
17  """Initialize global Coolmaster data updater."""
18  self._coolmaster_coolmaster = coolmaster
19 
20  super().__init__(
21  hass,
22  _LOGGER,
23  name=DOMAIN,
24  update_interval=SCAN_INTERVAL,
25  )
26 
27  async def _async_update_data(self):
28  """Fetch data from Coolmaster."""
29  try:
30  return await self._coolmaster_coolmaster.status()
31  except OSError as error:
32  raise UpdateFailed from error