1 """Alpha2 config flow."""
7 from moehlenhoff_alpha2
import Alpha2Base
8 import voluptuous
as vol
13 from .const
import DOMAIN
15 _LOGGER = logging.getLogger(__name__)
17 DATA_SCHEMA = vol.Schema({vol.Required(CONF_HOST): str})
21 """Validate the user input allows us to connect.
23 Data has the keys from DATA_SCHEMA with values provided by the user.
26 base = Alpha2Base(data[CONF_HOST])
28 await base.update_data()
29 except (aiohttp.client_exceptions.ClientConnectorError, TimeoutError):
30 return {
"error":
"cannot_connect"}
32 _LOGGER.exception(
"Unexpected exception")
33 return {
"error":
"unknown"}
36 return {
"title": base.name}
40 """Möhlenhoff Alpha2 config flow."""
45 self, user_input: dict[str, Any] |
None =
None
46 ) -> ConfigFlowResult:
47 """Handle a flow initialized by the user."""
49 if user_input
is not None:
52 if result.get(
"error"):
53 errors[
"base"] = result[
"error"]
58 step_id=
"user", data_schema=DATA_SCHEMA, errors=errors
ConfigFlowResult async_step_user(self, dict[str, Any]|None user_input=None)
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)
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)
_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)
dict[str, str] validate_input(dict[str, Any] data)