1 """Config flow for Wallbox integration."""
3 from __future__
import annotations
5 from collections.abc
import Mapping
8 import voluptuous
as vol
9 from wallbox
import Wallbox
15 from .const
import CONF_STATION, DOMAIN
16 from .coordinator
import InvalidAuth, async_validate_input
18 COMPONENT_DOMAIN = DOMAIN
20 STEP_USER_DATA_SCHEMA = vol.Schema(
22 vol.Required(CONF_STATION): str,
23 vol.Required(CONF_USERNAME): str,
24 vol.Required(CONF_PASSWORD): str,
29 async
def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> dict[str, str]:
30 """Validate the user input allows to connect.
32 Data has the keys from STEP_USER_DATA_SCHEMA with values provided by the user.
34 wallbox = Wallbox(data[
"username"], data[
"password"])
39 return {
"title":
"Wallbox Portal"}
43 """Handle a config flow for Wallbox."""
46 self, entry_data: Mapping[str, Any]
47 ) -> ConfigFlowResult:
48 """Perform reauth upon an API authentication error."""
52 self, user_input: dict[str, Any] |
None =
None
53 ) -> ConfigFlowResult:
54 """Handle the initial step."""
55 if user_input
is None:
58 data_schema=STEP_USER_DATA_SCHEMA,
70 if user_input[
"station"] == reauth_entry.data[CONF_STATION]:
72 errors[
"base"] =
"reauth_invalid"
73 except ConnectionError:
74 errors[
"base"] =
"cannot_connect"
76 errors[
"base"] =
"invalid_auth"
80 data_schema=STEP_USER_DATA_SCHEMA,
ConfigFlowResult async_step_reauth(self, Mapping[str, Any] entry_data)
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_step_user(self, dict[str, Any]|None user_input=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)
tuple[dict[str, str], str] async_validate_input(HomeAssistant hass, dict[str, Any] user_input)
dict[str, str] validate_input(HomeAssistant hass, dict[str, Any] data)