1 """Define a custom coordinator for the Weheat heatpump integration."""
3 from datetime
import timedelta
5 from weheat.abstractions.discovery
import HeatPumpDiscovery
6 from weheat.abstractions.heat_pump
import HeatPump
7 from weheat.exceptions
import (
13 UnauthorizedException,
22 from .const
import API_URL, DOMAIN, LOGGER, UPDATE_INTERVAL
34 """A custom coordinator for the Weheat heatpump integration."""
39 session: OAuth2Session,
40 heat_pump: HeatPumpDiscovery.HeatPumpInfo,
42 """Initialize the data coordinator."""
47 update_interval=
timedelta(seconds=UPDATE_INTERVAL),
56 """Return the heat pump id."""
61 """Return the readable name of the heat pump."""
68 """Return the model of the heat pump."""
72 """Get the data from the API."""
75 except UnauthorizedException
as error:
76 raise ConfigEntryAuthFailed
from error
77 except EXCEPTIONS
as error:
83 """Fetch data from the API."""
84 await self.
sessionsession.async_ensure_token_valid()
86 return await self.
hasshass.async_add_executor_job(self.
fetch_datafetch_data)
None __init__(self, HomeAssistant hass, OAuth2Session session, HeatPumpDiscovery.HeatPumpInfo heat_pump)
str|None readable_name(self)
HeatPump fetch_data(self)
HeatPump _async_update_data(self)
def get_status(hass, host, port)