1 """Config flow for Netgear LTE integration."""
3 from __future__
import annotations
7 from aiohttp.cookiejar
import CookieJar
8 from eternalegypt
import Error, Modem
9 from eternalegypt.eternalegypt
import Information
10 import voluptuous
as vol
17 from .const
import DEFAULT_HOST, DOMAIN, LOGGER, MANUFACTURER
21 """Handle a config flow for Netgear LTE."""
24 self, user_input: dict[str, Any] |
None =
None
25 ) -> ConfigFlowResult:
26 """Handle a flow initiated by the user."""
30 host = user_input[CONF_HOST]
31 password = user_input[CONF_PASSWORD]
34 info = await self._async_validate_input(host, password)
35 except InputValidationError
as ex:
36 errors[
"base"] = ex.base
41 title=f
"{MANUFACTURER} {info.items['general.devicename']}",
42 data={CONF_HOST: host, CONF_PASSWORD: password},
50 vol.Required(CONF_HOST): str,
51 vol.Required(CONF_PASSWORD): str,
54 user_input
or {CONF_HOST: DEFAULT_HOST},
59 async
def _async_validate_input(self, host: str, password: str) -> Information:
60 """Validate login credentials."""
62 self.hass, cookie_jar=CookieJar(unsafe=
True)
68 websession=websession,
72 info = await modem.information()
75 except Exception
as ex:
76 LOGGER.exception(
"Unexpected exception")
83 """Error to indicate we cannot proceed due to invalid input."""
86 """Initialize with error base."""
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)
vol.Schema add_suggested_values_to_schema(self, vol.Schema data_schema, Mapping[str, Any]|None suggested_values)
_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_create_clientsession()