1 """The Discovergy integration."""
3 from __future__
import annotations
5 from pydiscovergy
import Discovergy
6 from pydiscovergy.authentication
import BasicAuth
7 import pydiscovergy.error
as discovergyError
15 from .coordinator
import DiscovergyUpdateCoordinator
17 PLATFORMS = [Platform.SENSOR]
19 type DiscovergyConfigEntry = ConfigEntry[list[DiscovergyUpdateCoordinator]]
23 """Set up Discovergy from a config entry."""
25 email=entry.data[CONF_EMAIL],
26 password=entry.data[CONF_PASSWORD],
28 authentication=BasicAuth(),
34 meters = await client.meters()
35 except discovergyError.InvalidLogin
as err:
37 except Exception
as err:
39 "Unexpected error while while getting meters"
50 discovergy_client=client,
52 await coordinator.async_config_entry_first_refresh()
53 coordinators.append(coordinator)
55 entry.runtime_data = coordinators
56 await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
58 entry.async_on_unload(entry.add_update_listener(async_reload_entry))
64 """Unload a config entry."""
65 return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
69 """Handle an options update."""
70 await hass.config_entries.async_reload(entry.entry_id)
bool async_setup_entry(HomeAssistant hass, DiscovergyConfigEntry entry)
bool async_unload_entry(HomeAssistant hass, ConfigEntry entry)
None async_reload_entry(HomeAssistant hass, ConfigEntry entry)
httpx.AsyncClient get_async_client(HomeAssistant hass, bool verify_ssl=True)