1 """The lookin integration config_flow."""
3 from __future__
import annotations
9 from aiolookin
import Device, LookInHttpProtocol, NoUsableService
10 import voluptuous
as vol
17 from .const
import DOMAIN
19 LOGGER = logging.getLogger(__name__)
23 """Handle a config flow for lookin."""
26 """Init the lookin flow."""
27 self.
_host_host: str |
None =
None
28 self.
_name_name: str |
None =
None
31 self, discovery_info: zeroconf.ZeroconfServiceInfo
32 ) -> ConfigFlowResult:
33 """Start a discovery flow from zeroconf."""
34 uid: str = discovery_info.hostname.removesuffix(
".local.")
35 host: str = discovery_info.host
41 except (aiohttp.ClientError, NoUsableService):
44 LOGGER.exception(
"Unexpected exception")
50 self.context[
"title_placeholders"] = {
51 "name": self.
_name_name
or "LOOKin",
57 self, user_input: dict[str, Any] |
None =
None
58 ) -> ConfigFlowResult:
59 """User initiated discover flow."""
60 errors: dict[str, str] = {}
62 if user_input
is not None:
63 host = user_input[CONF_HOST]
66 except (aiohttp.ClientError, NoUsableService):
67 errors[CONF_HOST] =
"cannot_connect"
69 LOGGER.exception(
"Unexpected exception")
70 errors[
"base"] =
"unknown"
72 device_id = device.id.upper()
76 title=device.name
or host,
77 data={CONF_HOST: host},
82 data_schema=vol.Schema({vol.Required(CONF_HOST): str}),
87 """Validate we can connect to the device."""
89 lookin_protocol = LookInHttpProtocol(f
"http://{host}", session)
90 return await lookin_protocol.get_info()
93 self, user_input: dict[str, Any] |
None =
None
94 ) -> ConfigFlowResult:
95 """Confirm the discover flow."""
96 assert self.
_host_host
is not None
97 if user_input
is None:
99 step_id=
"discovery_confirm",
100 description_placeholders={
101 "name": self.
_name_name
or "LOOKin",
102 "host": self.
_host_host,
108 data={CONF_HOST: self.
_host_host},
ConfigFlowResult async_step_zeroconf(self, zeroconf.ZeroconfServiceInfo discovery_info)
Device _validate_device(self, str host)
ConfigFlowResult async_step_discovery_confirm(self, dict[str, Any]|None user_input=None)
ConfigFlowResult async_step_user(self, dict[str, Any]|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")
None _set_confirm_only(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_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)
aiohttp.ClientSession async_get_clientsession(HomeAssistant hass, bool verify_ssl=True, socket.AddressFamily family=socket.AF_UNSPEC, ssl_util.SSLCipherList ssl_cipher=ssl_util.SSLCipherList.PYTHON_DEFAULT)