Home Assistant Unofficial Reference 2024.12.1
config_flow.py
Go to the documentation of this file.
1 """Config flow for EDL21 integration."""
2 
3 import voluptuous as vol
4 
5 from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
6 
7 from .const import CONF_SERIAL_PORT, DEFAULT_TITLE, DOMAIN
8 
9 DATA_SCHEMA = vol.Schema(
10  {
11  vol.Required(CONF_SERIAL_PORT): str,
12  }
13 )
14 
15 
16 class EDL21ConfigFlow(ConfigFlow, domain=DOMAIN):
17  """EDL21 config flow."""
18 
19  VERSION = 1
20 
21  async def async_step_user(
22  self, user_input: dict[str, str] | None = None
23  ) -> ConfigFlowResult:
24  """Handle the user setup step."""
25  if user_input is not None:
26  self._async_abort_entries_match_async_abort_entries_match(
27  {CONF_SERIAL_PORT: user_input[CONF_SERIAL_PORT]}
28  )
29 
30  return self.async_create_entryasync_create_entryasync_create_entry(
31  title=DEFAULT_TITLE,
32  data=user_input,
33  )
34 
35  data_schema = self.add_suggested_values_to_schemaadd_suggested_values_to_schema(DATA_SCHEMA, user_input)
36  return self.async_show_formasync_show_formasync_show_form(step_id="user", data_schema=data_schema)
ConfigFlowResult async_step_user(self, dict[str, str]|None user_input=None)
Definition: config_flow.py:23
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)
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)
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)