1 """Config flow for Litter-Robot integration."""
3 from __future__
import annotations
5 from collections.abc
import Mapping
9 from pylitterbot
import Account
10 from pylitterbot.exceptions
import LitterRobotException, LitterRobotLoginException
11 import voluptuous
as vol
17 from .const
import DOMAIN
19 _LOGGER = logging.getLogger(__name__)
21 STEP_USER_DATA_SCHEMA = vol.Schema(
22 {vol.Required(CONF_USERNAME): str, vol.Required(CONF_PASSWORD): str}
27 """Handle a config flow for Litter-Robot."""
34 self, entry_data: Mapping[str, Any]
35 ) -> ConfigFlowResult:
36 """Handle a reauthorization flow request."""
37 self.
usernameusername = entry_data[CONF_USERNAME]
41 self, user_input: dict[str, str] |
None =
None
42 ) -> ConfigFlowResult:
43 """Handle user's reauth credentials."""
46 user_input = user_input | {CONF_USERNAME: self.
usernameusername}
52 errors[
"base"] = error
54 step_id=
"reauth_confirm",
55 data_schema=vol.Schema({vol.Required(CONF_PASSWORD): str}),
56 description_placeholders={CONF_USERNAME: self.
usernameusername},
61 self, user_input: Mapping[str, Any] |
None =
None
62 ) -> ConfigFlowResult:
63 """Handle the initial step."""
66 if user_input
is not None:
71 title=user_input[CONF_USERNAME], data=user_input
73 errors[
"base"] = error
76 step_id=
"user", data_schema=STEP_USER_DATA_SCHEMA, errors=errors
80 """Validate login credentials."""
83 await account.connect(
84 username=user_input[CONF_USERNAME],
85 password=user_input[CONF_PASSWORD],
87 await account.disconnect()
88 except LitterRobotLoginException:
90 except LitterRobotException:
91 return "cannot_connect"
93 _LOGGER.exception(
"Unexpected exception")
ConfigFlowResult async_step_user(self, Mapping[str, Any]|None user_input=None)
ConfigFlowResult async_step_reauth_confirm(self, dict[str, str]|None user_input=None)
str _async_validate_input(self, Mapping[str, Any] user_input)
ConfigFlowResult async_step_reauth(self, Mapping[str, Any] entry_data)
ConfigEntry _get_reauth_entry(self)
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)
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)
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)