1 """Config flow for air-Q integration."""
3 from __future__
import annotations
8 from aioairq
import AirQ, InvalidAuth
9 from aiohttp.client_exceptions
import ClientConnectionError
10 import voluptuous
as vol
18 SchemaOptionsFlowHandler,
22 from .const
import CONF_CLIP_NEGATIVE, CONF_RETURN_AVERAGE, DOMAIN
24 _LOGGER = logging.getLogger(__name__)
26 STEP_USER_DATA_SCHEMA = vol.Schema(
28 vol.Required(CONF_IP_ADDRESS): str,
29 vol.Required(CONF_PASSWORD): str,
45 """Handle a config flow for air-Q."""
50 self, user_input: dict[str, Any] |
None =
None
51 ) -> ConfigFlowResult:
52 """Handle the initial (authentication) configuration step."""
53 if user_input
is None:
55 step_id=
"user", data_schema=STEP_USER_DATA_SCHEMA
58 errors: dict[str, str] = {}
61 airq = AirQ(user_input[CONF_IP_ADDRESS], user_input[CONF_PASSWORD], session)
64 except ClientConnectionError:
67 "Failed to connect to device %s. Check the IP address / device"
68 " ID as well as whether the device is connected to power and"
71 user_input[CONF_IP_ADDRESS],
73 errors[
"base"] =
"cannot_connect"
76 "Incorrect password for device %s", user_input[CONF_IP_ADDRESS]
78 errors[
"base"] =
"invalid_auth"
80 _LOGGER.debug(
"Successfully connected to %s", user_input[CONF_IP_ADDRESS])
82 device_info = await airq.fetch_device_info()
89 step_id=
"user", data_schema=STEP_USER_DATA_SCHEMA, errors=errors
95 config_entry: ConfigEntry,
96 ) -> SchemaOptionsFlowHandler:
97 """Return the options flow."""
SchemaOptionsFlowHandler async_get_options_flow(ConfigEntry config_entry)
ConfigFlowResult async_step_user(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_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)