1 """Config flow for Bring! integration."""
3 from __future__
import annotations
5 from collections.abc
import Mapping
9 from bring_api
import (
13 BringRequestException,
15 import voluptuous
as vol
26 from .
import BringConfigEntry
27 from .const
import DOMAIN
29 _LOGGER = logging.getLogger(__name__)
31 STEP_USER_DATA_SCHEMA = vol.Schema(
35 type=TextSelectorType.EMAIL,
41 type=TextSelectorType.PASSWORD,
42 autocomplete=
"current-password",
50 """Handle a config flow for Bring!."""
53 reauth_entry: BringConfigEntry
54 info: BringAuthResponse
57 self, user_input: dict[str, Any] |
None =
None
58 ) -> ConfigFlowResult:
59 """Handle the initial step."""
60 errors: dict[str, str] = {}
61 if user_input
is not None and not (
66 title=self.
infoinfo.
get(
"name")
or user_input[CONF_EMAIL], data=user_input
70 step_id=
"user", data_schema=STEP_USER_DATA_SCHEMA, errors=errors
74 self, entry_data: Mapping[str, Any]
75 ) -> ConfigFlowResult:
76 """Perform reauth upon an API authentication error."""
81 self, user_input: dict[str, Any] |
None =
None
82 ) -> ConfigFlowResult:
83 """Dialog that informs the user that reauth is required."""
84 errors: dict[str, str] = {}
86 if user_input
is not None:
87 if not (errors := await self.
validate_inputvalidate_input(user_input)):
93 step_id=
"reauth_confirm",
95 data_schema=STEP_USER_DATA_SCHEMA,
96 suggested_values={CONF_EMAIL: self.
reauth_entryreauth_entry.data[CONF_EMAIL]},
98 description_placeholders={CONF_NAME: self.
reauth_entryreauth_entry.title},
105 errors: dict[str, str] = {}
107 bring = Bring(session, user_input[CONF_EMAIL], user_input[CONF_PASSWORD])
110 self.
infoinfo = await bring.login()
111 except BringRequestException:
112 errors[
"base"] =
"cannot_connect"
113 except BringAuthException:
114 errors[
"base"] =
"invalid_auth"
116 _LOGGER.exception(
"Unexpected exception")
117 errors[
"base"] =
"unknown"
ConfigFlowResult async_step_reauth(self, Mapping[str, Any] entry_data)
ConfigFlowResult async_step_reauth_confirm(self, dict[str, Any]|None user_input=None)
ConfigFlowResult async_step_user(self, dict[str, Any]|None user_input=None)
dict[str, str] validate_input(self, Mapping[str, Any] user_input)
None _abort_if_unique_id_configured(self, dict[str, Any]|None updates=None, bool reload_on_update=True, *str error="already_configured")
ConfigEntry _get_reauth_entry(self)
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_update_reload_and_abort(self, ConfigEntry entry, *str|None|UndefinedType unique_id=UNDEFINED, str|UndefinedType title=UNDEFINED, Mapping[str, Any]|UndefinedType data=UNDEFINED, Mapping[str, Any]|UndefinedType data_updates=UNDEFINED, Mapping[str, Any]|UndefinedType options=UNDEFINED, str|UndefinedType reason=UNDEFINED, bool reload_even_if_entry_is_unchanged=True)
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)
web.Response get(self, web.Request request, str config_key)
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)