1 """Config flow for AirTouch4."""
5 from airtouch4pyapi
import AirTouch, AirTouchStatus
6 import voluptuous
as vol
11 from .const
import DOMAIN
13 DATA_SCHEMA = vol.Schema({vol.Required(CONF_HOST): str})
17 """Handle an Airtouch config flow."""
22 self, user_input: dict[str, Any] |
None =
None
23 ) -> ConfigFlowResult:
24 """Handle a flow initialized by the user."""
25 if user_input
is None:
30 host = user_input[CONF_HOST]
33 airtouch = AirTouch(host)
34 await airtouch.UpdateInfo()
35 airtouch_status = airtouch.Status
36 airtouch_has_groups = bool(
37 airtouch.Status == AirTouchStatus.OK
and airtouch.GetGroups()
40 if airtouch_status != AirTouchStatus.OK:
41 errors[
"base"] =
"cannot_connect"
42 elif not airtouch_has_groups:
43 errors[
"base"] =
"no_units"
47 step_id=
"user", data_schema=DATA_SCHEMA, errors=errors
51 title=user_input[CONF_HOST],
53 CONF_HOST: user_input[CONF_HOST],
ConfigFlowResult async_step_user(self, dict[str, Any]|None user_input=None)
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)
None _async_abort_entries_match(self, dict[str, Any]|None match_dict=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)