1 """The ista Ecotrend integration."""
3 from __future__
import annotations
7 from pyecotrend_ista
import KeycloakError, LoginError, PyEcotrendIsta, ServerError
14 from .const
import DOMAIN
15 from .coordinator
import IstaCoordinator
17 _LOGGER = logging.getLogger(__name__)
19 PLATFORMS: list[Platform] = [Platform.SENSOR]
21 type IstaConfigEntry = ConfigEntry[IstaCoordinator]
25 """Set up ista EcoTrend from a config entry."""
26 ista = PyEcotrendIsta(
27 entry.data[CONF_EMAIL],
28 entry.data[CONF_PASSWORD],
32 await hass.async_add_executor_job(ista.login)
33 except ServerError
as e:
35 translation_domain=DOMAIN,
36 translation_key=
"connection_exception",
38 except (LoginError, KeycloakError)
as e:
40 translation_domain=DOMAIN,
41 translation_key=
"authentication_exception",
42 translation_placeholders={CONF_EMAIL: entry.data[CONF_EMAIL]},
46 await coordinator.async_config_entry_first_refresh()
48 entry.runtime_data = coordinator
50 await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
56 """Unload a config entry."""
57 return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
bool async_setup_entry(HomeAssistant hass, IstaConfigEntry entry)
bool async_unload_entry(HomeAssistant hass, IstaConfigEntry entry)