1 """Config flow for duotecno integration."""
3 from __future__
import annotations
8 from duotecno.controller
import PyDuotecno
9 from duotecno.exceptions
import InvalidPassword
10 import voluptuous
as vol
15 from .const
import DOMAIN
17 _LOGGER = logging.getLogger(__name__)
19 STEP_USER_DATA_SCHEMA = vol.Schema(
21 vol.Required(CONF_HOST): str,
22 vol.Required(CONF_PASSWORD): str,
23 vol.Required(CONF_PORT): int,
29 """Handle a config flow for duotecno."""
34 self, user_input: dict[str, Any] |
None =
None
35 ) -> ConfigFlowResult:
36 """Handle the initial step."""
37 errors: dict[str, str] = {}
38 if user_input
is not None:
40 controller = PyDuotecno()
41 await controller.connect(
42 user_input[CONF_HOST],
43 user_input[CONF_PORT],
44 user_input[CONF_PASSWORD],
47 except ConnectionError:
48 errors[
"base"] =
"cannot_connect"
49 except InvalidPassword:
50 errors[
"base"] =
"invalid_auth"
52 _LOGGER.exception(
"Unexpected exception")
53 errors[
"base"] =
"unknown"
56 title=f
"{user_input[CONF_HOST]}", data=user_input
60 step_id=
"user", data_schema=STEP_USER_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)
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)