1 """Config flow for Lektrico Charging Station."""
3 from __future__
import annotations
7 from lektricowifi
import Device, DeviceConnectionError
8 import voluptuous
as vol
21 from .const
import DOMAIN
23 STEP_USER_DATA_SCHEMA = vol.Schema(
25 vol.Required(CONF_HOST): str,
31 """Handle a Lektrico config flow."""
42 self, user_input: dict[str, str] |
None =
None
43 ) -> ConfigFlowResult:
44 """Handle a flow initiated by the user."""
47 if user_input
is not None:
48 self.
_host_host = user_input[CONF_HOST]
54 except DeviceConnectionError:
55 errors = {CONF_HOST:
"cannot_connect"}
62 user_input: dict[str, Any] |
None =
None,
63 errors: dict[str, str] |
None =
None,
64 ) -> ConfigFlowResult:
65 """Show the setup form to the user."""
66 if user_input
is None:
80 title=self.
_name_name,
82 CONF_HOST: self.
_host_host,
90 self, discovery_info: ZeroconfServiceInfo
91 ) -> ConfigFlowResult:
92 """Handle zeroconf discovery."""
93 self.
_host_host = discovery_info.host
98 except DeviceConnectionError:
101 self.context[
"title_placeholders"] = {
103 "name": self.
_name_name,
109 """Get device's serial number from a Lektrico device."""
111 _host=self.
_host_host,
115 settings = await device.device_config()
119 self.
_name_name = f
"{settings["type
"]}_{self._serial_number}"
126 updates={CONF_HOST: self.
_host_host}, reload_on_update=
True
130 self, user_input: dict[str, str] |
None =
None
131 ) -> ConfigFlowResult:
132 """Allow the user to confirm adding the device."""
134 if user_input
is not None:
None _get_lektrico_device_settings_and_treat_unique_id(self)
ConfigFlowResult _async_create_entry(self)
ConfigFlowResult async_step_user(self, dict[str, str]|None user_input=None)
ConfigFlowResult async_step_zeroconf(self, ZeroconfServiceInfo discovery_info)
ConfigFlowResult async_step_confirm(self, dict[str, str]|None user_input=None)
ConfigFlowResult _async_show_setup_form(self, dict[str, Any]|None user_input=None, dict[str, str]|None errors=None)
None _abort_if_unique_id_configured(self, dict[str, Any]|None updates=None, bool reload_on_update=True, *str error="already_configured")
None _set_confirm_only(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_abort(self, *str reason, Mapping[str, str]|None description_placeholders=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)
_FlowResultT async_abort(self, *str reason, Mapping[str, str]|None description_placeholders=None)
httpx.AsyncClient get_async_client(HomeAssistant hass, bool verify_ssl=True)