1 """Config flow to configure the SmartTub integration."""
3 from __future__
import annotations
5 from collections.abc
import Mapping
8 from smarttub
import LoginFailed
9 import voluptuous
as vol
14 from .const
import DOMAIN
15 from .controller
import SmartTubController
17 DATA_SCHEMA = vol.Schema(
18 {vol.Required(CONF_EMAIL): str, vol.Required(CONF_PASSWORD): str}
23 """SmartTub configuration flow."""
28 self, user_input: dict[str, Any] |
None =
None
29 ) -> ConfigFlowResult:
30 """Handle a flow initiated by the user."""
33 if user_input
is not None:
36 account = await controller.login(
37 user_input[CONF_EMAIL], user_input[CONF_PASSWORD]
41 errors[
"base"] =
"invalid_auth"
48 title=user_input[CONF_EMAIL], data=user_input
58 step_id=
"user", data_schema=DATA_SCHEMA, errors=errors
62 self, entry_data: Mapping[str, Any]
63 ) -> ConfigFlowResult:
64 """Get new credentials if the current ones don't work anymore."""
68 self, user_input: dict[str, str] |
None =
None
69 ) -> ConfigFlowResult:
70 """Dialog that informs the user that reauth is required."""
71 if user_input
is None:
73 data_schema = vol.Schema(
79 vol.Required(CONF_PASSWORD): str,
83 step_id=
"reauth_confirm",
84 data_schema=data_schema,
ConfigFlowResult async_step_reauth_confirm(self, dict[str, str]|None user_input=None)
ConfigFlowResult async_step_user(self, dict[str, Any]|None user_input=None)
ConfigFlowResult async_step_reauth(self, Mapping[str, Any] entry_data)
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)
ConfigFlowResult async_step_user(self, dict[str, Any]|None user_input=None)
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)