1 """Config flow for Aseko Pool Live integration."""
3 from __future__
import annotations
5 from collections.abc
import Mapping
9 from aioaseko
import Aseko, AsekoAPIError, AsekoInvalidCredentials
10 import voluptuous
as vol
15 from .const
import DOMAIN
17 _LOGGER = logging.getLogger(__name__)
21 """Handle a config flow for Aseko Pool Live."""
25 data_schema = vol.Schema(
27 vol.Required(CONF_EMAIL): str,
28 vol.Required(CONF_PASSWORD): str,
33 """Get account info from the mobile API and the web API."""
34 aseko = Aseko(email, password)
35 user = await aseko.login()
38 CONF_PASSWORD: password,
39 CONF_UNIQUE_ID: user.user_id,
43 self, user_input: Mapping[str, Any] |
None =
None
44 ) -> ConfigFlowResult:
45 """Handle the initial step."""
49 if user_input
is not None:
52 user_input[CONF_EMAIL], user_input[CONF_PASSWORD]
55 errors[
"base"] =
"cannot_connect"
56 except AsekoInvalidCredentials:
57 errors[
"base"] =
"invalid_auth"
59 _LOGGER.exception(
"Unexpected exception")
60 errors[
"base"] =
"unknown"
71 """Store validated credentials."""
78 title=info[CONF_EMAIL],
80 CONF_EMAIL: info[CONF_EMAIL],
81 CONF_PASSWORD: info[CONF_PASSWORD],
88 title=info[CONF_EMAIL],
90 CONF_EMAIL: info[CONF_EMAIL],
91 CONF_PASSWORD: info[CONF_PASSWORD],
96 self, entry_data: Mapping[str, Any]
97 ) -> ConfigFlowResult:
98 """Perform reauth upon an API authentication error."""
102 self, user_input: dict[str, Any] |
None =
None
103 ) -> ConfigFlowResult:
104 """Dialog that informs the user that reauth is required."""
107 if user_input
is not None:
110 user_input[CONF_EMAIL], user_input[CONF_PASSWORD]
112 except AsekoAPIError:
113 errors[
"base"] =
"cannot_connect"
114 except AsekoInvalidCredentials:
115 errors[
"base"] =
"invalid_auth"
117 _LOGGER.exception(
"Unexpected exception")
118 errors[
"base"] =
"unknown"
123 step_id=
"reauth_confirm",
ConfigFlowResult async_step_reauth(self, Mapping[str, Any] entry_data)
ConfigFlowResult async_step_user(self, Mapping[str, Any]|None user_input=None)
dict[str, Any] get_account_info(self, str email, str password)
ConfigFlowResult async_step_reauth_confirm(self, dict[str, Any]|None user_input=None)
ConfigFlowResult async_store_credentials(self, dict[str, Any] info)
None _abort_if_unique_id_configured(self, dict[str, Any]|None updates=None, bool reload_on_update=True, *str error="already_configured")
ConfigEntry _get_reauth_entry(self)
ConfigEntry|None async_set_unique_id(self, str|None unique_id=None, *bool raise_on_progress=True)
ConfigFlowResult async_create_entry(self, *str title, Mapping[str, Any] data, str|None description=None, Mapping[str, str]|None description_placeholders=None, Mapping[str, Any]|None options=None)
ConfigFlowResult async_update_reload_and_abort(self, ConfigEntry entry, *str|None|UndefinedType unique_id=UNDEFINED, str|UndefinedType title=UNDEFINED, Mapping[str, Any]|UndefinedType data=UNDEFINED, Mapping[str, Any]|UndefinedType data_updates=UNDEFINED, Mapping[str, Any]|UndefinedType options=UNDEFINED, str|UndefinedType reason=UNDEFINED, bool reload_even_if_entry_is_unchanged=True)
None _abort_if_unique_id_mismatch(self, *str reason="unique_id_mismatch", Mapping[str, str]|None description_placeholders=None)
ConfigFlowResult async_show_form(self, *str|None step_id=None, vol.Schema|None data_schema=None, dict[str, str]|None errors=None, Mapping[str, str]|None description_placeholders=None, bool|None last_step=None, str|None preview=None)
_FlowResultT async_show_form(self, *str|None step_id=None, vol.Schema|None data_schema=None, dict[str, str]|None errors=None, Mapping[str, str]|None description_placeholders=None, bool|None last_step=None, str|None preview=None)
_FlowResultT async_create_entry(self, *str|None title=None, Mapping[str, Any] data, str|None description=None, Mapping[str, str]|None description_placeholders=None)