1 """Config flow to configure the Arcam FMJ component."""
3 from __future__
import annotations
6 from urllib.parse
import urlparse
8 from arcam.fmj.client
import Client, ConnectionFailed
9 from arcam.fmj.utils
import get_uniqueid_from_host, get_uniqueid_from_udn
10 import voluptuous
as vol
17 from .const
import DEFAULT_NAME, DEFAULT_PORT, DOMAIN
21 """Handle config flow."""
29 self, host: str, port: int, uuid: str
35 client = Client(host, port)
38 except ConnectionFailed:
44 title=f
"{DEFAULT_NAME} ({host})",
45 data={CONF_HOST: host, CONF_PORT: port},
49 self, user_input: dict[str, Any] |
None =
None
50 ) -> ConfigFlowResult:
51 """Handle a discovered device."""
52 errors: dict[str, str] = {}
54 if user_input
is not None:
55 uuid = await get_uniqueid_from_host(
60 user_input[CONF_HOST], user_input[CONF_PORT], uuid
64 user_input[CONF_HOST], user_input[CONF_PORT]
68 vol.Required(CONF_HOST): str,
69 vol.Required(CONF_PORT, default=DEFAULT_PORT): int,
73 step_id=
"user", data_schema=vol.Schema(fields), errors=errors
77 self, user_input: dict[str, Any] |
None =
None
78 ) -> ConfigFlowResult:
79 """Handle user-confirmation of discovered node."""
80 placeholders = {
"host": self.
hosthost}
81 self.context[
"title_placeholders"] = placeholders
83 if user_input
is not None:
87 step_id=
"confirm", description_placeholders=placeholders
91 self, discovery_info: ssdp.SsdpServiceInfo
92 ) -> ConfigFlowResult:
93 """Handle a discovered device."""
94 host =
str(urlparse(discovery_info.ssdp_location).hostname)
96 uuid = get_uniqueid_from_udn(discovery_info.upnp[ssdp.ATTR_UPNP_UDN])
ConfigFlowResult async_step_ssdp(self, ssdp.SsdpServiceInfo discovery_info)
ConfigFlowResult _async_check_and_create(self, str host, int port)
ConfigFlowResult async_step_user(self, dict[str, Any]|None user_input=None)
ConfigFlowResult async_step_confirm(self, dict[str, Any]|None user_input=None)
None _async_set_unique_id_and_update(self, str host, int port, str uuid)
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)
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)