1 """Config flow to configure Dynalite hub."""
3 from __future__
import annotations
7 import voluptuous
as vol
13 from .bridge
import DynaliteBridge
14 from .const
import DEFAULT_PORT, DOMAIN, LOGGER
15 from .convert_config
import convert_config
19 """Handle a Dynalite config flow."""
24 """Initialize the Dynalite flow."""
28 self, user_input: dict[str, Any] |
None =
None
29 ) -> ConfigFlowResult:
30 """Step when user initializes a integration."""
31 if user_input
is not None:
32 return await self.
_try_create_try_create(user_input)
36 vol.Required(CONF_HOST): cv.string,
37 vol.Required(CONF_PORT, default=DEFAULT_PORT): int,
42 async
def _try_create(self, info: dict[str, Any]) -> ConfigFlowResult:
43 """Try to connect and if successful, create entry."""
44 host = info[CONF_HOST]
48 if host
in configured_hosts:
51 if not await bridge.async_setup():
52 LOGGER.error(
"Unable to setup bridge - import info=%s", info)
54 LOGGER.debug(
"Creating entry for the bridge - %s", info)
ConfigFlowResult async_step_user(self, dict[str, Any]|None user_input=None)
ConfigFlowResult _try_create(self, dict[str, Any] info)
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)
list[ConfigEntry] _async_current_entries(self, bool|None include_ignore=None)
ConfigFlowResult async_abort(self, *str reason, 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)
_FlowResultT async_abort(self, *str reason, Mapping[str, str]|None description_placeholders=None)
dict[str, Any] convert_config(dict[str, Any]|MappingProxyType[str, Any] config)