1 """Config flow for Fully Kiosk Browser integration."""
3 from __future__
import annotations
9 from aiohttp.client_exceptions
import ClientConnectorError
10 from fullykiosk
import FullyKiosk
11 from fullykiosk.exceptions
import FullyKioskError
12 import voluptuous
as vol
27 from .const
import DEFAULT_PORT, DOMAIN, LOGGER
31 """Handle a config flow for Fully Kiosk Browser."""
38 """Initialize the config flow."""
44 user_input: dict[str, Any],
45 errors: dict[str, str],
46 description_placeholders: dict[str, str] | Any =
None,
47 ) -> ConfigFlowResult |
None:
52 user_input[CONF_PASSWORD],
53 use_ssl=user_input[CONF_SSL],
54 verify_ssl=user_input[CONF_VERIFY_SSL],
58 async
with asyncio.timeout(15):
59 device_info = await fully.getDeviceInfo()
65 LOGGER.debug(error.args, exc_info=
True)
66 errors[
"base"] =
"cannot_connect"
67 description_placeholders[
"error_detail"] =
str(error.args)
69 except Exception
as error:
70 LOGGER.exception(
"Unexpected exception: %s", error)
71 errors[
"base"] =
"unknown"
72 description_placeholders[
"error_detail"] =
str(error.args)
75 await self.
async_set_unique_idasync_set_unique_id(device_info[
"deviceID"], raise_on_progress=
False)
78 title=device_info[
"deviceName"],
81 CONF_PASSWORD: user_input[CONF_PASSWORD],
83 CONF_SSL: user_input[CONF_SSL],
84 CONF_VERIFY_SSL: user_input[CONF_VERIFY_SSL],
89 self, user_input: dict[str, Any] |
None =
None
90 ) -> ConfigFlowResult:
91 """Handle the initial step."""
92 errors: dict[str, str] = {}
93 placeholders: dict[str, str] = {}
94 if user_input
is not None:
96 user_input[CONF_HOST], user_input, errors, placeholders
103 data_schema=vol.Schema(
105 vol.Required(CONF_HOST): str,
106 vol.Required(CONF_PASSWORD): str,
107 vol.Optional(CONF_SSL, default=
False): bool,
108 vol.Optional(CONF_VERIFY_SSL, default=
False): bool,
111 description_placeholders=placeholders,
116 self, discovery_info: DhcpServiceInfo
117 ) -> ConfigFlowResult:
118 """Handle dhcp discovery."""
122 if entry.data[CONF_MAC] == mac:
123 self.hass.config_entries.async_update_entry(
125 data=entry.data | {CONF_HOST: discovery_info.ip},
127 self.hass.async_create_task(
128 self.hass.config_entries.async_reload(entry.entry_id)
135 self, user_input: dict[str, Any] |
None =
None
136 ) -> ConfigFlowResult:
137 """Confirm discovery."""
138 errors: dict[str, str] = {}
139 if user_input
is not None:
140 result = await self.
_create_entry_create_entry(self.
hosthost, user_input, errors)
146 CONF_HOST: self.
hosthost,
148 self.context[
"title_placeholders"] = placeholders
150 step_id=
"discovery_confirm",
151 data_schema=vol.Schema(
153 vol.Required(CONF_PASSWORD): str,
154 vol.Optional(CONF_SSL, default=
False): bool,
155 vol.Optional(CONF_VERIFY_SSL, default=
False): bool,
158 description_placeholders=placeholders,
163 self, discovery_info: MqttServiceInfo
164 ) -> ConfigFlowResult:
165 """Handle a flow initialized by MQTT discovery."""
166 device_info: dict[str, Any] = json.loads(discovery_info.payload)
167 device_id: str = device_info[
"deviceId"]
171 self.
hosthost = device_info[
"hostname4"]
ConfigFlowResult async_step_user(self, dict[str, Any]|None user_input=None)
ConfigFlowResult|None _create_entry(self, str host, dict[str, Any] user_input, dict[str, str] errors, dict[str, str]|Any description_placeholders=None)
ConfigFlowResult async_step_mqtt(self, MqttServiceInfo discovery_info)
ConfigFlowResult async_step_discovery_confirm(self, dict[str, Any]|None user_input=None)
ConfigFlowResult async_step_dhcp(self, DhcpServiceInfo discovery_info)
None _abort_if_unique_id_configured(self, dict[str, Any]|None updates=None, bool reload_on_update=True, *str error="already_configured")
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)
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)
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)