1 """Config flow for ROMY integration."""
3 from __future__
import annotations
6 import voluptuous
as vol
13 from .const
import DOMAIN, LOGGER
17 """Handle config flow for ROMY."""
22 """Handle a config flow for ROMY."""
23 self.
hosthost: str =
""
28 self, user_input: dict[str, str] |
None =
None
29 ) -> ConfigFlowResult:
30 """Handle the user step."""
31 errors: dict[str, str] = {}
34 self.
hosthost = user_input[CONF_HOST]
36 new_romy = await romy.create_romy(self.
hosthost,
"")
38 if not new_romy.is_initialized:
39 errors[CONF_HOST] =
"cannot_connect"
46 if not new_romy.is_unlocked:
52 data_schema=vol.Schema(
54 vol.Required(CONF_HOST): cv.string,
61 self, user_input: dict[str, str] |
None =
None
62 ) -> ConfigFlowResult:
63 """Unlock the robots local http interface with password."""
64 errors: dict[str, str] = {}
67 self.
passwordpassword = user_input[CONF_PASSWORD]
68 new_romy = await romy.create_romy(self.
hosthost, self.
passwordpassword)
70 if not new_romy.is_initialized:
71 errors[CONF_PASSWORD] =
"cannot_connect"
72 elif not new_romy.is_unlocked:
73 errors[CONF_PASSWORD] =
"invalid_auth"
80 data_schema=vol.Schema(
81 {vol.Required(CONF_PASSWORD): vol.All(cv.string, vol.Length(8))},
87 self, discovery_info: zeroconf.ZeroconfServiceInfo
88 ) -> ConfigFlowResult:
89 """Handle zeroconf discovery."""
91 LOGGER.debug(
"Zeroconf discovery_info: %s", discovery_info)
94 self.
hosthost = discovery_info.host
95 LOGGER.debug(
"ZeroConf Host: %s", self.
hosthost)
97 new_discovered_romy = await romy.create_romy(self.
hosthost,
"")
103 unique_id = new_discovered_romy.unique_id
104 LOGGER.debug(
"ZeroConf Unique_id: %s", unique_id)
110 "title_placeholders": {
111 "name": f
"{self.robot_name_given_by_user} ({self.host} / {unique_id})"
113 "configuration_url": f
"http://{self.host}:{new_discovered_romy.port}",
118 if not new_discovered_romy.is_initialized:
121 if new_discovered_romy.is_unlocked:
127 self, user_input: dict[str, str] |
None =
None
128 ) -> ConfigFlowResult:
129 """Handle a confirmation flow initiated by zeroconf."""
130 if user_input
is None:
132 step_id=
"zeroconf_confirm",
133 description_placeholders={
135 "host": self.
hosthost,
141 """Finish the configuration setup."""
145 CONF_HOST: self.
hosthost,
146 CONF_PASSWORD: self.
passwordpassword,
ConfigFlowResult async_step_user(self, dict[str, str]|None user_input=None)
ConfigFlowResult async_step_password(self, dict[str, str]|None user_input=None)
ConfigFlowResult async_step_zeroconf(self, zeroconf.ZeroconfServiceInfo discovery_info)
ConfigFlowResult _async_step_finish_config(self)
ConfigFlowResult async_step_zeroconf_confirm(self, dict[str, str]|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")
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)
IssData update(pyiss.ISS iss)