1 """Config flow for sky_remote."""
6 from skyboxremote
import RemoteControl, SkyBoxConnectionError
7 import voluptuous
as vol
13 from .const
import DEFAULT_PORT, DOMAIN, LEGACY_PORT
15 DATA_SCHEMA = vol.Schema(
17 vol.Required(CONF_HOST): cv.string,
23 """Find port box uses for communication."""
24 logging.debug(
"Attempting to find port to connect to %s on", host)
25 remote = RemoteControl(host, DEFAULT_PORT)
27 await remote.check_connectable()
28 except SkyBoxConnectionError:
30 remote = RemoteControl(host, LEGACY_PORT)
31 await remote.check_connectable()
37 """Handle a config flow for Sky Remote."""
43 self, user_input: dict[str, Any] |
None =
None
44 ) -> ConfigFlowResult:
45 """Handle the user step."""
47 errors: dict[str, str] = {}
48 if user_input
is not None:
49 logging.debug(
"user_input: %s", user_input)
53 except SkyBoxConnectionError:
54 logging.exception(
"while finding port of skybox")
55 errors[
"base"] =
"cannot_connect"
58 title=user_input[CONF_HOST],
59 data={**user_input, CONF_PORT: port},
63 step_id=
"user", data_schema=DATA_SCHEMA, errors=errors
ConfigFlowResult async_step_user(self, dict[str, Any]|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)
_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)
int async_find_box_port(str host)