1 """Config flow for Airzone Cloud."""
3 from __future__
import annotations
7 from aioairzone_cloud.cloudapi
import AirzoneCloudApi
8 from aioairzone_cloud.common
import ConnectionOptions
9 from aioairzone_cloud.const
import AZD_ID, AZD_NAME, AZD_WEBSERVERS
10 from aioairzone_cloud.exceptions
import AirzoneCloudError, LoginError
11 import voluptuous
as vol
23 from .const
import DOMAIN
27 """Handle config flow for an Airzone Cloud device."""
29 airzone: AirzoneCloudApi
32 self, user_input: dict[str, Any] |
None =
None
33 ) -> ConfigFlowResult:
34 """Handle the installation selection."""
36 options: dict[str, str] = {}
40 if user_input
is not None:
41 inst_id = user_input[CONF_ID]
44 inst_list = await self.
airzoneairzone.list_installations()
45 except AirzoneCloudError:
46 errors[
"base"] =
"cannot_connect"
48 for inst
in inst_list:
51 options[_id] = f
"{_data[AZD_NAME]} {_data[AZD_WEBSERVERS][0]} ({_id})"
52 if _id
is not None and _id == inst_id:
53 inst_desc = options[_id]
55 if user_input
is not None and inst_desc
is not None:
59 user_input[CONF_USERNAME] = self.
airzoneairzone.options.username
60 user_input[CONF_PASSWORD] = self.
airzoneairzone.options.password
66 data_schema=vol.Schema(
72 for k, v
in options.items()
74 mode=SelectSelectorMode.DROPDOWN,
83 self, user_input: dict[str, Any] |
None =
None
84 ) -> ConfigFlowResult:
85 """Handle the initial step."""
88 if user_input
is not None:
89 if CONF_ID
in user_input:
93 aiohttp_client.async_get_clientsession(self.hass),
95 user_input[CONF_USERNAME],
96 user_input[CONF_PASSWORD],
102 await self.
airzoneairzone.login()
103 except (AirzoneCloudError, LoginError):
104 errors[
"base"] =
"cannot_connect"
110 data_schema=vol.Schema(
112 vol.Required(CONF_USERNAME): str,
113 vol.Required(CONF_PASSWORD): str,
ConfigFlowResult async_step_inst_pick(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|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_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)