1 """SFR Box config flow."""
3 from __future__
import annotations
5 from collections.abc
import Mapping
6 from typing
import TYPE_CHECKING, Any
8 from sfrbox_api.bridge
import SFRBox
9 from sfrbox_api.exceptions
import SFRBoxAuthenticationError, SFRBoxError
10 import voluptuous
as vol
17 from .const
import DEFAULT_HOST, DEFAULT_USERNAME, DOMAIN
19 DATA_SCHEMA = vol.Schema(
21 vol.Required(CONF_HOST, default=DEFAULT_HOST): selector.TextSelector(),
24 AUTH_SCHEMA = vol.Schema(
26 vol.Required(CONF_USERNAME, default=DEFAULT_USERNAME): selector.TextSelector(),
27 vol.Required(CONF_PASSWORD): selector.TextSelector(
28 selector.TextSelectorConfig(type=selector.TextSelectorType.PASSWORD)
35 """SFR Box config flow."""
39 _config: dict[str, Any] = {}
42 self, user_input: dict[str, str] |
None =
None
43 ) -> ConfigFlowResult:
44 """Handle a flow initialized by the user."""
46 if user_input
is not None:
49 system_info = await box.system_get_info()
51 errors[
"base"] =
"cannot_connect"
54 assert system_info
is not None
59 self._config.
update(user_input)
64 step_id=
"user", data_schema=data_schema, errors=errors
68 self, user_input: dict[str, str] |
None =
None
69 ) -> ConfigFlowResult:
70 """Handle a flow initialized by the user."""
72 step_id=
"choose_auth",
73 menu_options=[
"auth",
"skip_auth"],
77 self, user_input: dict[str, str] |
None =
None
78 ) -> ConfigFlowResult:
79 """Check authentication."""
81 if user_input
is not None:
84 username=user_input[CONF_USERNAME],
85 password=user_input[CONF_PASSWORD],
87 except SFRBoxAuthenticationError:
88 errors[
"base"] =
"invalid_auth"
94 self._config.
update(user_input)
97 suggested_values: Mapping[str, Any] |
None = user_input
103 step_id=
"auth", data_schema=data_schema, errors=errors
107 self, user_input: dict[str, str] |
None =
None
108 ) -> ConfigFlowResult:
109 """Skip authentication."""
113 self, entry_data: Mapping[str, Any]
114 ) -> ConfigFlowResult:
115 """Handle failed credentials."""
ConfigFlowResult async_step_user(self, dict[str, str]|None user_input=None)
ConfigFlowResult async_step_choose_auth(self, dict[str, str]|None user_input=None)
ConfigFlowResult async_step_skip_auth(self, dict[str, str]|None user_input=None)
ConfigFlowResult async_step_reauth(self, Mapping[str, Any] entry_data)
ConfigFlowResult async_step_auth(self, dict[str, str]|None user_input=None)
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 _async_abort_entries_match(self, dict[str, Any]|None match_dict=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)
vol.Schema add_suggested_values_to_schema(self, vol.Schema data_schema, Mapping[str, Any]|None suggested_values)
_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_show_menu(self, *str|None step_id=None, Container[str] menu_options, Mapping[str, str]|None description_placeholders=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)
IssData update(pyiss.ISS iss)
dict[str, str|bool] authenticate(HomeAssistant hass, str host, str security_code)
httpx.AsyncClient get_async_client(HomeAssistant hass, bool verify_ssl=True)