1 """Config flow to configure the HomematicIP Cloud component."""
3 from __future__
import annotations
7 import voluptuous
as vol
11 from .const
import _LOGGER, DOMAIN, HMIPC_AUTHTOKEN, HMIPC_HAPID, HMIPC_NAME, HMIPC_PIN
12 from .hap
import HomematicipAuth
16 """Config flow for the HomematicIP Cloud component."""
23 """Initialize HomematicIP Cloud config flow."""
26 self, user_input: dict[str, Any] |
None =
None
27 ) -> ConfigFlowResult:
28 """Handle a flow initialized by the user."""
29 return await self.async_step_init(user_input)
32 self, user_input: dict[str, str] |
None =
None
33 ) -> ConfigFlowResult:
34 """Handle a flow start."""
37 if user_input
is not None:
38 user_input[HMIPC_HAPID] = user_input[HMIPC_HAPID].replace(
"-",
"").upper()
46 _LOGGER.debug(
"Connection to HomematicIP Cloud established")
49 _LOGGER.debug(
"Connection to HomematicIP Cloud failed")
50 errors[
"base"] =
"invalid_sgtin_or_pin"
54 data_schema=vol.Schema(
56 vol.Required(HMIPC_HAPID): str,
57 vol.Optional(HMIPC_NAME): str,
58 vol.Optional(HMIPC_PIN): str,
65 """Attempt to link with the HomematicIP Cloud access point."""
68 pressed = await self.
authauth.async_checkbutton()
72 _LOGGER.debug(
"Write config entry for HomematicIP Cloud")
74 title=self.
authauth.config[HMIPC_HAPID],
76 HMIPC_HAPID: self.
authauth.config[HMIPC_HAPID],
77 HMIPC_AUTHTOKEN: authtoken,
78 HMIPC_NAME: self.
authauth.config.get(HMIPC_NAME),
82 errors[
"base"] =
"press_the_button"
87 """Import a new access point as a config entry."""
88 hapid = import_data[HMIPC_HAPID].replace(
"-",
"").upper()
89 authtoken = import_data[HMIPC_AUTHTOKEN]
90 name = import_data[HMIPC_NAME]
95 _LOGGER.debug(
"Imported authentication for %s", hapid)
98 data={HMIPC_AUTHTOKEN: authtoken, HMIPC_HAPID: hapid, HMIPC_NAME: name},
ConfigFlowResult async_step_user(self, dict[str, Any]|None user_input=None)
ConfigFlowResult async_step_init(self, dict[str, str]|None user_input=None)
ConfigFlowResult async_step_import(self, dict[str, str] import_data)
ConfigFlowResult async_step_link(self, 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)
None async_register(HomeAssistant hass, system_health.SystemHealthRegistration register)
bool async_setup(HomeAssistant hass, ConfigType config)