Home Assistant Unofficial Reference 2024.12.1
config_flow.py
Go to the documentation of this file.
1 """Config flow to configure iss component."""
2 
3 from __future__ import annotations
4 
5 import voluptuous as vol
6 
8  ConfigEntry,
9  ConfigFlow,
10  ConfigFlowResult,
11  OptionsFlow,
12 )
13 from homeassistant.const import CONF_SHOW_ON_MAP
14 from homeassistant.core import callback
15 
16 from .const import DEFAULT_NAME, DOMAIN
17 
18 
19 class ISSConfigFlow(ConfigFlow, domain=DOMAIN):
20  """Config flow for iss component."""
21 
22  VERSION = 1
23 
24  @staticmethod
25  @callback
27  config_entry: ConfigEntry,
28  ) -> OptionsFlowHandler:
29  """Get the options flow for this handler."""
30  return OptionsFlowHandler()
31 
32  async def async_step_user(self, user_input=None) -> ConfigFlowResult:
33  """Handle a flow initialized by the user."""
34  if user_input is not None:
35  return self.async_create_entryasync_create_entryasync_create_entry(
36  title=DEFAULT_NAME,
37  data={},
38  options={CONF_SHOW_ON_MAP: user_input.get(CONF_SHOW_ON_MAP, False)},
39  )
40 
41  return self.async_show_formasync_show_formasync_show_form(step_id="user")
42 
43 
45  """Config flow options handler for iss."""
46 
47  async def async_step_init(self, user_input=None) -> ConfigFlowResult:
48  """Manage the options."""
49  if user_input is not None:
50  return self.async_create_entryasync_create_entry(data=self.config_entryconfig_entryconfig_entry.options | user_input)
51 
52  return self.async_show_formasync_show_form(
53  step_id="init",
54  data_schema=vol.Schema(
55  {
56  vol.Optional(
57  CONF_SHOW_ON_MAP,
58  default=self.config_entryconfig_entryconfig_entry.options.get(CONF_SHOW_ON_MAP, False),
59  ): bool,
60  }
61  ),
62  )
ConfigFlowResult async_step_user(self, user_input=None)
Definition: config_flow.py:32
OptionsFlowHandler async_get_options_flow(ConfigEntry config_entry)
Definition: config_flow.py:28
ConfigFlowResult async_step_init(self, user_input=None)
Definition: config_flow.py:47
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_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)
None config_entry(self, ConfigEntry value)
_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)