1 """Config flow for Velux integration."""
3 from pyvlx
import PyVLX, PyVLXException
4 import voluptuous
as vol
10 from .const
import DOMAIN, LOGGER
12 DATA_SCHEMA = vol.Schema(
14 vol.Required(CONF_HOST): cv.string,
15 vol.Required(CONF_PASSWORD): cv.string,
21 """Handle a config flow for velux."""
24 self, user_input: dict[str, str] |
None =
None
25 ) -> ConfigFlowResult:
26 """Handle the initial step."""
27 errors: dict[str, str] = {}
29 if user_input
is not None:
33 host=user_input[CONF_HOST], password=user_input[CONF_PASSWORD]
37 await pyvlx.disconnect()
38 except (PyVLXException, ConnectionError)
as err:
39 errors[
"base"] =
"cannot_connect"
40 LOGGER.debug(
"Cannot connect: %s", err)
41 except Exception
as err:
42 LOGGER.exception(
"Unexpected exception: %s", err)
43 errors[
"base"] =
"unknown"
46 title=user_input[CONF_HOST],
53 data_schema=data_schema,
ConfigFlowResult async_step_user(self, dict[str, str]|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)
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_create_entry(self, *str|None title=None, Mapping[str, Any] data, str|None description=None, Mapping[str, str]|None description_placeholders=None)