Home Assistant Unofficial Reference 2024.12.1
config_flow.py
Go to the documentation of this file.
1 """Config flow for the Thread integration."""
2 
3 from __future__ import annotations
4 
5 from typing import Any
6 
7 from homeassistant.components import onboarding, zeroconf
8 from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
9 
10 from .const import DOMAIN
11 
12 
13 class ThreadConfigFlow(ConfigFlow, domain=DOMAIN):
14  """Handle a config flow for Thread."""
15 
16  VERSION = 1
17 
18  async def async_step_import(self, import_data: None) -> ConfigFlowResult:
19  """Set up by import from async_setup."""
20  await self._async_handle_discovery_without_unique_id_async_handle_discovery_without_unique_id()
21  return self.async_create_entryasync_create_entryasync_create_entry(title="Thread", data={})
22 
23  async def async_step_user(
24  self, user_input: dict[str, str] | None = None
25  ) -> ConfigFlowResult:
26  """Set up by import from async_setup."""
27  await self._async_handle_discovery_without_unique_id_async_handle_discovery_without_unique_id()
28  return self.async_create_entryasync_create_entryasync_create_entry(title="Thread", data={})
29 
31  self, discovery_info: zeroconf.ZeroconfServiceInfo
32  ) -> ConfigFlowResult:
33  """Set up because the user has border routers."""
34  await self._async_handle_discovery_without_unique_id_async_handle_discovery_without_unique_id()
35  return await self.async_step_confirmasync_step_confirm()
36 
37  async def async_step_confirm(
38  self, user_input: dict[str, Any] | None = None
39  ) -> ConfigFlowResult:
40  """Confirm the setup."""
41  if user_input is not None or not onboarding.async_is_onboarded(self.hass):
42  return self.async_create_entryasync_create_entryasync_create_entry(title="Thread", data={})
43  return self.async_show_formasync_show_formasync_show_form(step_id="confirm")
ConfigFlowResult async_step_confirm(self, dict[str, Any]|None user_input=None)
Definition: config_flow.py:39
ConfigFlowResult async_step_import(self, None import_data)
Definition: config_flow.py:18
ConfigFlowResult async_step_user(self, dict[str, str]|None user_input=None)
Definition: config_flow.py:25
ConfigFlowResult async_step_zeroconf(self, zeroconf.ZeroconfServiceInfo discovery_info)
Definition: config_flow.py:32
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)
_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)