1 """Config flow to configure the Ambient PWS component."""
3 from __future__
import annotations
7 from aioambient
import API
8 from aioambient.errors
import AmbientError
9 import voluptuous
as vol
15 from .const
import CONF_APP_KEY, DOMAIN
19 """Handle an Ambient PWS config flow."""
24 """Initialize the config flow."""
26 {vol.Required(CONF_API_KEY): str, vol.Required(CONF_APP_KEY): str}
29 async
def _show_form(self, errors: dict |
None =
None) -> ConfigFlowResult:
30 """Show the form to the user."""
34 errors=errors
if errors
else {},
38 self, user_input: dict[str, Any] |
None =
None
39 ) -> ConfigFlowResult:
40 """Handle the start of the config flow."""
47 session = aiohttp_client.async_get_clientsession(self.hass)
48 api =
API(user_input[CONF_APP_KEY], user_input[CONF_API_KEY], session=session)
51 devices = await api.get_devices()
53 return await self.
_show_form_show_form({
"base":
"invalid_key"})
56 return await self.
_show_form_show_form({
"base":
"no_devices"})
62 title=user_input[CONF_APP_KEY][:12], data=user_input
ConfigFlowResult async_step_user(self, dict[str, Any]|None user_input=None)
ConfigFlowResult _show_form(self, dict|None errors=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_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)