1 """Config flow for ViCare integration."""
3 from __future__
import annotations
5 from collections.abc
import Mapping
9 from PyViCare.PyViCareUtils
import (
10 PyViCareInvalidConfigurationError,
11 PyViCareInvalidCredentialsError,
13 import voluptuous
as vol
21 from .
import vicare_login
30 _LOGGER = logging.getLogger(__name__)
32 REAUTH_SCHEMA = vol.Schema(
34 vol.Required(CONF_PASSWORD): cv.string,
35 vol.Required(CONF_CLIENT_ID): cv.string,
39 USER_SCHEMA = REAUTH_SCHEMA.extend(
41 vol.Required(CONF_USERNAME): cv.string,
42 vol.Required(CONF_HEATING_TYPE, default=DEFAULT_HEATING_TYPE.value): vol.In(
43 [e.value
for e
in HeatingType]
50 """Handle a config flow for ViCare."""
55 self, user_input: dict[str, Any] |
None =
None
56 ) -> ConfigFlowResult:
57 """Invoke when a user initiates a flow via the user interface."""
61 errors: dict[str, str] = {}
63 if user_input
is not None:
65 await self.hass.async_add_executor_job(
66 vicare_login, self.hass, user_input
68 except (PyViCareInvalidConfigurationError, PyViCareInvalidCredentialsError):
69 errors[
"base"] =
"invalid_auth"
75 data_schema=USER_SCHEMA,
80 self, entry_data: Mapping[str, Any]
81 ) -> ConfigFlowResult:
82 """Handle re-authentication with ViCare."""
86 self, user_input: dict[str, Any] |
None =
None
87 ) -> ConfigFlowResult:
88 """Confirm re-authentication with ViCare."""
89 errors: dict[str, str] = {}
99 await self.hass.async_add_executor_job(vicare_login, self.hass, data)
100 except (PyViCareInvalidConfigurationError, PyViCareInvalidCredentialsError):
101 errors[
"base"] =
"invalid_auth"
106 step_id=
"reauth_confirm",
108 REAUTH_SCHEMA, reauth_entry.data
114 self, discovery_info: dhcp.DhcpServiceInfo
115 ) -> ConfigFlowResult:
116 """Invoke when a Viessmann MAC address is discovered on the network."""
117 formatted_mac =
format_mac(discovery_info.macaddress)
118 _LOGGER.debug(
"Found device with mac %s", formatted_mac)
ConfigFlowResult async_step_reauth(self, Mapping[str, Any] entry_data)
ConfigFlowResult async_step_user(self, dict[str, Any]|None user_input=None)
ConfigFlowResult async_step_dhcp(self, dhcp.DhcpServiceInfo discovery_info)
ConfigFlowResult async_step_reauth_confirm(self, dict[str, Any]|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 _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)
list[ConfigEntry] _async_current_entries(self, bool|None include_ignore=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_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)
vol.Schema add_suggested_values_to_schema(self, vol.Schema data_schema, Mapping[str, Any]|None suggested_values)
_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)