1 """The Weheat integration."""
3 from __future__
import annotations
5 from weheat.abstractions.discovery
import HeatPumpDiscovery
6 from weheat.exceptions
import UnauthorizedException
14 async_get_config_entry_implementation,
17 from .const
import API_URL, LOGGER
18 from .coordinator
import WeheatDataUpdateCoordinator
20 PLATFORMS: list[Platform] = [Platform.SENSOR]
22 type WeheatConfigEntry = ConfigEntry[list[WeheatDataUpdateCoordinator]]
26 """Set up Weheat from a config entry."""
31 token = session.token[CONF_ACCESS_TOKEN]
32 entry.runtime_data = []
36 discovered_heat_pumps = await HeatPumpDiscovery.discover_active(API_URL, token)
37 except UnauthorizedException
as error:
38 raise ConfigEntryAuthFailed
from error
40 for pump_info
in discovered_heat_pumps:
41 LOGGER.debug(
"Adding %s", pump_info)
45 await new_coordinator.async_config_entry_first_refresh()
47 entry.runtime_data.append(new_coordinator)
49 await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
55 """Unload a config entry."""
56 return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
bool async_unload_entry(HomeAssistant hass, WeheatConfigEntry entry)
bool async_setup_entry(HomeAssistant hass, WeheatConfigEntry entry)
AbstractOAuth2Implementation async_get_config_entry_implementation(HomeAssistant hass, config_entries.ConfigEntry config_entry)