1 """Config flow for Tedee integration."""
3 from collections.abc
import Mapping
11 TedeeDataUpdateException,
12 TedeeLocalAuthException,
14 import voluptuous
as vol
26 from .const
import CONF_LOCAL_ACCESS_TOKEN, DOMAIN, NAME
28 _LOGGER = logging.getLogger(__name__)
32 """Handle a config flow for Tedee."""
38 self, user_input: dict[str, Any] |
None =
None
39 ) -> ConfigFlowResult:
40 """Handle the initial step."""
41 errors: dict[str, str] = {}
43 if user_input
is not None:
47 host = user_input[CONF_HOST]
48 local_access_token = user_input[CONF_LOCAL_ACCESS_TOKEN]
49 tedee_client = TedeeClient(
50 local_token=local_access_token,
55 local_bridge = await tedee_client.get_local_bridge()
56 except (TedeeAuthException, TedeeLocalAuthException):
57 errors[CONF_LOCAL_ACCESS_TOKEN] =
"invalid_api_key"
58 except TedeeClientException:
59 errors[CONF_HOST] =
"invalid_host"
60 except TedeeDataUpdateException
as exc:
61 _LOGGER.error(
"Error during local bridge discovery: %s", exc)
62 errors[
"base"] =
"cannot_connect"
78 data={**user_input, CONF_WEBHOOK_ID: webhook_generate_id()},
83 data_schema=vol.Schema(
89 CONF_LOCAL_ACCESS_TOKEN,
97 self, entry_data: Mapping[str, Any]
98 ) -> ConfigFlowResult:
99 """Perform reauth upon an API authentication error."""
103 self, user_input: dict[str, Any] |
None =
None
104 ) -> ConfigFlowResult:
105 """Dialog that informs the user that reauth is required."""
108 step_id=
"reauth_confirm",
109 data_schema=vol.Schema(
112 CONF_LOCAL_ACCESS_TOKEN,
114 CONF_LOCAL_ACCESS_TOKEN
123 self, user_input: dict[str, Any] |
None =
None
124 ) -> ConfigFlowResult:
125 """Perform a reconfiguration."""
129 step_id=
"reconfigure",
130 data_schema=vol.Schema(
133 CONF_HOST, default=reconfigure_entry.data[CONF_HOST]
136 CONF_LOCAL_ACCESS_TOKEN,
137 default=reconfigure_entry.data[CONF_LOCAL_ACCESS_TOKEN],
ConfigFlowResult async_step_user(self, dict[str, Any]|None user_input=None)
ConfigFlowResult async_step_reauth_confirm(self, dict[str, Any]|None user_input=None)
ConfigFlowResult async_step_reconfigure(self, dict[str, Any]|None user_input=None)
ConfigFlowResult async_step_reauth(self, Mapping[str, Any] entry_data)
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)
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)
ConfigEntry _get_reconfigure_entry(self)
None _abort_if_unique_id_mismatch(self, *str reason="unique_id_mismatch", 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)
aiohttp.ClientSession async_get_clientsession(HomeAssistant hass, bool verify_ssl=True, socket.AddressFamily family=socket.AF_UNSPEC, ssl_util.SSLCipherList ssl_cipher=ssl_util.SSLCipherList.PYTHON_DEFAULT)