1 """Config flow to configure ZWaveMe integration."""
3 from __future__
import annotations
7 from url_normalize
import url_normalize
8 import voluptuous
as vol
15 from .const
import DOMAIN
17 _LOGGER = logging.getLogger(__name__)
21 """ZWaveMe integration config flow."""
24 """Initialize flow."""
25 self.
urlurl: str |
None =
None
26 self.
tokentoken: str |
None =
None
27 self.
uuiduuid: str |
None =
None
30 self, user_input: dict[str, str] |
None =
None
31 ) -> ConfigFlowResult:
32 """Handle a flow initialized by the user or started with zeroconf."""
35 "local_token":
"/112f7a4a-0051-cc2b-3b61-1898181b9950",
37 "0481effe8a5c6f757b455babb678dc0e764feae279/112f7a4a-0051"
38 "-cc2b-3b61-1898181b9950"
40 "local_url":
"ws://192.168.1.39:8083",
41 "add_on_url":
"ws://127.0.0.1:8083",
42 "find_url":
"wss://find.z-wave.me",
43 "remote_url":
"wss://87.250.250.242:8083",
45 if self.
urlurl
is None:
48 vol.Required(CONF_URL): str,
49 vol.Required(CONF_TOKEN): str,
55 vol.Required(CONF_TOKEN): str,
59 if user_input
is not None:
60 if self.
urlurl
is None:
61 self.
urlurl = user_input[CONF_URL]
63 self.
tokentoken = user_input[CONF_TOKEN]
64 if not self.
urlurl.startswith((
"ws://",
"wss://")):
65 self.
urlurl = f
"ws://{self.url}"
66 self.
urlurl = url_normalize(self.
urlurl, default_scheme=
"ws")
68 if self.
uuiduuid
is None:
69 self.
uuiduuid = await helpers.get_uuid(self.
urlurl, self.
tokentoken)
70 if self.
uuiduuid
is not None:
74 errors[
"base"] =
"no_valid_uuid_set"
79 data={CONF_URL: self.
urlurl, CONF_TOKEN: self.
tokentoken},
84 description_placeholders=placeholders,
90 self, discovery_info: ZeroconfServiceInfo
91 ) -> ConfigFlowResult:
92 """Handle a discovered Z-Wave accessory - get url to pass into user step.
94 This flow is triggered by the discovery component.
96 self.
urlurl = discovery_info.host
97 self.
uuiduuid = await helpers.get_uuid(self.
urlurl)
98 if self.
uuiduuid
is None:
ConfigFlowResult async_step_zeroconf(self, ZeroconfServiceInfo discovery_info)
ConfigFlowResult async_step_user(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_step_user(self, dict[str, Any]|None user_input=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)