hass-core/homeassistant/components/dsmr_reader/config_flow.py
Tom Puttemans 7aa53feff4
Add config flow and MQTT autodiscover to dsmr_reader integration (#71617)
Co-authored-by: J. Nick Koston <nick@koston.org>
Co-authored-by: G Johansson <goran.johansson@shiftit.se>
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2022-09-25 23:15:50 -04:00

40 lines
1.2 KiB
Python

"""Config flow to configure DSMR Reader."""
from __future__ import annotations
from collections.abc import Awaitable
import logging
from typing import Any
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.config_entry_flow import DiscoveryFlowHandler
from .const import DOMAIN
_LOGGER = logging.getLogger(__name__)
async def _async_has_devices(_: HomeAssistant) -> bool:
"""MQTT is set as dependency, so that should be sufficient."""
return True
class DsmrReaderFlowHandler(DiscoveryFlowHandler[Awaitable[bool]], domain=DOMAIN):
"""Handle DSMR Reader config flow. The MQTT step is inherited from the parent class."""
VERSION = 1
def __init__(self) -> None:
"""Set up the config flow."""
super().__init__(DOMAIN, "DSMR Reader", _async_has_devices)
async def async_step_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
"""Confirm setup."""
if user_input is None:
return self.async_show_form(
step_id="confirm",
)
return await super().async_step_confirm(user_input)