1 """Config flow to configure the devolo home control integration."""
3 from __future__
import annotations
5 from collections.abc
import Mapping
8 import voluptuous
as vol
20 from .
import configure_mydevolo
21 from .const
import CONF_MYDEVOLO, DEFAULT_MYDEVOLO, DOMAIN, SUPPORTED_MODEL_TYPES
22 from .exceptions
import CredentialsInvalid, UuidChanged
26 """Handle a devolo HomeControl config flow."""
30 _reauth_entry: ConfigEntry
33 """Initialize devolo Home Control flow."""
35 vol.Required(CONF_USERNAME): str,
36 vol.Required(CONF_PASSWORD): str,
38 self.
_url_url = DEFAULT_MYDEVOLO
41 self, user_input: dict[str, Any] |
None =
None
42 ) -> ConfigFlowResult:
43 """Handle a flow initiated by the user."""
45 self.
data_schemadata_schema[vol.Required(CONF_MYDEVOLO, default=self.
_url_url)] = str
46 if user_input
is None:
47 return self.
_show_form_show_form(step_id=
"user")
50 except CredentialsInvalid:
51 return self.
_show_form_show_form(step_id=
"user", errors={
"base":
"invalid_auth"})
54 self, discovery_info: zeroconf.ZeroconfServiceInfo
55 ) -> ConfigFlowResult:
56 """Handle zeroconf discovery."""
58 if discovery_info.properties.get(
"MT")
in SUPPORTED_MODEL_TYPES:
64 self, user_input: dict[str, Any] |
None =
None
65 ) -> ConfigFlowResult:
66 """Handle a flow initiated by zeroconf."""
67 if user_input
is None:
68 return self.
_show_form_show_form(step_id=
"zeroconf_confirm")
71 except CredentialsInvalid:
73 step_id=
"zeroconf_confirm", errors={
"base":
"invalid_auth"}
77 self, entry_data: Mapping[str, Any]
78 ) -> ConfigFlowResult:
79 """Handle reauthentication."""
81 self.
_url_url = entry_data[CONF_MYDEVOLO]
83 vol.Required(CONF_USERNAME, default=entry_data[CONF_USERNAME]): str,
84 vol.Required(CONF_PASSWORD): str,
89 self, user_input: dict[str, Any] |
None =
None
90 ) -> ConfigFlowResult:
91 """Handle a flow initiated by reauthentication."""
92 if user_input
is None:
93 return self.
_show_form_show_form(step_id=
"reauth_confirm")
96 except CredentialsInvalid:
98 step_id=
"reauth_confirm", errors={
"base":
"invalid_auth"}
102 step_id=
"reauth_confirm", errors={
"base":
"reauth_failed"}
106 """Connect to mydevolo."""
107 user_input[CONF_MYDEVOLO] = user_input.get(CONF_MYDEVOLO, self.
_url_url)
109 credentials_valid = await self.hass.async_add_executor_job(
110 mydevolo.credentials_valid
112 if not credentials_valid:
113 raise CredentialsInvalid
114 uuid = await self.hass.async_add_executor_job(mydevolo.uuid)
120 title=
"devolo Home Control",
122 CONF_PASSWORD: mydevolo.password,
123 CONF_USERNAME: mydevolo.user,
124 CONF_MYDEVOLO: mydevolo.url,
133 self.
_reauth_entry_reauth_entry, data=user_input, unique_id=uuid
138 self, step_id: str, errors: dict[str, str] |
None =
None
139 ) -> ConfigFlowResult:
140 """Show the form to the user."""
143 data_schema=vol.Schema(self.
data_schemadata_schema),
144 errors=errors
if errors
else {},
ConfigFlowResult async_step_reauth(self, Mapping[str, Any] entry_data)
ConfigFlowResult async_step_reauth_confirm(self, dict[str, Any]|None user_input=None)
ConfigFlowResult _connect_mydevolo(self, dict[str, Any] user_input)
ConfigFlowResult async_step_user(self, dict[str, Any]|None user_input=None)
ConfigFlowResult async_step_zeroconf_confirm(self, dict[str, Any]|None user_input=None)
ConfigFlowResult _show_form(self, str step_id, dict[str, str]|None errors=None)
ConfigFlowResult async_step_zeroconf(self, zeroconf.ZeroconfServiceInfo discovery_info)
None _abort_if_unique_id_configured(self, dict[str, Any]|None updates=None, bool reload_on_update=True, *str error="already_configured")
None _async_handle_discovery_without_unique_id(self)
ConfigEntry _get_reauth_entry(self)
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_update_reload_and_abort(self, ConfigEntry entry, *str|None|UndefinedType unique_id=UNDEFINED, str|UndefinedType title=UNDEFINED, Mapping[str, Any]|UndefinedType data=UNDEFINED, Mapping[str, Any]|UndefinedType data_updates=UNDEFINED, Mapping[str, Any]|UndefinedType options=UNDEFINED, str|UndefinedType reason=UNDEFINED, bool reload_even_if_entry_is_unchanged=True)
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)
bool show_advanced_options(self)
_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)
Mydevolo configure_mydevolo(dict[str, Any]|MappingProxyType[str, Any] conf)