Home Assistant Unofficial Reference 2024.12.1
config_flow.py
Go to the documentation of this file.
1 """Config flow to configure DSMR Reader."""
2 
3 from __future__ import annotations
4 
5 from collections.abc import Awaitable
6 from typing import Any
7 
8 from homeassistant.config_entries import ConfigFlowResult
9 from homeassistant.core import HomeAssistant
10 from homeassistant.helpers.config_entry_flow import DiscoveryFlowHandler
11 
12 from .const import DOMAIN
13 
14 
15 async def _async_has_devices(_: HomeAssistant) -> bool:
16  """MQTT is set as dependency, so that should be sufficient."""
17  return True
18 
19 
20 class DsmrReaderFlowHandler(DiscoveryFlowHandler[Awaitable[bool]], domain=DOMAIN):
21  """Handle DSMR Reader config flow. The MQTT step is inherited from the parent class."""
22 
23  VERSION = 1
24 
25  def __init__(self) -> None:
26  """Set up the config flow."""
27  super().__init__(DOMAIN, "DSMR Reader", _async_has_devices)
28 
29  async def async_step_confirm(
30  self, user_input: dict[str, Any] | None = None
31  ) -> ConfigFlowResult:
32  """Confirm setup."""
33  if user_input is None:
34  return self.async_show_form(
35  step_id="confirm",
36  )
37 
38  return await super().async_step_confirm(user_input)
ConfigFlowResult async_step_confirm(self, dict[str, Any]|None user_input=None)
Definition: config_flow.py:31