Migrate integrations i-m to generic flowhandler (#111863)

This commit is contained in:
Erik Montnemery 2024-02-29 20:08:46 +01:00 committed by GitHub
parent 9ec9ac4fd4
commit 52e7912caf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
94 changed files with 715 additions and 612 deletions

View File

@ -4,8 +4,9 @@ import logging
from pyialarm import IAlarm
import voluptuous as vol
from homeassistant import config_entries, core
from homeassistant.config_entries import ConfigFlow
from homeassistant.const import CONF_HOST, CONF_PORT
from homeassistant.core import HomeAssistant
from .const import DEFAULT_PORT, DOMAIN
@ -19,12 +20,12 @@ DATA_SCHEMA = vol.Schema(
)
async def _get_device_mac(hass: core.HomeAssistant, host, port):
async def _get_device_mac(hass: HomeAssistant, host, port):
ialarm = IAlarm(host, port)
return await hass.async_add_executor_job(ialarm.get_mac)
class IAlarmConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class IAlarmConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Antifurto365 iAlarm."""
VERSION = 1

View File

@ -11,21 +11,20 @@ from iaqualink.exception import (
)
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.data_entry_flow import FlowResult
from .const import DOMAIN
class AqualinkFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class AqualinkFlowHandler(ConfigFlow, domain=DOMAIN):
"""Aqualink config flow."""
VERSION = 1
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow start."""
# Supporting a single account.
entries = self._async_current_entries()

View File

@ -6,23 +6,27 @@ from uuid import UUID
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import bluetooth
from homeassistant.config_entries import (
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
import homeassistant.helpers.config_validation as cv
from .const import CONF_ALLOW_NAMELESS_UUIDS, DOMAIN
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class IBeaconConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for iBeacon Tracker."""
VERSION = 1
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the initial step."""
if self._async_current_entries():
return self.async_abort(reason="single_instance_allowed")
@ -38,20 +42,20 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
@staticmethod
@callback
def async_get_options_flow(
config_entry: config_entries.ConfigEntry,
config_entry: ConfigEntry,
) -> OptionsFlow:
"""Get the options flow for this handler."""
return OptionsFlow(config_entry)
return IBeaconOptionsFlow(config_entry)
class OptionsFlow(config_entries.OptionsFlow):
class IBeaconOptionsFlow(OptionsFlow):
"""Handle options."""
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
def __init__(self, config_entry: ConfigEntry) -> None:
"""Initialize options flow."""
self.config_entry = config_entry
async def async_step_init(self, user_input: dict | None = None) -> FlowResult:
async def async_step_init(self, user_input: dict | None = None) -> ConfigFlowResult:
"""Manage the options."""
errors = {}

View File

@ -15,9 +15,8 @@ from pyicloud.exceptions import (
)
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.storage import Store
from .const import (
@ -38,7 +37,7 @@ CONF_VERIFICATION_CODE = "verification_code"
_LOGGER = logging.getLogger(__name__)
class IcloudFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class IcloudFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a iCloud config flow."""
VERSION = 1
@ -178,7 +177,9 @@ class IcloudFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
return await self._validate_and_create_entry(user_input, "user")
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
async def async_step_reauth(
self, entry_data: Mapping[str, Any]
) -> ConfigFlowResult:
"""Initialise re-authentication."""
# Store existing entry data so it can be used later and set unique ID
# so existing config entry can be updated
@ -189,7 +190,7 @@ class IcloudFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_reauth_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Update password for a config entry that can't authenticate."""
if user_input is None:
return self._show_setup_form(step_id="reauth_confirm")

View File

@ -10,20 +10,19 @@ from idasen_ha import Desk
from idasen_ha.errors import AuthFailedError
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components.bluetooth import (
BluetoothServiceInfoBleak,
async_discovered_service_info,
)
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_ADDRESS
from homeassistant.data_entry_flow import FlowResult
from .const import DOMAIN, EXPECTED_SERVICE_UUID
_LOGGER = logging.getLogger(__name__)
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class IdasenDeskConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Idasen Desk integration."""
VERSION = 1
@ -35,7 +34,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_bluetooth(
self, discovery_info: BluetoothServiceInfoBleak
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the bluetooth discovery step."""
await self.async_set_unique_id(discovery_info.address)
self._abort_if_unique_id_configured()
@ -49,7 +48,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the user step to pick discovered device."""
errors: dict[str, str] = {}

View File

@ -8,10 +8,15 @@ from typing import Any
from aioimaplib import AioImapException
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import (
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlowWithConfigEntry,
)
from homeassistant.const import CONF_PASSWORD, CONF_PORT, CONF_USERNAME, CONF_VERIFY_SSL
from homeassistant.core import HomeAssistant, callback
from homeassistant.data_entry_flow import AbortFlow, FlowResult
from homeassistant.data_entry_flow import AbortFlow
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.selector import (
BooleanSelector,
@ -119,15 +124,15 @@ async def validate_input(
return errors
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class IMAPConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for imap."""
VERSION = 1
_reauth_entry: config_entries.ConfigEntry | None
_reauth_entry: ConfigEntry | None
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the initial step."""
schema = CONFIG_SCHEMA
@ -152,7 +157,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
schema = self.add_suggested_values_to_schema(schema, user_input)
return self.async_show_form(step_id="user", data_schema=schema, errors=errors)
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
async def async_step_reauth(
self, entry_data: Mapping[str, Any]
) -> ConfigFlowResult:
"""Perform reauth upon an API authentication error."""
self._reauth_entry = self.hass.config_entries.async_get_entry(
self.context["entry_id"]
@ -161,7 +168,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_reauth_confirm(
self, user_input: dict[str, str] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Confirm reauth dialog."""
errors = {}
assert self._reauth_entry
@ -188,18 +195,18 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
@staticmethod
@callback
def async_get_options_flow(
config_entry: config_entries.ConfigEntry,
config_entry: ConfigEntry,
) -> OptionsFlow:
"""Get the options flow for this handler."""
return OptionsFlow(config_entry)
class OptionsFlow(config_entries.OptionsFlowWithConfigEntry):
class OptionsFlow(OptionsFlowWithConfigEntry):
"""Option flow handler."""
async def async_step_init(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Manage the options."""
errors: dict[str, str] | None = None
entry_data: dict[str, Any] = dict(self._config_entry.data)

View File

@ -19,11 +19,11 @@ from improv_ble_client import (
)
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import bluetooth
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_ADDRESS
from homeassistant.core import callback
from homeassistant.data_entry_flow import AbortFlow, FlowResult
from homeassistant.data_entry_flow import AbortFlow
from .const import DOMAIN
@ -47,7 +47,7 @@ class Credentials:
ssid: str
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class ImprovBLEConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Improv via BLE."""
VERSION = 1
@ -55,9 +55,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
_authorize_task: asyncio.Task | None = None
_can_identify: bool | None = None
_credentials: Credentials | None = None
_provision_result: FlowResult | None = None
_provision_result: ConfigFlowResult | None = None
_provision_task: asyncio.Task | None = None
_reauth_entry: config_entries.ConfigEntry | None = None
_reauth_entry: ConfigEntry | None = None
_remove_bluetooth_callback: Callable[[], None] | None = None
_unsub: Callable[[], None] | None = None
@ -71,7 +71,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the user step to pick discovered device."""
errors: dict[str, str] = {}
@ -158,7 +158,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_bluetooth(
self, discovery_info: bluetooth.BluetoothServiceInfoBleak
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the Bluetooth discovery step."""
self._discovery_info = discovery_info
@ -181,7 +181,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_bluetooth_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle bluetooth confirm step."""
# mypy is not aware that we can't get here without having these set already
assert self._discovery_info is not None
@ -198,7 +198,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_start_improv(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Start improv flow.
If the device supports identification, show a menu, if it does not,
@ -220,7 +220,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
return await self.async_step_main_menu()
return await self.async_step_provision()
async def async_step_main_menu(self, _: None = None) -> FlowResult:
async def async_step_main_menu(self, _: None = None) -> ConfigFlowResult:
"""Show the main menu."""
return self.async_show_menu(
step_id="main_menu",
@ -232,7 +232,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_identify(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle identify step."""
# mypy is not aware that we can't get here without having these set already
assert self._device is not None
@ -247,7 +247,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_provision(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle provision step."""
# mypy is not aware that we can't get here without having these set already
assert self._device is not None
@ -272,7 +272,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_do_provision(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Execute provisioning."""
async def _do_provision() -> None:
@ -339,7 +339,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_provision_done(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Show the result of the provision step."""
# mypy is not aware that we can't get here without having these set already
assert self._provision_result is not None
@ -350,7 +350,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_authorize(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle authorize step."""
# mypy is not aware that we can't get here without having these set already
assert self._device is not None

View File

@ -10,9 +10,8 @@ from homeassistant.components.bluetooth import (
BluetoothServiceInfoBleak,
async_discovered_service_info,
)
from homeassistant.config_entries import ConfigFlow
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_ADDRESS
from homeassistant.data_entry_flow import FlowResult
from .const import DOMAIN
@ -30,7 +29,7 @@ class INKBIRDConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_bluetooth(
self, discovery_info: BluetoothServiceInfoBleak
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the bluetooth discovery step."""
await self.async_set_unique_id(discovery_info.address)
self._abort_if_unique_id_configured()
@ -43,7 +42,7 @@ class INKBIRDConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_bluetooth_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Confirm discovery."""
assert self._discovered_device is not None
device = self._discovered_device
@ -62,7 +61,7 @@ class INKBIRDConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the user step to pick discovered device."""
if user_input is not None:
address = user_input[CONF_ADDRESS]

View File

@ -5,8 +5,14 @@ import logging
from pyinsteon import async_close, async_connect, devices
from homeassistant import config_entries
from homeassistant.components import dhcp, usb
from homeassistant.config_entries import (
DEFAULT_DISCOVERY_UNIQUE_ID,
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.const import (
CONF_ADDRESS,
CONF_DEVICE,
@ -17,7 +23,6 @@ from homeassistant.const import (
CONF_USERNAME,
)
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.device_registry import format_mac
from homeassistant.helpers.dispatcher import async_dispatcher_send
@ -106,7 +111,7 @@ def _remove_x10(device, options):
return new_options, housecode, unitcode
class InsteonFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class InsteonFlowHandler(ConfigFlow, domain=DOMAIN):
"""Insteon config flow handler."""
_device_path: str | None = None
@ -116,7 +121,7 @@ class InsteonFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
@staticmethod
@callback
def async_get_options_flow(
config_entry: config_entries.ConfigEntry,
config_entry: ConfigEntry,
) -> InsteonOptionsFlowHandler:
"""Define the config flow to handle options."""
return InsteonOptionsFlowHandler(config_entry)
@ -185,7 +190,9 @@ class InsteonFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
step_id=step_id, data_schema=data_schema, errors=errors
)
async def async_step_usb(self, discovery_info: usb.UsbServiceInfo) -> FlowResult:
async def async_step_usb(
self, discovery_info: usb.UsbServiceInfo
) -> ConfigFlowResult:
"""Handle USB discovery."""
if self._async_current_entries():
return self.async_abort(reason="single_instance_allowed")
@ -203,10 +210,10 @@ class InsteonFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
self.context["title_placeholders"] = {
CONF_NAME: f"Insteon PLM {self._device_name}"
}
await self.async_set_unique_id(config_entries.DEFAULT_DISCOVERY_UNIQUE_ID)
await self.async_set_unique_id(DEFAULT_DISCOVERY_UNIQUE_ID)
return await self.async_step_confirm_usb()
async def async_step_confirm_usb(self, user_input=None) -> FlowResult:
async def async_step_confirm_usb(self, user_input=None) -> ConfigFlowResult:
"""Confirm a USB discovery."""
if user_input is not None:
return await self.async_step_plm({CONF_DEVICE: self._device_path})
@ -216,7 +223,9 @@ class InsteonFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
description_placeholders={CONF_NAME: self._device_name},
)
async def async_step_dhcp(self, discovery_info: dhcp.DhcpServiceInfo) -> FlowResult:
async def async_step_dhcp(
self, discovery_info: dhcp.DhcpServiceInfo
) -> ConfigFlowResult:
"""Handle a DHCP discovery."""
self.discovered_conf = {CONF_HOST: discovery_info.ip}
self.context["title_placeholders"] = {
@ -226,14 +235,14 @@ class InsteonFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
return await self.async_step_user()
class InsteonOptionsFlowHandler(config_entries.OptionsFlow):
class InsteonOptionsFlowHandler(OptionsFlow):
"""Handle an Insteon options flow."""
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
def __init__(self, config_entry: ConfigEntry) -> None:
"""Init the InsteonOptionsFlowHandler class."""
self.config_entry = config_entry
async def async_step_init(self, user_input=None) -> FlowResult:
async def async_step_init(self, user_input=None) -> ConfigFlowResult:
"""Init the options config flow."""
menu_options = [STEP_ADD_OVERRIDE, STEP_ADD_X10]
@ -250,7 +259,7 @@ class InsteonOptionsFlowHandler(config_entries.OptionsFlow):
return self.async_show_menu(step_id="init", menu_options=menu_options)
async def async_step_change_hub_config(self, user_input=None) -> FlowResult:
async def async_step_change_hub_config(self, user_input=None) -> ConfigFlowResult:
"""Change the Hub configuration."""
errors = {}
if user_input is not None:
@ -276,7 +285,7 @@ class InsteonOptionsFlowHandler(config_entries.OptionsFlow):
step_id=STEP_CHANGE_HUB_CONFIG, data_schema=data_schema, errors=errors
)
async def async_step_change_plm_config(self, user_input=None) -> FlowResult:
async def async_step_change_plm_config(self, user_input=None) -> ConfigFlowResult:
"""Change the PLM configuration."""
errors = {}
if user_input is not None:
@ -299,7 +308,7 @@ class InsteonOptionsFlowHandler(config_entries.OptionsFlow):
step_id=STEP_CHANGE_PLM_CONFIG, data_schema=data_schema, errors=errors
)
async def async_step_add_override(self, user_input=None) -> FlowResult:
async def async_step_add_override(self, user_input=None) -> ConfigFlowResult:
"""Add a device override."""
errors = {}
if user_input is not None:
@ -315,7 +324,7 @@ class InsteonOptionsFlowHandler(config_entries.OptionsFlow):
step_id=STEP_ADD_OVERRIDE, data_schema=data_schema, errors=errors
)
async def async_step_add_x10(self, user_input=None) -> FlowResult:
async def async_step_add_x10(self, user_input=None) -> ConfigFlowResult:
"""Add an X10 device."""
errors: dict[str, str] = {}
if user_input is not None:
@ -328,7 +337,7 @@ class InsteonOptionsFlowHandler(config_entries.OptionsFlow):
step_id=STEP_ADD_X10, data_schema=data_schema, errors=errors
)
async def async_step_remove_override(self, user_input=None) -> FlowResult:
async def async_step_remove_override(self, user_input=None) -> ConfigFlowResult:
"""Remove a device override."""
errors: dict[str, str] = {}
options = self.config_entry.options
@ -346,7 +355,7 @@ class InsteonOptionsFlowHandler(config_entries.OptionsFlow):
step_id=STEP_REMOVE_OVERRIDE, data_schema=data_schema, errors=errors
)
async def async_step_remove_x10(self, user_input=None) -> FlowResult:
async def async_step_remove_x10(self, user_input=None) -> ConfigFlowResult:
"""Remove an X10 device."""
errors: dict[str, str] = {}
options = self.config_entry.options

View File

@ -11,10 +11,9 @@ from intellifire4py.exceptions import LoginException
from intellifire4py.intellifire import IntellifireAPICloud, IntellifireAPILocal
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components.dhcp import DhcpServiceInfo
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_API_KEY, CONF_HOST, CONF_PASSWORD, CONF_USERNAME
from homeassistant.data_entry_flow import FlowResult
from .const import CONF_USER_ID, DOMAIN, LOGGER
@ -46,7 +45,7 @@ async def validate_host_input(host: str, dhcp_mode: bool = False) -> str:
return serial
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class IntelliFireConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for IntelliFire."""
VERSION = 1
@ -107,7 +106,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_api_config(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Configure API access."""
errors = {}
@ -151,7 +150,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
step_id="api_config", errors=errors, data_schema=control_schema
)
async def _async_validate_ip_and_continue(self, host: str) -> FlowResult:
async def _async_validate_ip_and_continue(self, host: str) -> ConfigFlowResult:
"""Validate local config and continue."""
self._async_abort_entries_match({CONF_HOST: host})
self._serial = await validate_host_input(host)
@ -181,7 +180,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_pick_device(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Pick which device to configure."""
errors = {}
LOGGER.debug("STEP: pick_device")
@ -210,7 +209,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Start the user flow."""
# Launch fireplaces discovery
@ -222,7 +221,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
LOGGER.debug("Running Step: manual_device_entry")
return await self.async_step_manual_device_entry()
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
async def async_step_reauth(
self, entry_data: Mapping[str, Any]
) -> ConfigFlowResult:
"""Perform reauth upon an API authentication error."""
LOGGER.debug("STEP: reauth")
entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
@ -237,7 +238,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
self.context["title_placeholders"] = placeholders
return await self.async_step_api_config()
async def async_step_dhcp(self, discovery_info: DhcpServiceInfo) -> FlowResult:
async def async_step_dhcp(
self, discovery_info: DhcpServiceInfo
) -> ConfigFlowResult:
"""Handle DHCP Discovery."""
# Run validation logic on ip

View File

@ -6,8 +6,10 @@ import logging
from iotawattpy.iotawatt import Iotawatt
import voluptuous as vol
from homeassistant import config_entries, core, exceptions
from homeassistant.config_entries import ConfigFlow
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import httpx_client
from .const import CONNECTION_ERRORS, DOMAIN
@ -15,9 +17,7 @@ from .const import CONNECTION_ERRORS, DOMAIN
_LOGGER = logging.getLogger(__name__)
async def validate_input(
hass: core.HomeAssistant, data: dict[str, str]
) -> dict[str, str]:
async def validate_input(hass: HomeAssistant, data: dict[str, str]) -> dict[str, str]:
"""Validate the user input allows us to connect."""
iotawatt = Iotawatt(
"",
@ -40,7 +40,7 @@ async def validate_input(
return {}
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class IOTaWattConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for iotawatt."""
VERSION = 1
@ -99,9 +99,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
return self.async_create_entry(title=data[CONF_HOST], data=data)
class CannotConnect(exceptions.HomeAssistantError):
class CannotConnect(HomeAssistantError):
"""Error to indicate we cannot connect."""
class InvalidAuth(exceptions.HomeAssistantError):
class InvalidAuth(HomeAssistantError):
"""Error to indicate there is invalid auth."""

View File

@ -7,9 +7,8 @@ from pyipma.api import IPMA_API
from pyipma.location import Location
import voluptuous as vol
from homeassistant.config_entries import ConfigFlow
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
import homeassistant.helpers.config_validation as cv
@ -25,7 +24,7 @@ class IpmaFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initialized by the user."""
errors = {}

View File

@ -16,7 +16,7 @@ from pyipp import (
import voluptuous as vol
from homeassistant.components import zeroconf
from homeassistant.config_entries import ConfigFlow
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import (
CONF_HOST,
CONF_NAME,
@ -26,7 +26,6 @@ from homeassistant.const import (
CONF_VERIFY_SSL,
)
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import CONF_BASE_PATH, CONF_SERIAL, DOMAIN
@ -65,7 +64,7 @@ class IPPFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initiated by the user."""
if user_input is None:
return self._show_setup_form()
@ -104,7 +103,7 @@ class IPPFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_zeroconf(
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle zeroconf discovery."""
host = discovery_info.host
@ -190,7 +189,7 @@ class IPPFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_zeroconf_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a confirmation flow initiated by zeroconf."""
if user_input is None:
return self.async_show_form(
@ -204,7 +203,7 @@ class IPPFlowHandler(ConfigFlow, domain=DOMAIN):
data=self.discovery_info,
)
def _show_setup_form(self, errors: dict | None = None) -> FlowResult:
def _show_setup_form(self, errors: dict | None = None) -> ConfigFlowResult:
"""Show the setup form to the user."""
return self.async_show_form(
step_id="user",

View File

@ -7,14 +7,13 @@ from pyiqvia import Client
from pyiqvia.errors import InvalidZipError
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.data_entry_flow import FlowResult
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.helpers import aiohttp_client
from .const import CONF_ZIP_CODE, DOMAIN
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class IqviaConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle an IQVIA config flow."""
VERSION = 1
@ -25,7 +24,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the start of the config flow."""
if not user_input:
return self.async_show_form(step_id="user", data_schema=self.data_schema)

View File

@ -7,10 +7,14 @@ from prayer_times_calculator import InvalidResponseError, PrayerTimesCalculator
from requests.exceptions import ConnectionError as ConnError
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import (
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.const import CONF_LATITUDE, CONF_LOCATION, CONF_LONGITUDE, CONF_NAME
from homeassistant.core import HomeAssistant, callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.selector import (
LocationSelector,
SelectSelector,
@ -58,7 +62,7 @@ async def async_validate_location(
return errors
class IslamicPrayerFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class IslamicPrayerFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle the Islamic Prayer config flow."""
VERSION = 1
@ -67,14 +71,14 @@ class IslamicPrayerFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
@staticmethod
@callback
def async_get_options_flow(
config_entry: config_entries.ConfigEntry,
config_entry: ConfigEntry,
) -> IslamicPrayerOptionsFlowHandler:
"""Get the options flow for this handler."""
return IslamicPrayerOptionsFlowHandler(config_entry)
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initialized by the user."""
errors = {}
@ -111,16 +115,16 @@ class IslamicPrayerFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
)
class IslamicPrayerOptionsFlowHandler(config_entries.OptionsFlow):
class IslamicPrayerOptionsFlowHandler(OptionsFlow):
"""Handle Islamic Prayer client options."""
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
def __init__(self, config_entry: ConfigEntry) -> None:
"""Initialize options flow."""
self.config_entry = config_entry
async def async_step_init(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Manage options."""
if user_input is not None:
return self.async_create_entry(title="", data=user_input)

View File

@ -2,15 +2,19 @@
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import (
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.const import CONF_SHOW_ON_MAP
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from .const import DEFAULT_NAME, DOMAIN
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class ISSConfigFlow(ConfigFlow, domain=DOMAIN):
"""Config flow for iss component."""
VERSION = 1
@ -18,12 +22,12 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
@staticmethod
@callback
def async_get_options_flow(
config_entry: config_entries.ConfigEntry,
) -> config_entries.OptionsFlow:
config_entry: ConfigEntry,
) -> OptionsFlow:
"""Get the options flow for this handler."""
return OptionsFlowHandler(config_entry)
async def async_step_user(self, user_input=None) -> FlowResult:
async def async_step_user(self, user_input=None) -> ConfigFlowResult:
"""Handle a flow initialized by the user."""
# Check if already configured
if self._async_current_entries():
@ -39,15 +43,15 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
return self.async_show_form(step_id="user")
class OptionsFlowHandler(config_entries.OptionsFlow):
class OptionsFlowHandler(OptionsFlow):
"""Config flow options handler for iss."""
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
def __init__(self, config_entry: ConfigEntry) -> None:
"""Initialize options flow."""
self.config_entry = config_entry
self.options = dict(config_entry.options)
async def async_step_init(self, user_input=None) -> FlowResult:
async def async_step_init(self, user_input=None) -> ConfigFlowResult:
"""Manage the options."""
if user_input is not None:
self.options.update(user_input)

View File

@ -13,11 +13,18 @@ from pyisy.configuration import Configuration
from pyisy.connection import Connection
import voluptuous as vol
from homeassistant import config_entries, core, exceptions
from homeassistant.components import dhcp, ssdp
from homeassistant.config_entries import (
SOURCE_IGNORE,
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import callback
from homeassistant.data_entry_flow import AbortFlow, FlowResult
from homeassistant.core import HomeAssistant, callback
from homeassistant.data_entry_flow import AbortFlow
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import aiohttp_client
from .const import (
@ -58,9 +65,7 @@ def _data_schema(schema_input: dict[str, str]) -> vol.Schema:
)
async def validate_input(
hass: core.HomeAssistant, data: dict[str, Any]
) -> dict[str, str]:
async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> dict[str, str]:
"""Validate the user input allows us to connect.
Data has the keys from DATA_SCHEMA with values provided by the user.
@ -118,7 +123,7 @@ async def validate_input(
}
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class Isy994ConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Universal Devices ISY/IoX."""
VERSION = 1
@ -126,19 +131,19 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
def __init__(self) -> None:
"""Initialize the ISY/IoX config flow."""
self.discovered_conf: dict[str, str] = {}
self._existing_entry: config_entries.ConfigEntry | None = None
self._existing_entry: ConfigEntry | None = None
@staticmethod
@callback
def async_get_options_flow(
config_entry: config_entries.ConfigEntry,
) -> config_entries.OptionsFlow:
config_entry: ConfigEntry,
) -> OptionsFlow:
"""Get the options flow for this handler."""
return OptionsFlowHandler(config_entry)
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the initial step."""
errors = {}
info: dict[str, str] = {}
@ -175,7 +180,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
existing_entry = await self.async_set_unique_id(isy_mac)
if not existing_entry:
return
if existing_entry.source == config_entries.SOURCE_IGNORE:
if existing_entry.source == SOURCE_IGNORE:
raise AbortFlow("already_configured")
parsed_url = urlparse(existing_entry.data[CONF_HOST])
if parsed_url.hostname != ip_address:
@ -202,7 +207,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
)
raise AbortFlow("already_configured")
async def async_step_dhcp(self, discovery_info: dhcp.DhcpServiceInfo) -> FlowResult:
async def async_step_dhcp(
self, discovery_info: dhcp.DhcpServiceInfo
) -> ConfigFlowResult:
"""Handle a discovered ISY/IoX device via dhcp."""
friendly_name = discovery_info.hostname
if friendly_name.startswith("polisy") or friendly_name.startswith("eisy"):
@ -223,7 +230,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
self.context["title_placeholders"] = self.discovered_conf
return await self.async_step_user()
async def async_step_ssdp(self, discovery_info: ssdp.SsdpServiceInfo) -> FlowResult:
async def async_step_ssdp(
self, discovery_info: ssdp.SsdpServiceInfo
) -> ConfigFlowResult:
"""Handle a discovered ISY/IoX Device."""
friendly_name = discovery_info.upnp[ssdp.ATTR_UPNP_FRIENDLY_NAME]
url = discovery_info.ssdp_location
@ -250,14 +259,16 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
self.context["title_placeholders"] = self.discovered_conf
return await self.async_step_user()
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
async def async_step_reauth(
self, entry_data: Mapping[str, Any]
) -> ConfigFlowResult:
"""Handle reauth."""
self._existing_entry = await self.async_set_unique_id(self.context["unique_id"])
return await self.async_step_reauth_confirm()
async def async_step_reauth_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle reauth input."""
errors = {}
assert self._existing_entry is not None
@ -299,16 +310,16 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
)
class OptionsFlowHandler(config_entries.OptionsFlow):
class OptionsFlowHandler(OptionsFlow):
"""Handle a option flow for ISY/IoX."""
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
def __init__(self, config_entry: ConfigEntry) -> None:
"""Initialize options flow."""
self.config_entry = config_entry
async def async_step_init(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle options flow."""
if user_input is not None:
return self.async_create_entry(title="", data=user_input)
@ -337,13 +348,13 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
return self.async_show_form(step_id="init", data_schema=options_schema)
class InvalidHost(exceptions.HomeAssistantError):
class InvalidHost(HomeAssistantError):
"""Error to indicate the host value is invalid."""
class CannotConnect(exceptions.HomeAssistantError):
class CannotConnect(HomeAssistantError):
"""Error to indicate we cannot connect."""
class InvalidAuth(exceptions.HomeAssistantError):
class InvalidAuth(HomeAssistantError):
"""Error to indicate there is invalid auth."""

View File

@ -7,9 +7,8 @@ from typing import Any
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_PASSWORD, CONF_URL, CONF_USERNAME
from homeassistant.data_entry_flow import FlowResult
from homeassistant.util.uuid import random_uuid_hex
from .client_wrapper import CannotConnect, InvalidAuth, create_client, validate_input
@ -37,7 +36,7 @@ def _generate_client_device_id() -> str:
return random_uuid_hex()
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class JellyfinConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Jellyfin."""
VERSION = 1
@ -45,11 +44,11 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
def __init__(self) -> None:
"""Initialize the Jellyfin config flow."""
self.client_device_id: str | None = None
self.entry: config_entries.ConfigEntry | None = None
self.entry: ConfigEntry | None = None
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a user defined configuration."""
if self._async_current_entries():
return self.async_abort(reason="single_instance_allowed")
@ -92,14 +91,16 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
step_id="user", data_schema=STEP_USER_DATA_SCHEMA, errors=errors
)
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
async def async_step_reauth(
self, entry_data: Mapping[str, Any]
) -> ConfigFlowResult:
"""Perform reauth upon an API authentication error."""
self.entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
return await self.async_step_reauth_confirm()
async def async_step_reauth_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Dialog that informs the user that reauth is required."""
errors: dict[str, str] = {}

View File

@ -1,11 +1,11 @@
"""Config flow for JuiceNet integration."""
from homeassistant import config_entries
from homeassistant.config_entries import ConfigFlow
from . import DOMAIN
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class JuiceNetConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for JuiceNet."""
VERSION = 1

View File

@ -8,9 +8,8 @@ from typing import Any
import justnimbus
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_CLIENT_ID
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import config_validation as cv
from .const import CONF_ZIP_CODE, DOMAIN
@ -25,15 +24,15 @@ STEP_USER_DATA_SCHEMA = vol.Schema(
)
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class JustNimbusConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for JustNimbus."""
VERSION = 1
reauth_entry: config_entries.ConfigEntry | None = None
reauth_entry: ConfigEntry | None = None
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the initial step."""
if user_input is None:
return self.async_show_form(
@ -76,7 +75,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
step_id="user", data_schema=STEP_USER_DATA_SCHEMA, errors=errors
)
async def async_step_reauth(self, user_input: Mapping[str, Any]) -> FlowResult:
async def async_step_reauth(
self, user_input: Mapping[str, Any]
) -> ConfigFlowResult:
"""Perform reauth upon an API authentication error."""
self.reauth_entry = self.hass.config_entries.async_get_entry(
self.context["entry_id"]

View File

@ -9,9 +9,8 @@ from jvcprojector import JvcProjector, JvcProjectorAuthError, JvcProjectorConnec
from jvcprojector.projector import DEFAULT_PORT
import voluptuous as vol
from homeassistant.config_entries import ConfigEntry, ConfigFlow
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.device_registry import format_mac
from homeassistant.util.network import is_host_valid
@ -27,7 +26,7 @@ class JvcProjectorConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle user initiated device additions."""
errors = {}
@ -74,7 +73,9 @@ class JvcProjectorConfigFlow(ConfigFlow, domain=DOMAIN):
errors=errors,
)
async def async_step_reauth(self, user_input: Mapping[str, Any]) -> FlowResult:
async def async_step_reauth(
self, user_input: Mapping[str, Any]
) -> ConfigFlowResult:
"""Perform reauth on password authentication error."""
self._reauth_entry = self.hass.config_entries.async_get_entry(
self.context["entry_id"]
@ -83,7 +84,7 @@ class JvcProjectorConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_reauth_confirm(
self, user_input: Mapping[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Dialog that informs the user that reauth is required."""
assert self._reauth_entry

View File

@ -2,21 +2,18 @@
from __future__ import annotations
from typing import TYPE_CHECKING, Any, cast
from typing import Any, cast
from urllib.parse import urlparse
import voluptuous as vol
from homeassistant.components import ssdp
from homeassistant.config_entries import ConfigFlow
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_HOST
from . import KaleidescapeDeviceInfo, UnsupportedError, validate_host
from .const import DEFAULT_HOST, DOMAIN, NAME as KALEIDESCAPE_NAME
if TYPE_CHECKING:
from homeassistant.data_entry_flow import FlowResult
ERROR_CANNOT_CONNECT = "cannot_connect"
ERROR_UNSUPPORTED = "unsupported"
@ -30,7 +27,7 @@ class KaleidescapeConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle user initiated device additions."""
errors = {}
host = DEFAULT_HOST
@ -63,7 +60,9 @@ class KaleidescapeConfigFlow(ConfigFlow, domain=DOMAIN):
errors=errors,
)
async def async_step_ssdp(self, discovery_info: ssdp.SsdpServiceInfo) -> FlowResult:
async def async_step_ssdp(
self, discovery_info: ssdp.SsdpServiceInfo
) -> ConfigFlowResult:
"""Handle discovered device."""
host = cast(str, urlparse(discovery_info.ssdp_location).hostname)
serial_number = discovery_info.upnp[ssdp.ATTR_UPNP_SERIAL]
@ -93,7 +92,7 @@ class KaleidescapeConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_discovery_confirm(
self, user_input: dict | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle addition of discovered device."""
if user_input is None:
return self.async_show_form(

View File

@ -7,9 +7,13 @@ from urllib.parse import urlparse
from ndms2_client import Client, ConnectionException, InterfaceInfo, TelnetConnection
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import ssdp
from homeassistant.config_entries import ConfigEntry
from homeassistant.config_entries import (
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.const import (
CONF_HOST,
CONF_PASSWORD,
@ -18,7 +22,6 @@ from homeassistant.const import (
CONF_USERNAME,
)
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import config_validation as cv
from .const import (
@ -37,7 +40,7 @@ from .const import (
from .router import KeeneticRouter
class KeeneticFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class KeeneticFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a config flow."""
VERSION = 1
@ -52,7 +55,7 @@ class KeeneticFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initialized by the user."""
errors = {}
if user_input is not None:
@ -97,7 +100,9 @@ class KeeneticFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
errors=errors,
)
async def async_step_ssdp(self, discovery_info: ssdp.SsdpServiceInfo) -> FlowResult:
async def async_step_ssdp(
self, discovery_info: ssdp.SsdpServiceInfo
) -> ConfigFlowResult:
"""Handle a discovered device."""
friendly_name = discovery_info.upnp.get(ssdp.ATTR_UPNP_FRIENDLY_NAME, "")
@ -124,7 +129,7 @@ class KeeneticFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
return await self.async_step_user()
class KeeneticOptionsFlowHandler(config_entries.OptionsFlow):
class KeeneticOptionsFlowHandler(OptionsFlow):
"""Handle options."""
def __init__(self, config_entry: ConfigEntry) -> None:
@ -134,7 +139,7 @@ class KeeneticOptionsFlowHandler(config_entries.OptionsFlow):
async def async_step_init(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Manage the options."""
router: KeeneticRouter = self.hass.data[DOMAIN][self.config_entry.entry_id][
ROUTER
@ -153,7 +158,7 @@ class KeeneticOptionsFlowHandler(config_entries.OptionsFlow):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Manage the device tracker options."""
if user_input is not None:
return self.async_create_entry(title="", data=user_input)

View File

@ -10,9 +10,8 @@ from homeassistant.components.bluetooth import (
BluetoothServiceInfoBleak,
async_discovered_service_info,
)
from homeassistant.config_entries import ConfigFlow
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_ADDRESS
from homeassistant.data_entry_flow import FlowResult
from .const import DOMAIN
@ -30,7 +29,7 @@ class KegtronConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_bluetooth(
self, discovery_info: BluetoothServiceInfoBleak
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the bluetooth discovery step."""
await self.async_set_unique_id(discovery_info.address)
self._abort_if_unique_id_configured()
@ -43,7 +42,7 @@ class KegtronConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_bluetooth_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Confirm discovery."""
assert self._discovered_device is not None
device = self._discovered_device
@ -62,7 +61,7 @@ class KegtronConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the user step to pick discovered device."""
if user_input is not None:
address = user_input[CONF_ADDRESS]

View File

@ -17,9 +17,8 @@ from homeassistant.components.bluetooth import (
BluetoothServiceInfoBleak,
async_discovered_service_info,
)
from homeassistant.config_entries import ConfigFlow
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_ADDRESS
from homeassistant.data_entry_flow import FlowResult
from .const import DOMAIN
@ -54,7 +53,7 @@ class MicroBotConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_bluetooth(
self, discovery_info: BluetoothServiceInfoBleak
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the bluetooth discovery step."""
_LOGGER.debug("Discovered bluetooth device: %s", discovery_info)
await self.async_set_unique_id(discovery_info.address)
@ -71,14 +70,14 @@ class MicroBotConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initialized by the user."""
# This is for backwards compatibility.
return await self.async_step_init(user_input)
async def async_step_init(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Check if paired."""
errors: dict[str, str] = {}
@ -125,7 +124,7 @@ class MicroBotConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_link(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Given a configured host, will ask the user to press the button to pair."""
errors: dict[str, str] = {}
token = randomid(32)

View File

@ -3,18 +3,17 @@ from __future__ import annotations
from typing import Any
from homeassistant import config_entries
from homeassistant.data_entry_flow import FlowResult
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from . import DOMAIN
class KitchenSinkConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class KitchenSinkConfigFlow(ConfigFlow, domain=DOMAIN):
"""Kitchen Sink configuration flow."""
VERSION = 1
async def async_step_import(self, import_info: dict[str, Any]) -> FlowResult:
async def async_step_import(self, import_info: dict[str, Any]) -> ConfigFlowResult:
"""Set the config entry up from yaml."""
if self._async_current_entries():
return self.async_abort(reason="single_instance_allowed")

View File

@ -8,9 +8,10 @@ from pykmtronic.auth import Auth
from pykmtronic.hub import KMTronicHubAPI
import voluptuous as vol
from homeassistant import config_entries, core, exceptions
from homeassistant.config_entries import ConfigEntry, ConfigFlow, OptionsFlow
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import callback
from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import aiohttp_client
from .const import CONF_REVERSE, DOMAIN
@ -26,7 +27,7 @@ DATA_SCHEMA = vol.Schema(
)
async def validate_input(hass: core.HomeAssistant, data):
async def validate_input(hass: HomeAssistant, data):
"""Validate the user input allows us to connect."""
session = aiohttp_client.async_get_clientsession(hass)
auth = Auth(
@ -47,7 +48,7 @@ async def validate_input(hass: core.HomeAssistant, data):
return data
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class KmtronicConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for kmtronic."""
VERSION = 1
@ -55,7 +56,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
@staticmethod
@callback
def async_get_options_flow(
config_entry: config_entries.ConfigEntry,
config_entry: ConfigEntry,
) -> KMTronicOptionsFlow:
"""Get the options flow for this handler."""
return KMTronicOptionsFlow(config_entry)
@ -81,18 +82,18 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
)
class CannotConnect(exceptions.HomeAssistantError):
class CannotConnect(HomeAssistantError):
"""Error to indicate we cannot connect."""
class InvalidAuth(exceptions.HomeAssistantError):
class InvalidAuth(HomeAssistantError):
"""Error to indicate there is invalid auth."""
class KMTronicOptionsFlow(config_entries.OptionsFlow):
class KMTronicOptionsFlow(OptionsFlow):
"""Handle options."""
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
def __init__(self, config_entry: ConfigEntry) -> None:
"""Initialize options flow."""
self.config_entry = config_entry

View File

@ -18,10 +18,15 @@ from xknx.io.self_description import request_description
from xknx.io.util import validate_ip as xknx_validate_ip
from xknx.secure.keyring import Keyring, XMLInterface
from homeassistant.config_entries import ConfigEntry, ConfigFlow, OptionsFlow
from homeassistant.config_entries import (
ConfigEntry,
ConfigEntryBaseFlow,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.const import CONF_HOST, CONF_PORT
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowHandler, FlowResult
from homeassistant.helpers import selector
from homeassistant.helpers.typing import UNDEFINED
@ -96,7 +101,7 @@ _PORT_SELECTOR = vol.All(
)
class KNXCommonFlow(ABC, FlowHandler):
class KNXCommonFlow(ABC, ConfigEntryBaseFlow):
"""Base class for KNX flows."""
def __init__(self, initial_data: KNXConfigEntryData) -> None:
@ -115,7 +120,7 @@ class KNXCommonFlow(ABC, FlowHandler):
self._async_scan_gen: AsyncGenerator[GatewayDescriptor, None] | None = None
@abstractmethod
def finish_flow(self) -> FlowResult:
def finish_flow(self) -> ConfigFlowResult:
"""Finish the flow."""
@property
@ -136,7 +141,7 @@ class KNXCommonFlow(ABC, FlowHandler):
async def async_step_connection_type(
self, user_input: dict | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle connection type configuration."""
if user_input is not None:
if self._async_scan_gen:
@ -202,7 +207,9 @@ class KNXCommonFlow(ABC, FlowHandler):
step_id="connection_type", data_schema=vol.Schema(fields)
)
async def async_step_tunnel(self, user_input: dict | None = None) -> FlowResult:
async def async_step_tunnel(
self, user_input: dict | None = None
) -> ConfigFlowResult:
"""Select a tunnel from a list.
Will be skipped if the gateway scan was unsuccessful
@ -258,7 +265,7 @@ class KNXCommonFlow(ABC, FlowHandler):
async def async_step_manual_tunnel(
self, user_input: dict | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Manually configure tunnel connection parameters. Fields default to preselected gateway if one was found."""
errors: dict = {}
@ -380,7 +387,7 @@ class KNXCommonFlow(ABC, FlowHandler):
async def async_step_secure_tunnel_manual(
self, user_input: dict | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Configure ip secure tunnelling manually."""
errors: dict = {}
@ -428,7 +435,7 @@ class KNXCommonFlow(ABC, FlowHandler):
async def async_step_secure_routing_manual(
self, user_input: dict | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Configure ip secure routing manually."""
errors: dict = {}
@ -481,7 +488,7 @@ class KNXCommonFlow(ABC, FlowHandler):
async def async_step_secure_knxkeys(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Manage upload of new KNX Keyring file."""
errors: dict[str, str] = {}
@ -533,7 +540,7 @@ class KNXCommonFlow(ABC, FlowHandler):
async def async_step_knxkeys_tunnel_select(
self, user_input: dict | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Select if a specific tunnel should be used from knxkeys file."""
errors = {}
description_placeholders = {}
@ -618,7 +625,9 @@ class KNXCommonFlow(ABC, FlowHandler):
description_placeholders=description_placeholders,
)
async def async_step_routing(self, user_input: dict | None = None) -> FlowResult:
async def async_step_routing(
self, user_input: dict | None = None
) -> ConfigFlowResult:
"""Routing setup."""
errors: dict = {}
_individual_address = (
@ -703,7 +712,7 @@ class KNXCommonFlow(ABC, FlowHandler):
async def async_step_secure_key_source_menu_tunnel(
self, user_input: dict | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Show the key source menu."""
return self.async_show_menu(
step_id="secure_key_source_menu_tunnel",
@ -712,7 +721,7 @@ class KNXCommonFlow(ABC, FlowHandler):
async def async_step_secure_key_source_menu_routing(
self, user_input: dict | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Show the key source menu."""
return self.async_show_menu(
step_id="secure_key_source_menu_routing",
@ -736,7 +745,7 @@ class KNXConfigFlow(KNXCommonFlow, ConfigFlow, domain=DOMAIN):
return KNXOptionsFlow(config_entry)
@callback
def finish_flow(self) -> FlowResult:
def finish_flow(self) -> ConfigFlowResult:
"""Create the ConfigEntry."""
title = self.new_title or f"KNX {self.new_entry_data[CONF_KNX_CONNECTION_TYPE]}"
return self.async_create_entry(
@ -744,7 +753,7 @@ class KNXConfigFlow(KNXCommonFlow, ConfigFlow, domain=DOMAIN):
data=DEFAULT_ENTRY_DATA | self.new_entry_data,
)
async def async_step_user(self, user_input: dict | None = None) -> FlowResult:
async def async_step_user(self, user_input: dict | None = None) -> ConfigFlowResult:
"""Handle a flow initialized by the user."""
if self._async_current_entries():
return self.async_abort(reason="single_instance_allowed")
@ -762,7 +771,7 @@ class KNXOptionsFlow(KNXCommonFlow, OptionsFlow):
super().__init__(initial_data=config_entry.data) # type: ignore[arg-type]
@callback
def finish_flow(self) -> FlowResult:
def finish_flow(self) -> ConfigFlowResult:
"""Update the ConfigEntry and finish the flow."""
new_data = DEFAULT_ENTRY_DATA | self.initial_data | self.new_entry_data
self.hass.config_entries.async_update_entry(
@ -774,7 +783,7 @@ class KNXOptionsFlow(KNXCommonFlow, OptionsFlow):
async def async_step_init(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Manage KNX options."""
return self.async_show_menu(
step_id="init",
@ -787,7 +796,7 @@ class KNXOptionsFlow(KNXCommonFlow, OptionsFlow):
async def async_step_communication_settings(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Manage KNX communication settings."""
if user_input is not None:
self.new_entry_data = KNXConfigEntryData(

View File

@ -6,8 +6,8 @@ import logging
from pykodi import CannotConnectError, InvalidAuthError, Kodi, get_kodi_connection
import voluptuous as vol
from homeassistant import config_entries, core, exceptions
from homeassistant.components import zeroconf
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import (
CONF_HOST,
CONF_NAME,
@ -17,8 +17,8 @@ from homeassistant.const import (
CONF_TIMEOUT,
CONF_USERNAME,
)
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import (
@ -33,7 +33,7 @@ from .const import (
_LOGGER = logging.getLogger(__name__)
async def validate_http(hass: core.HomeAssistant, data):
async def validate_http(hass: HomeAssistant, data):
"""Validate the user input allows us to connect over HTTP."""
host = data[CONF_HOST]
@ -56,7 +56,7 @@ async def validate_http(hass: core.HomeAssistant, data):
raise InvalidAuth from error
async def validate_ws(hass: core.HomeAssistant, data):
async def validate_ws(hass: HomeAssistant, data):
"""Validate the user input allows us to connect over WS."""
if not (ws_port := data.get(CONF_WS_PORT)):
return
@ -84,7 +84,7 @@ async def validate_ws(hass: core.HomeAssistant, data):
raise WSCannotConnect from error
class KodiConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class KodiConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Kodi."""
VERSION = 1
@ -102,7 +102,7 @@ class KodiConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_zeroconf(
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle zeroconf discovery."""
self._host = discovery_info.host
self._port = discovery_info.port or DEFAULT_PORT
@ -313,13 +313,13 @@ class KodiConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
return data
class CannotConnect(exceptions.HomeAssistantError):
class CannotConnect(HomeAssistantError):
"""Error to indicate we cannot connect."""
class InvalidAuth(exceptions.HomeAssistantError):
class InvalidAuth(HomeAssistantError):
"""Error to indicate there is invalid auth."""
class WSCannotConnect(exceptions.HomeAssistantError):
class WSCannotConnect(HomeAssistantError):
"""Error to indicate we cannot connect to websocket."""

View File

@ -11,12 +11,17 @@ from urllib.parse import urlparse
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import ssdp
from homeassistant.components.binary_sensor import (
DEVICE_CLASSES_SCHEMA,
BinarySensorDeviceClass,
)
from homeassistant.config_entries import (
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.const import (
CONF_ACCESS_TOKEN,
CONF_BINARY_SENSORS,
@ -33,7 +38,6 @@ from homeassistant.const import (
CONF_ZONE,
)
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import config_validation as cv
from .const import (
@ -166,7 +170,7 @@ CONFIG_ENTRY_SCHEMA = vol.Schema(
)
class KonnectedFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class KonnectedFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Konnected Panels."""
VERSION = 1
@ -244,7 +248,9 @@ class KonnectedFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
)
return await self.async_step_user()
async def async_step_ssdp(self, discovery_info: ssdp.SsdpServiceInfo) -> FlowResult:
async def async_step_ssdp(
self, discovery_info: ssdp.SsdpServiceInfo
) -> ConfigFlowResult:
"""Handle a discovered konnected panel.
This flow is triggered by the SSDP component. It will check if the
@ -376,16 +382,16 @@ class KonnectedFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
@staticmethod
@callback
def async_get_options_flow(
config_entry: config_entries.ConfigEntry,
config_entry: ConfigEntry,
) -> OptionsFlowHandler:
"""Return the Options Flow."""
return OptionsFlowHandler(config_entry)
class OptionsFlowHandler(config_entries.OptionsFlow):
class OptionsFlowHandler(OptionsFlow):
"""Handle a option flow for a Konnected Panel."""
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
def __init__(self, config_entry: ConfigEntry) -> None:
"""Initialize options flow."""
self.entry = config_entry
self.model = self.entry.data[CONF_MODEL]

View File

@ -5,7 +5,7 @@ from aiohttp.client_exceptions import ClientError
from pykoplenti import ApiClient, AuthenticationException
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigFlow
from homeassistant.const import CONF_BASE, CONF_HOST, CONF_PASSWORD
from homeassistant.core import HomeAssistant
from homeassistant.helpers.aiohttp_client import async_get_clientsession
@ -38,7 +38,7 @@ async def test_connection(hass: HomeAssistant, data) -> str:
return values["scb:network"][hostname_id]
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class KostalPlenticoreConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Kostal Plenticore Solar Inverter."""
VERSION = 1

View File

@ -7,17 +7,21 @@ import krakenex
from pykrakenapi.pykrakenapi import KrakenAPI
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import (
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.const import CONF_SCAN_INTERVAL
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import config_validation as cv
from .const import CONF_TRACKED_ASSET_PAIRS, DEFAULT_SCAN_INTERVAL, DOMAIN
from .utils import get_tradable_asset_pairs
class KrakenConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class KrakenConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for kraken."""
VERSION = 1
@ -25,14 +29,14 @@ class KrakenConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
@staticmethod
@callback
def async_get_options_flow(
config_entry: config_entries.ConfigEntry,
config_entry: ConfigEntry,
) -> KrakenOptionsFlowHandler:
"""Get the options flow for this handler."""
return KrakenOptionsFlowHandler(config_entry)
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the initial step."""
if self._async_current_entries():
return self.async_abort(reason="already_configured")
@ -45,16 +49,16 @@ class KrakenConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
)
class KrakenOptionsFlowHandler(config_entries.OptionsFlow):
class KrakenOptionsFlowHandler(OptionsFlow):
"""Handle Kraken client options."""
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
def __init__(self, config_entry: ConfigEntry) -> None:
"""Initialize Kraken options flow."""
self.config_entry = config_entry
async def async_step_init(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Manage the Kraken options."""
if user_input is not None:
return self.async_create_entry(title="", data=user_input)

View File

@ -8,9 +8,8 @@ from typing import Any
from lacrosse_view import LaCrosse, Location, LoginError
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResult
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.aiohttp_client import async_get_clientsession
@ -45,7 +44,7 @@ async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> list[Loca
return locations
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class LaCrosseViewConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for LaCrosse View."""
VERSION = 1
@ -54,11 +53,11 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
"""Initialize the config flow."""
self.data: dict[str, str] = {}
self.locations: list[Location] = []
self._reauth_entry: config_entries.ConfigEntry | None = None
self._reauth_entry: ConfigEntry | None = None
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the initial step."""
if user_input is None:
_LOGGER.debug("Showing initial form")
@ -100,7 +99,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_location(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the location step."""
if not user_input:
@ -135,7 +134,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
},
)
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
async def async_step_reauth(
self, entry_data: Mapping[str, Any]
) -> ConfigFlowResult:
"""Reauth in case of a password change or other error."""
self._reauth_entry = self.hass.config_entries.async_get_entry(
self.context["entry_id"]

View File

@ -7,9 +7,8 @@ from lmcloud import LMCloud as LaMarzoccoClient
from lmcloud.exceptions import AuthFail, RequestNotSuccessful
import voluptuous as vol
from homeassistant.config_entries import ConfigEntry, ConfigFlow
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.selector import (
SelectOptionDict,
@ -35,7 +34,7 @@ class LmConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the initial step."""
errors = {}
@ -89,7 +88,7 @@ class LmConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_machine_selection(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Let user select machine to connect to."""
errors: dict[str, str] = {}
if user_input:
@ -141,7 +140,9 @@ class LmConfigFlow(ConfigFlow, domain=DOMAIN):
errors=errors,
)
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
async def async_step_reauth(
self, entry_data: Mapping[str, Any]
) -> ConfigFlowResult:
"""Perform reauth upon an API authentication error."""
self.reauth_entry = self.hass.config_entries.async_get_entry(
self.context["entry_id"]
@ -150,7 +151,7 @@ class LmConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_reauth_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Dialog that informs the user that reauth is required."""
if not user_input:
return self.async_show_form(

View File

@ -28,9 +28,9 @@ from homeassistant.components.ssdp import (
ATTR_UPNP_SERIAL,
SsdpServiceInfo,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.config_entries import ConfigEntry, ConfigFlowResult
from homeassistant.const import CONF_API_KEY, CONF_DEVICE, CONF_HOST, CONF_MAC
from homeassistant.data_entry_flow import AbortFlow, FlowResult
from homeassistant.data_entry_flow import AbortFlow
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.config_entry_oauth2_flow import AbstractOAuth2FlowHandler
from homeassistant.helpers.device_registry import format_mac
@ -72,11 +72,13 @@ class LaMetricFlowHandler(AbstractOAuth2FlowHandler, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initiated by the user."""
return await self.async_step_choice_enter_manual_or_fetch_cloud()
async def async_step_ssdp(self, discovery_info: SsdpServiceInfo) -> FlowResult:
async def async_step_ssdp(
self, discovery_info: SsdpServiceInfo
) -> ConfigFlowResult:
"""Handle a flow initiated by SSDP discovery."""
url = URL(discovery_info.ssdp_location or "")
if url.host is None or not (
@ -106,7 +108,9 @@ class LaMetricFlowHandler(AbstractOAuth2FlowHandler, domain=DOMAIN):
self.discovered_serial = serial
return await self.async_step_choice_enter_manual_or_fetch_cloud()
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
async def async_step_reauth(
self, entry_data: Mapping[str, Any]
) -> ConfigFlowResult:
"""Handle initiation of re-authentication with LaMetric."""
self.reauth_entry = self.hass.config_entries.async_get_entry(
self.context["entry_id"]
@ -115,7 +119,7 @@ class LaMetricFlowHandler(AbstractOAuth2FlowHandler, domain=DOMAIN):
async def async_step_choice_enter_manual_or_fetch_cloud(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the user's choice.
Either enter the manual credentials or fetch the cloud credentials.
@ -127,7 +131,7 @@ class LaMetricFlowHandler(AbstractOAuth2FlowHandler, domain=DOMAIN):
async def async_step_manual_entry(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the user's choice of entering the device manually."""
errors: dict[str, str] = {}
if user_input is not None:
@ -166,7 +170,9 @@ class LaMetricFlowHandler(AbstractOAuth2FlowHandler, domain=DOMAIN):
errors=errors,
)
async def async_step_cloud_fetch_devices(self, data: dict[str, Any]) -> FlowResult:
async def async_step_cloud_fetch_devices(
self, data: dict[str, Any]
) -> ConfigFlowResult:
"""Fetch information about devices from the cloud."""
lametric = LaMetricCloud(
token=data["token"]["access_token"],
@ -184,7 +190,7 @@ class LaMetricFlowHandler(AbstractOAuth2FlowHandler, domain=DOMAIN):
async def async_step_cloud_select_device(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle device selection from devices offered by the cloud."""
if self.discovered:
user_input = {CONF_DEVICE: self.discovered_serial}
@ -232,7 +238,9 @@ class LaMetricFlowHandler(AbstractOAuth2FlowHandler, domain=DOMAIN):
errors=errors,
)
async def _async_step_create_entry(self, host: str, api_key: str) -> FlowResult:
async def _async_step_create_entry(
self, host: str, api_key: str
) -> ConfigFlowResult:
"""Create entry."""
lametric = LaMetricDevice(
host=host,
@ -287,7 +295,9 @@ class LaMetricFlowHandler(AbstractOAuth2FlowHandler, domain=DOMAIN):
},
)
async def async_step_dhcp(self, discovery_info: DhcpServiceInfo) -> FlowResult:
async def async_step_dhcp(
self, discovery_info: DhcpServiceInfo
) -> ConfigFlowResult:
"""Handle dhcp discovery to update existing entries."""
mac = format_mac(discovery_info.macaddress)
for entry in self._async_current_entries():

View File

@ -10,11 +10,10 @@ from serial.tools import list_ports
import ultraheat_api
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import usb
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_DEVICE
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResult
from homeassistant.exceptions import HomeAssistantError
from .const import DOMAIN, ULTRAHEAT_TIMEOUT
@ -30,14 +29,14 @@ STEP_USER_DATA_SCHEMA = vol.Schema(
)
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class LandisgyrConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Ultraheat Heat Meter."""
VERSION = 2
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Step when setting up serial configuration."""
errors = {}
@ -63,7 +62,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_setup_serial_manual_path(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Set path manually."""
errors = {}

View File

@ -9,11 +9,11 @@ import voluptuous as vol
from homeassistant.config_entries import (
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlowWithConfigEntry,
)
from homeassistant.const import CONF_API_KEY
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.selector import (
SelectOptionDict,
SelectSelector,
@ -83,7 +83,7 @@ class LastFmConfigFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Initialize user input."""
errors: dict[str, str] = {}
if user_input is not None:
@ -102,7 +102,7 @@ class LastFmConfigFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_friends(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Form to select other users and friends."""
errors: dict[str, str] = {}
if user_input is not None:
@ -159,7 +159,7 @@ class LastFmOptionsFlowHandler(OptionsFlowWithConfigEntry):
async def async_step_init(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Initialize form."""
errors: dict[str, str] = {}
if user_input is not None:

View File

@ -3,20 +3,19 @@ from __future__ import annotations
from typing import Any
from homeassistant import config_entries
from homeassistant.data_entry_flow import FlowResult
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from .const import DOMAIN
class LaunchLibraryFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class LaunchLibraryFlowHandler(ConfigFlow, domain=DOMAIN):
"""Config flow for Launch Library component."""
VERSION = 1
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initialized by the user."""
# Check if already configured
if self._async_current_entries():

View File

@ -13,9 +13,8 @@ from laundrify_aio.exceptions import (
)
from voluptuous import Required, Schema
from homeassistant.config_entries import ConfigFlow
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_CODE
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import DOMAIN
@ -32,13 +31,13 @@ class LaundrifyConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initialized by the user."""
return await self.async_step_init(user_input)
async def async_step_init(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the initial step."""
if user_input is None:
return self.async_show_form(step_id="init", data_schema=CONFIG_SCHEMA)
@ -77,13 +76,15 @@ class LaundrifyConfigFlow(ConfigFlow, domain=DOMAIN):
step_id="init", data_schema=CONFIG_SCHEMA, errors=errors
)
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
async def async_step_reauth(
self, entry_data: Mapping[str, Any]
) -> ConfigFlowResult:
"""Perform reauth upon an API authentication error."""
return await self.async_step_reauth_confirm()
async def async_step_reauth_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Dialog that informs the user that reauth is required."""
if user_input is None:
return self.async_show_form(

View File

@ -5,7 +5,12 @@ import logging
import pypck
from homeassistant import config_entries
from homeassistant.config_entries import (
SOURCE_IMPORT,
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
)
from homeassistant.const import (
CONF_HOST,
CONF_IP_ADDRESS,
@ -14,7 +19,6 @@ from homeassistant.const import (
CONF_USERNAME,
)
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.typing import ConfigType
from .const import CONF_DIM_MODE, CONF_SK_NUM_TRIES, DOMAIN
@ -23,9 +27,7 @@ from .helpers import purge_device_registry, purge_entity_registry
_LOGGER = logging.getLogger(__name__)
def get_config_entry(
hass: HomeAssistant, data: ConfigType
) -> config_entries.ConfigEntry | None:
def get_config_entry(hass: HomeAssistant, data: ConfigType) -> ConfigEntry | None:
"""Check config entries for already configured entries based on the ip address/port."""
return next(
(
@ -65,12 +67,12 @@ async def validate_connection(host_name: str, data: ConfigType) -> ConfigType:
return data
class LcnFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class LcnFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a LCN config flow."""
VERSION = 1
async def async_step_import(self, data: ConfigType) -> FlowResult:
async def async_step_import(self, data: ConfigType) -> ConfigFlowResult:
"""Import existing configuration from LCN."""
host_name = data[CONF_HOST]
# validate the imported connection parameters
@ -94,7 +96,7 @@ class LcnFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
# check if we already have a host with the same address configured
if entry := get_config_entry(self.hass, data):
entry.source = config_entries.SOURCE_IMPORT
entry.source = SOURCE_IMPORT
# Cleanup entity and device registry, if we imported from configuration.yaml to
# remove orphans when entities were removed from configuration
purge_entity_registry(self.hass, entry.entry_id, data)

View File

@ -8,20 +8,19 @@ from bluetooth_data_tools import human_readable_name
from ld2410_ble import BLEAK_EXCEPTIONS, LD2410BLE
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components.bluetooth import (
BluetoothServiceInfoBleak,
async_discovered_service_info,
)
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_ADDRESS
from homeassistant.data_entry_flow import FlowResult
from .const import DOMAIN, LOCAL_NAMES
_LOGGER = logging.getLogger(__name__)
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class Ld2410BleConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for LD2410 BLE."""
VERSION = 1
@ -33,7 +32,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_bluetooth(
self, discovery_info: BluetoothServiceInfoBleak
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the bluetooth discovery step."""
await self.async_set_unique_id(discovery_info.address)
self._abort_if_unique_id_configured()
@ -47,7 +46,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the user step to pick discovered device."""
errors: dict[str, str] = {}

View File

@ -7,9 +7,8 @@ from leaone_ble import LeaoneBluetoothDeviceData as DeviceData
import voluptuous as vol
from homeassistant.components.bluetooth import async_discovered_service_info
from homeassistant.config_entries import ConfigFlow
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_ADDRESS
from homeassistant.data_entry_flow import FlowResult
from .const import DOMAIN
@ -25,7 +24,7 @@ class LeaoneConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the user step to pick discovered device."""
if user_input is not None:
address = user_input[CONF_ADDRESS]

View File

@ -8,20 +8,19 @@ from bluetooth_data_tools import human_readable_name
from led_ble import BLEAK_EXCEPTIONS, LEDBLE
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components.bluetooth import (
BluetoothServiceInfoBleak,
async_discovered_service_info,
)
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_ADDRESS
from homeassistant.data_entry_flow import FlowResult
from .const import DOMAIN, LOCAL_NAMES, UNSUPPORTED_SUB_MODEL
_LOGGER = logging.getLogger(__name__)
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class LedBleConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Yale Access Bluetooth."""
VERSION = 1
@ -33,7 +32,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_bluetooth(
self, discovery_info: BluetoothServiceInfoBleak
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the bluetooth discovery step."""
if discovery_info.name.startswith(UNSUPPORTED_SUB_MODEL):
# These versions speak a different protocol
@ -51,7 +50,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the user step to pick discovered device."""
errors: dict[str, str] = {}

View File

@ -5,9 +5,8 @@ from queue import Empty, Full, Queue
import temescal
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_HOST, CONF_PORT
from homeassistant.data_entry_flow import FlowResult
from .const import DEFAULT_PORT, DOMAIN
@ -67,12 +66,12 @@ def test_connect(host, port):
return details
class LGSoundbarConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class LGSoundbarConfigFlow(ConfigFlow, domain=DOMAIN):
"""LG Soundbar config flow."""
VERSION = 1
async def async_step_user(self, user_input=None) -> FlowResult:
async def async_step_user(self, user_input=None) -> ConfigFlowResult:
"""Handle a flow initiated by the user."""
if user_input is None:
return self._show_form()

View File

@ -9,10 +9,9 @@ from aiopyarr import exceptions
from aiopyarr.lidarr_client import LidarrClient
import voluptuous as vol
from homeassistant.config_entries import ConfigEntry, ConfigFlow
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_API_KEY, CONF_URL, CONF_VERIFY_SSL
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import DEFAULT_NAME, DOMAIN
@ -27,7 +26,9 @@ class LidarrConfigFlow(ConfigFlow, domain=DOMAIN):
"""Initialize the flow."""
self.entry: ConfigEntry | None = None
async def async_step_reauth(self, user_input: Mapping[str, Any]) -> FlowResult:
async def async_step_reauth(
self, user_input: Mapping[str, Any]
) -> ConfigFlowResult:
"""Handle configuration by re-auth."""
self.entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
@ -35,7 +36,7 @@ class LidarrConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_reauth_confirm(
self, user_input: dict[str, str] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Confirm reauth dialog."""
if user_input is not None:
return await self.async_step_user()
@ -45,7 +46,7 @@ class LidarrConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initiated by the user."""
errors = {}

View File

@ -8,12 +8,11 @@ from aiolifx.aiolifx import Light
from aiolifx.connection import LIFXConnection
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import zeroconf
from homeassistant.components.dhcp import DhcpServiceInfo
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_DEVICE, CONF_HOST
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import device_registry as dr
from homeassistant.helpers.typing import DiscoveryInfoType
@ -36,7 +35,7 @@ from .util import (
)
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class LifXConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for LIFX."""
VERSION = 1
@ -46,7 +45,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
self._discovered_devices: dict[str, Light] = {}
self._discovered_device: Light | None = None
async def async_step_dhcp(self, discovery_info: DhcpServiceInfo) -> FlowResult:
async def async_step_dhcp(
self, discovery_info: DhcpServiceInfo
) -> ConfigFlowResult:
"""Handle discovery via DHCP."""
mac = discovery_info.macaddress
host = discovery_info.ip
@ -69,13 +70,13 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_homekit(
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle HomeKit discovery."""
return await self._async_handle_discovery(host=discovery_info.host)
async def async_step_integration_discovery(
self, discovery_info: DiscoveryInfoType
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle LIFX UDP broadcast discovery."""
serial = discovery_info[CONF_SERIAL]
host = discovery_info[CONF_HOST]
@ -85,7 +86,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def _async_handle_discovery(
self, host: str, serial: str | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle any discovery."""
self._async_abort_entries_match({CONF_HOST: host})
self.context[CONF_HOST] = host
@ -120,7 +121,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_discovery_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Confirm discovery."""
assert self._discovered_device is not None
discovered = self._discovered_device
@ -146,7 +147,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the initial step."""
errors = {}
if user_input is not None:
@ -168,7 +169,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_pick_device(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the step to pick discovered device."""
if user_input is not None:
serial = user_input[CONF_DEVICE]
@ -207,7 +208,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
)
@callback
def _async_create_entry_from_device(self, device: Light) -> FlowResult:
def _async_create_entry_from_device(self, device: Light) -> ConfigFlowResult:
"""Create a config entry from a smart device."""
self._abort_if_unique_id_configured(updates={CONF_HOST: device.ip_addr})
return self.async_create_entry(

View File

@ -10,10 +10,9 @@ from linear_garage_door import Linear
from linear_garage_door.errors import InvalidLoginError
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResult
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.aiohttp_client import async_get_clientsession
@ -63,7 +62,7 @@ async def validate_input(
return info
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class LinearGarageDoorConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Linear Garage Door."""
VERSION = 1
@ -71,11 +70,11 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
def __init__(self) -> None:
"""Initialize the config flow."""
self.data: dict[str, Sequence[Collection[str]]] = {}
self._reauth_entry: config_entries.ConfigEntry | None = None
self._reauth_entry: ConfigEntry | None = None
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the initial step."""
data_schema = STEP_USER_DATA_SCHEMA
@ -115,7 +114,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_site(
self,
user_input: dict[str, Any] | None = None,
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the site step."""
if isinstance(self.data["sites"], list):
@ -150,7 +149,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
},
)
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
async def async_step_reauth(
self, entry_data: Mapping[str, Any]
) -> ConfigFlowResult:
"""Reauth in case of a password change or other error."""
self._reauth_entry = self.hass.config_entries.async_get_entry(
self.context["entry_id"]

View File

@ -7,25 +7,29 @@ import pylitejet
from serial import SerialException
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import (
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.const import CONF_PORT
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
import homeassistant.helpers.config_validation as cv
from .const import CONF_DEFAULT_TRANSITION, DOMAIN
class LiteJetOptionsFlow(config_entries.OptionsFlow):
class LiteJetOptionsFlow(OptionsFlow):
"""Handle LiteJet options."""
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
def __init__(self, config_entry: ConfigEntry) -> None:
"""Initialize LiteJet options flow."""
self.config_entry = config_entry
async def async_step_init(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Manage LiteJet options."""
if user_input is not None:
return self.async_create_entry(title="", data=user_input)
@ -45,12 +49,12 @@ class LiteJetOptionsFlow(config_entries.OptionsFlow):
)
class LiteJetConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class LiteJetConfigFlow(ConfigFlow, domain=DOMAIN):
"""LiteJet config flow."""
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Create a LiteJet config entry based upon user input."""
if self._async_current_entries():
return self.async_abort(reason="single_instance_allowed")
@ -79,7 +83,7 @@ class LiteJetConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
@staticmethod
@callback
def async_get_options_flow(
config_entry: config_entries.ConfigEntry,
config_entry: ConfigEntry,
) -> LiteJetOptionsFlow:
"""Get the options flow for this handler."""
return LiteJetOptionsFlow(config_entry)

View File

@ -9,9 +9,8 @@ from pylitterbot import Account
from pylitterbot.exceptions import LitterRobotException, LitterRobotLoginException
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import DOMAIN
@ -23,21 +22,23 @@ STEP_USER_DATA_SCHEMA = vol.Schema(
)
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class LitterRobotConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Litter-Robot."""
VERSION = 1
username: str
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
async def async_step_reauth(
self, entry_data: Mapping[str, Any]
) -> ConfigFlowResult:
"""Handle a reauthorization flow request."""
self.username = entry_data[CONF_USERNAME]
return await self.async_step_reauth_confirm()
async def async_step_reauth_confirm(
self, user_input: dict[str, str] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle user's reauth credentials."""
errors = {}
if user_input:
@ -62,7 +63,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: Mapping[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the initial step."""
errors = {}

View File

@ -8,15 +8,14 @@ from aiohttp import ClientConnectorError
from aiolivisi import AioLivisi, errors as livisi_errors
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_HOST, CONF_PASSWORD
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import aiohttp_client
from .const import DOMAIN, LOGGER
class LivisiFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class LivisiFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a Livisi Smart Home config flow."""
def __init__(self) -> None:
@ -31,7 +30,7 @@ class LivisiFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, str] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the initial step."""
if user_input is None:
return self.async_show_form(step_id="user", data_schema=self.data_schema)
@ -70,7 +69,7 @@ class LivisiFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def create_entity(
self, user_input: dict[str, str], controller_info: dict[str, Any]
) -> FlowResult:
) -> ConfigFlowResult:
"""Create LIVISI entity."""
if (controller_data := controller_info.get("gateway")) is None:
controller_data = controller_info

View File

@ -5,8 +5,7 @@ from typing import Any
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.data_entry_flow import FlowResult
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.util import slugify
from .const import CONF_CALENDAR_NAME, CONF_STORAGE_KEY, DOMAIN
@ -18,14 +17,14 @@ STEP_USER_DATA_SCHEMA = vol.Schema(
)
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class LocalCalendarConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Local Calendar."""
VERSION = 1
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the initial step."""
if user_input is None:
return self.async_show_form(

View File

@ -3,8 +3,7 @@ from __future__ import annotations
from typing import Any
from homeassistant.config_entries import ConfigFlow
from homeassistant.data_entry_flow import FlowResult
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from .const import DOMAIN
@ -14,7 +13,7 @@ class SimpleConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the initial step."""
if self._async_current_entries():
return self.async_abort(reason="single_instance_allowed")

View File

@ -6,8 +6,7 @@ from typing import Any
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.data_entry_flow import FlowResult
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.util import slugify
from .const import CONF_STORAGE_KEY, CONF_TODO_LIST_NAME, DOMAIN
@ -21,14 +20,14 @@ STEP_USER_DATA_SCHEMA = vol.Schema(
)
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class LocalTodoConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Local To-do."""
VERSION = 1
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the initial step."""
errors: dict[str, str] = {}
if user_input is not None:

View File

@ -7,8 +7,8 @@ from logi_circle import LogiCircle
from logi_circle.exception import AuthorizationFailed
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components.http import HomeAssistantView
from homeassistant.config_entries import ConfigFlow
from homeassistant.const import (
CONF_API_KEY,
CONF_CLIENT_ID,
@ -53,7 +53,7 @@ def register_flow_implementation(
}
class LogiCircleFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class LogiCircleFlowHandler(ConfigFlow, domain=DOMAIN):
"""Config flow for Logi Circle component."""
VERSION = 1

View File

@ -8,10 +8,9 @@ import aiohttp
from aiolookin import Device, LookInHttpProtocol, NoUsableService
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import zeroconf
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_HOST
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import DOMAIN
@ -19,7 +18,7 @@ from .const import DOMAIN
LOGGER = logging.getLogger(__name__)
class LookinFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class LookinFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for lookin."""
def __init__(self) -> None:
@ -29,7 +28,7 @@ class LookinFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_zeroconf(
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
) -> ConfigFlowResult:
"""Start a discovery flow from zeroconf."""
uid: str = discovery_info.hostname.removesuffix(".local.")
host: str = discovery_info.host
@ -52,7 +51,7 @@ class LookinFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""User initiated discover flow."""
errors: dict[str, str] = {}
@ -88,7 +87,7 @@ class LookinFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_discovery_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Confirm the discover flow."""
assert self._host is not None
if user_input is None:

View File

@ -9,12 +9,11 @@ import aiohttp
from loqedAPI import cloud_loqed, loqed
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import webhook
from homeassistant.components.zeroconf import ZeroconfServiceInfo
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_API_TOKEN, CONF_NAME, CONF_WEBHOOK_ID
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResult
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.aiohttp_client import async_get_clientsession
@ -23,7 +22,7 @@ from .const import DOMAIN
_LOGGER = logging.getLogger(__name__)
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class LoqedConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Loqed."""
VERSION = 1
@ -83,7 +82,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_zeroconf(
self, discovery_info: ZeroconfServiceInfo
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle zeroconf discovery."""
host = discovery_info.host
self._host = host
@ -101,7 +100,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Show userform to user."""
user_data_schema = (
vol.Schema(

View File

@ -7,22 +7,21 @@ from luftdaten import Luftdaten
from luftdaten.exceptions import LuftdatenConnectionError
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_SHOW_ON_MAP
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
import homeassistant.helpers.config_validation as cv
from .const import CONF_SENSOR_ID, DOMAIN
class SensorCommunityFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class SensorCommunityFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a Sensor.Community config flow."""
VERSION = 1
@callback
def _show_form(self, errors: dict[str, str] | None = None) -> FlowResult:
def _show_form(self, errors: dict[str, str] | None = None) -> ConfigFlowResult:
"""Show the form to the user."""
return self.async_show_form(
step_id="user",
@ -37,7 +36,7 @@ class SensorCommunityFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the start of the config flow."""
if user_input is None:
return self._show_form()

View File

@ -16,7 +16,6 @@ from homeassistant.const import (
CONF_USERNAME,
)
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResult
from homeassistant.exceptions import HomeAssistantError
from .const import DOMAIN
@ -37,7 +36,7 @@ class LupusecConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> config_entries.ConfigFlowResult:
"""Handle a flow initiated by the user."""
errors = {}
@ -67,7 +66,9 @@ class LupusecConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
step_id="user", data_schema=DATA_SCHEMA, errors=errors
)
async def async_step_import(self, user_input: dict[str, Any]) -> FlowResult:
async def async_step_import(
self, user_input: dict[str, Any]
) -> config_entries.ConfigFlowResult:
"""Import the yaml config."""
self._async_abort_entries_match(
{

View File

@ -8,9 +8,8 @@ from urllib.error import HTTPError
from pylutron import Lutron
import voluptuous as vol
from homeassistant.config_entries import ConfigFlow
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME
from homeassistant.data_entry_flow import FlowResult
from .const import DOMAIN
@ -24,7 +23,7 @@ class LutronConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""First step in the config flow."""
# Check if a configuration entry already exists
@ -74,7 +73,9 @@ class LutronConfigFlow(ConfigFlow, domain=DOMAIN):
errors=errors,
)
async def async_step_import(self, import_config: dict[str, Any]) -> FlowResult:
async def async_step_import(
self, import_config: dict[str, Any]
) -> ConfigFlowResult:
"""Attempt to import the existing configuration."""
if self._async_current_entries():
return self.async_abort(reason="single_instance_allowed")

View File

@ -10,11 +10,10 @@ from pylutron_caseta.pairing import PAIR_CA, PAIR_CERT, PAIR_KEY, async_pair
from pylutron_caseta.smartbridge import Smartbridge
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import zeroconf
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_HOST, CONF_NAME
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from .const import (
ABORT_REASON_CANNOT_CONNECT,
@ -45,7 +44,7 @@ DATA_SCHEMA_USER = vol.Schema({vol.Required(CONF_HOST): str})
TLS_ASSET_TEMPLATE = "lutron_caseta-{}-{}.pem"
class LutronCasetaFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class LutronCasetaFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle Lutron Caseta config flow."""
VERSION = 1
@ -67,7 +66,7 @@ class LutronCasetaFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_zeroconf(
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initialized by zeroconf discovery."""
hostname = discovery_info.hostname
if hostname is None or not hostname.lower().startswith("lutron-"):
@ -88,7 +87,7 @@ class LutronCasetaFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_homekit(
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initialized by homekit discovery."""
return await self.async_step_zeroconf(discovery_info)

View File

@ -5,7 +5,7 @@ from collections.abc import Mapping
import logging
from typing import Any
from homeassistant.data_entry_flow import FlowResult
from homeassistant.config_entries import ConfigFlowResult
from homeassistant.helpers import config_entry_oauth2_flow
from .const import DOMAIN
@ -23,19 +23,21 @@ class OAuth2FlowHandler(
"""Return logger."""
return logging.getLogger(__name__)
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
async def async_step_reauth(
self, entry_data: Mapping[str, Any]
) -> ConfigFlowResult:
"""Perform reauth upon an API authentication error."""
return await self.async_step_reauth_confirm()
async def async_step_reauth_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Dialog that informs the user that reauth is required."""
if user_input is None:
return self.async_show_form(step_id="reauth_confirm")
return await self.async_step_user()
async def async_oauth_create_entry(self, data: dict[str, Any]) -> FlowResult:
async def async_oauth_create_entry(self, data: dict[str, Any]) -> ConfigFlowResult:
"""Create an oauth config entry or update existing entry for reauth."""
existing_entry = await self.async_set_unique_id(DOMAIN)
if existing_entry:

View File

@ -8,7 +8,6 @@ from matter_server.client import MatterClient
from matter_server.client.exceptions import CannotConnect, InvalidServerVersion
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components.hassio import (
AddonError,
AddonInfo,
@ -17,9 +16,10 @@ from homeassistant.components.hassio import (
HassioServiceInfo,
is_hassio,
)
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_URL
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import AbortFlow, FlowResult
from homeassistant.data_entry_flow import AbortFlow
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import aiohttp_client
@ -56,7 +56,7 @@ def build_ws_address(host: str, port: int) -> str:
return f"ws://{host}:{port}/ws"
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class MatterConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Matter."""
VERSION = 1
@ -72,7 +72,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_install_addon(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Install Matter Server add-on."""
if not self.install_task:
self.install_task = self.hass.async_create_task(self._async_install_addon())
@ -98,7 +98,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_install_failed(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Add-on installation failed."""
return self.async_abort(reason="addon_install_failed")
@ -120,7 +120,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_start_addon(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Start Matter Server add-on."""
if not self.start_task:
self.start_task = self.hass.async_create_task(self._async_start_addon())
@ -143,7 +143,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_start_failed(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Add-on start failed."""
return self.async_abort(reason="addon_start_failed")
@ -186,7 +186,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the initial step."""
if is_hassio(self.hass):
return await self.async_step_on_supervisor()
@ -195,7 +195,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_manual(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a manual configuration."""
if user_input is None:
return self.async_show_form(
@ -222,7 +222,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
step_id="manual", data_schema=get_manual_schema(user_input), errors=errors
)
async def async_step_hassio(self, discovery_info: HassioServiceInfo) -> FlowResult:
async def async_step_hassio(
self, discovery_info: HassioServiceInfo
) -> ConfigFlowResult:
"""Receive configuration from add-on discovery info.
This flow is triggered by the Matter Server add-on.
@ -240,7 +242,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_hassio_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Confirm the add-on discovery."""
if user_input is not None:
return await self.async_step_on_supervisor(
@ -251,7 +253,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_on_supervisor(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle logic when on Supervisor host."""
if user_input is None:
return self.async_show_form(
@ -274,7 +276,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_finish_addon_setup(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Prepare info needed to complete the config entry."""
if not self.ws_address:
discovery_info = await self._async_get_addon_discovery_info()
@ -289,7 +291,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
return await self._async_create_entry_or_abort()
async def _async_create_entry_or_abort(self) -> FlowResult:
async def _async_create_entry_or_abort(self) -> ConfigFlowResult:
"""Return a config entry for the flow or abort if already configured."""
assert self.ws_address is not None

View File

@ -7,9 +7,8 @@ from typing import Any
from meater import AuthenticationError, MeaterApi, ServiceUnavailableError
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import aiohttp_client
from .const import DOMAIN
@ -20,7 +19,7 @@ USER_SCHEMA = vol.Schema(
)
class MeaterConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class MeaterConfigFlow(ConfigFlow, domain=DOMAIN):
"""Meater Config Flow."""
_data_schema = USER_SCHEMA
@ -28,7 +27,7 @@ class MeaterConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, str] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Define the login user step."""
if user_input is None:
return self.async_show_form(
@ -45,7 +44,9 @@ class MeaterConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
return await self._try_connect_meater("user", None, username, password)
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
async def async_step_reauth(
self, entry_data: Mapping[str, Any]
) -> ConfigFlowResult:
"""Handle configuration by re-auth."""
self._data_schema = REAUTH_SCHEMA
self._username = entry_data[CONF_USERNAME]
@ -53,7 +54,7 @@ class MeaterConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_reauth_confirm(
self, user_input: dict[str, str] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle re-auth completion."""
placeholders = {"username": self._username}
if not user_input:
@ -70,7 +71,7 @@ class MeaterConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def _try_connect_meater(
self, step_id, placeholders: dict[str, str] | None, username: str, password: str
) -> FlowResult:
) -> ConfigFlowResult:
session = aiohttp_client.async_get_clientsession(self.hass)
api = MeaterApi(session)

View File

@ -16,9 +16,9 @@ from homeassistant.components.bluetooth import (
BluetoothServiceInfo,
async_discovered_service_info,
)
from homeassistant.config_entries import ConfigFlow
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_ADDRESS
from homeassistant.data_entry_flow import AbortFlow, FlowResult
from homeassistant.data_entry_flow import AbortFlow
from .const import DOMAIN
@ -51,7 +51,7 @@ class InspectorBLEConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_bluetooth(
self, discovery_info: BluetoothServiceInfo
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the bluetooth discovery step."""
_LOGGER.debug("Discovered BLE device: %s", discovery_info.name)
await self.async_set_unique_id(discovery_info.address)
@ -67,7 +67,7 @@ class InspectorBLEConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_bluetooth_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Confirm discovery."""
# We always will have self._discovery_info be a BluetoothServiceInfo at this point
# and this helps mypy not complain
@ -84,7 +84,7 @@ class InspectorBLEConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the user step to pick discovered device."""
if user_input is not None:
address = user_input[CONF_ADDRESS]
@ -123,7 +123,7 @@ class InspectorBLEConfigFlow(ConfigFlow, domain=DOMAIN):
),
)
async def async_step_check_connection(self) -> FlowResult:
async def async_step_check_connection(self) -> ConfigFlowResult:
"""Check we can connect to the device before considering the configuration is successful."""
# We always will have self._discovery_info be a BluetoothServiceInfo at this point
# and this helps mypy not complain

View File

@ -11,9 +11,8 @@ from aiohttp import ClientError, ClientResponseError
import pymelcloud
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_PASSWORD, CONF_TOKEN, CONF_USERNAME
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import DOMAIN
@ -21,14 +20,14 @@ from .const import DOMAIN
_LOGGER = logging.getLogger(__name__)
class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class FlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a config flow."""
VERSION = 1
entry: config_entries.ConfigEntry | None = None
entry: ConfigEntry | None = None
async def _create_entry(self, username: str, token: str) -> FlowResult:
async def _create_entry(self, username: str, token: str) -> ConfigFlowResult:
"""Register new entry."""
await self.async_set_unique_id(username)
self._abort_if_unique_id_configured({CONF_TOKEN: token})
@ -42,7 +41,7 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
*,
password: str | None = None,
token: str | None = None,
) -> FlowResult:
) -> ConfigFlowResult:
"""Create client."""
try:
async with asyncio.timeout(10):
@ -67,7 +66,7 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""User initiated config flow."""
if user_input is None:
return self.async_show_form(
@ -79,14 +78,16 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
username = user_input[CONF_USERNAME]
return await self._create_client(username, password=user_input[CONF_PASSWORD])
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
async def async_step_reauth(
self, entry_data: Mapping[str, Any]
) -> ConfigFlowResult:
"""Handle initiation of re-authentication with MELCloud."""
self.entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
return await self.async_step_reauth_confirm()
async def async_step_reauth_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle re-authentication with MELCloud."""
errors: dict[str, str] = {}

View File

@ -6,16 +6,15 @@ from typing import Any
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components.bluetooth import async_discovered_service_info
from homeassistant.components.bluetooth.models import BluetoothServiceInfoBleak
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_ADDRESS
from homeassistant.data_entry_flow import FlowResult
from .const import DOMAIN, MANUFACTURER_DATA_START, MANUFACTURER_ID
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class MelnorConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for melnor."""
VERSION = 1
@ -25,7 +24,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
self._discovered_address: str
self._discovered_addresses: list[str] = []
def _create_entry(self, address: str) -> FlowResult:
def _create_entry(self, address: str) -> ConfigFlowResult:
"""Create an entry for a discovered device."""
return self.async_create_entry(
@ -37,7 +36,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_bluetooth_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle user-confirmation of discovered device."""
if user_input is not None:
@ -50,7 +49,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_bluetooth(
self, discovery_info: BluetoothServiceInfoBleak
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initialized by Bluetooth discovery."""
address = discovery_info.address
@ -65,7 +64,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_pick_device(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the step to pick discovered device."""
if user_input is not None:
@ -108,7 +107,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initialized by the user."""
return await self.async_step_pick_device()

View File

@ -5,8 +5,13 @@ from typing import Any
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import OptionsFlowWithConfigEntry
from homeassistant.config_entries import (
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
OptionsFlowWithConfigEntry,
)
from homeassistant.const import (
CONF_ELEVATION,
CONF_LATITUDE,
@ -15,7 +20,6 @@ from homeassistant.const import (
UnitOfLength,
)
from homeassistant.core import HomeAssistant, callback
from homeassistant.data_entry_flow import FlowResult
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.selector import (
NumberSelector,
@ -47,7 +51,7 @@ def configured_instances(hass: HomeAssistant) -> set[str]:
def _get_data_schema(
hass: HomeAssistant, config_entry: config_entries.ConfigEntry | None = None
hass: HomeAssistant, config_entry: ConfigEntry | None = None
) -> vol.Schema:
"""Get a schema with default values."""
# If tracking home or no config entry is passed in, default value come from Home location
@ -91,14 +95,14 @@ def _get_data_schema(
)
class MetConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class MetConfigFlowHandler(ConfigFlow, domain=DOMAIN):
"""Config flow for Met component."""
VERSION = 1
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initialized by the user."""
errors = {}
@ -120,7 +124,7 @@ class MetConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_onboarding(
self, data: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initialized by onboarding."""
# Don't create entry if latitude or longitude isn't set.
# Also, filters out our onboarding default location.
@ -137,8 +141,8 @@ class MetConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
@staticmethod
@callback
def async_get_options_flow(
config_entry: config_entries.ConfigEntry,
) -> config_entries.OptionsFlow:
config_entry: ConfigEntry,
) -> OptionsFlow:
"""Get the options flow for Met."""
return MetOptionsFlowHandler(config_entry)
@ -148,7 +152,7 @@ class MetOptionsFlowHandler(OptionsFlowWithConfigEntry):
async def async_step_init(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Configure options for Met."""
if user_input is not None:

View File

@ -3,22 +3,21 @@ from typing import Any
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_ELEVATION, CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME
from homeassistant.data_entry_flow import FlowResult
import homeassistant.helpers.config_validation as cv
from .const import DOMAIN, HOME_LOCATION_NAME
class MetEireannFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class MetEireannFlowHandler(ConfigFlow, domain=DOMAIN):
"""Config flow for Met Eireann component."""
VERSION = 1
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initialized by the user."""
if user_input is not None:
# Check if an identical entity is already configured

View File

@ -8,18 +8,16 @@ from meteofrance_api.client import MeteoFranceClient
from meteofrance_api.model import Place
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import SOURCE_IMPORT
from homeassistant.config_entries import SOURCE_IMPORT, ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from .const import CONF_CITY, DOMAIN
_LOGGER = logging.getLogger(__name__)
class MeteoFranceFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class MeteoFranceFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a Meteo-France config flow."""
VERSION = 1
@ -33,7 +31,7 @@ class MeteoFranceFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
self,
user_input: dict[str, Any] | None = None,
errors: dict[str, str] | None = None,
) -> FlowResult:
) -> ConfigFlowResult:
"""Show the setup form to the user."""
if user_input is None:
@ -49,7 +47,7 @@ class MeteoFranceFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initiated by the user."""
errors: dict[str, str] = {}
@ -83,7 +81,7 @@ class MeteoFranceFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_cities(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Step where the user choose the city from the API search results."""
if not user_input:
if len(self.places) > 1 and self.source != SOURCE_IMPORT:

View File

@ -5,14 +5,14 @@ from meteoclimatic import MeteoclimaticClient
from meteoclimatic.exceptions import MeteoclimaticError, StationNotFound
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigFlow
from .const import CONF_STATION_CODE, DOMAIN
_LOGGER = logging.getLogger(__name__)
class MeteoclimaticFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class MeteoclimaticFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a Meteoclimatic config flow."""
VERSION = 1

View File

@ -7,9 +7,10 @@ from typing import Any
import datapoint
import voluptuous as vol
from homeassistant import config_entries, core, exceptions
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME
from homeassistant.data_entry_flow import FlowResult
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import config_validation as cv
from .const import DOMAIN
@ -18,9 +19,7 @@ from .helpers import fetch_site
_LOGGER = logging.getLogger(__name__)
async def validate_input(
hass: core.HomeAssistant, data: dict[str, Any]
) -> dict[str, str]:
async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> dict[str, str]:
"""Validate that the user input allows us to connect to DataPoint.
Data has the keys from DATA_SCHEMA with values provided by the user.
@ -41,14 +40,14 @@ async def validate_input(
return {"site_name": site.name}
class MetOfficeConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class MetOfficeConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Met Office weather integration."""
VERSION = 1
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the initial step."""
errors = {}
if user_input is not None:
@ -87,5 +86,5 @@ class MetOfficeConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
)
class CannotConnect(exceptions.HomeAssistantError):
class CannotConnect(HomeAssistantError):
"""Error to indicate we cannot connect."""

View File

@ -7,7 +7,6 @@ from microBeesPy import MicroBees, MicroBeesException
from homeassistant import config_entries
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_TOKEN
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import aiohttp_client, config_entry_oauth2_flow
from .const import DOMAIN
@ -32,7 +31,9 @@ class OAuth2FlowHandler(
scopes = ["read", "write"]
return {"scope": " ".join(scopes)}
async def async_oauth_create_entry(self, data: dict[str, Any]) -> FlowResult:
async def async_oauth_create_entry(
self, data: dict[str, Any]
) -> config_entries.ConfigFlowResult:
"""Create an oauth config entry or update existing entry for reauth."""
microbees = MicroBees(
@ -61,7 +62,9 @@ class OAuth2FlowHandler(
return self.async_abort(reason="reauth_successful")
return self.async_abort(reason="wrong_account")
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
async def async_step_reauth(
self, entry_data: Mapping[str, Any]
) -> config_entries.ConfigFlowResult:
"""Perform reauth upon an API authentication error."""
self.reauth_entry = self.hass.config_entries.async_get_entry(
self.context["entry_id"]
@ -70,7 +73,7 @@ class OAuth2FlowHandler(
async def async_step_reauth_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> config_entries.ConfigFlowResult:
"""Confirm reauth dialog."""
if user_input is None:
return self.async_show_form(step_id="reauth_confirm")

View File

@ -6,7 +6,12 @@ from typing import Any
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import (
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.const import (
CONF_HOST,
CONF_PASSWORD,
@ -15,7 +20,6 @@ from homeassistant.const import (
CONF_VERIFY_SSL,
)
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from .const import (
CONF_ARP_PING,
@ -30,23 +34,23 @@ from .errors import CannotConnect, LoginError
from .hub import get_api
class MikrotikFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class MikrotikFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a Mikrotik config flow."""
VERSION = 1
_reauth_entry: config_entries.ConfigEntry | None
_reauth_entry: ConfigEntry | None
@staticmethod
@callback
def async_get_options_flow(
config_entry: config_entries.ConfigEntry,
config_entry: ConfigEntry,
) -> MikrotikOptionsFlowHandler:
"""Get the options flow for this handler."""
return MikrotikOptionsFlowHandler(config_entry)
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initialized by the user."""
errors = {}
if user_input is not None:
@ -78,7 +82,7 @@ class MikrotikFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
errors=errors,
)
async def async_step_reauth(self, data: Mapping[str, Any]) -> FlowResult:
async def async_step_reauth(self, data: Mapping[str, Any]) -> ConfigFlowResult:
"""Perform reauth upon an API authentication error."""
self._reauth_entry = self.hass.config_entries.async_get_entry(
self.context["entry_id"]
@ -87,7 +91,7 @@ class MikrotikFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_reauth_confirm(
self, user_input: dict[str, str] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Confirm reauth dialog."""
errors = {}
assert self._reauth_entry
@ -122,22 +126,22 @@ class MikrotikFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
)
class MikrotikOptionsFlowHandler(config_entries.OptionsFlow):
class MikrotikOptionsFlowHandler(OptionsFlow):
"""Handle Mikrotik options."""
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
def __init__(self, config_entry: ConfigEntry) -> None:
"""Initialize Mikrotik options flow."""
self.config_entry = config_entry
async def async_step_init(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Manage the Mikrotik options."""
return await self.async_step_device_tracker()
async def async_step_device_tracker(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Manage the device tracker options."""
if user_input is not None:
return self.async_create_entry(title="", data=user_input)

View File

@ -3,14 +3,14 @@ from mill import Mill
from mill_local import Mill as MillLocal
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigFlow
from homeassistant.const import CONF_IP_ADDRESS, CONF_PASSWORD, CONF_USERNAME
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import CLOUD, CONNECTION_TYPE, DOMAIN, LOCAL
class MillConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class MillConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Mill integration."""
VERSION = 1

View File

@ -6,9 +6,8 @@ from typing import Any
import voluptuous as vol
from homeassistant.config_entries import ConfigFlow
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_ADDRESS, CONF_NAME, CONF_TYPE
from homeassistant.data_entry_flow import FlowResult
from .api import MinecraftServer, MinecraftServerAddressError, MinecraftServerType
from .const import DEFAULT_NAME, DOMAIN
@ -25,7 +24,7 @@ class MinecraftServerConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the initial step."""
errors: dict[str, str] = {}
@ -66,7 +65,7 @@ class MinecraftServerConfigFlow(ConfigFlow, domain=DOMAIN):
self,
user_input: dict[str, Any] | None = None,
errors: dict[str, str] | None = None,
) -> FlowResult:
) -> ConfigFlowResult:
"""Show the setup form to the user."""
if user_input is None:
user_input = {}

View File

@ -10,7 +10,12 @@ from requests.auth import HTTPBasicAuth, HTTPDigestAuth
from requests.exceptions import HTTPError, Timeout
import voluptuous as vol
from homeassistant.config_entries import ConfigEntry, ConfigFlow, OptionsFlow
from homeassistant.config_entries import (
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.const import (
CONF_AUTHENTICATION,
CONF_NAME,
@ -21,7 +26,6 @@ from homeassistant.const import (
HTTP_DIGEST_AUTHENTICATION,
)
from homeassistant.core import HomeAssistant, callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.exceptions import HomeAssistantError
from .const import CONF_MJPEG_URL, CONF_STILL_IMAGE_URL, DOMAIN, LOGGER
@ -140,7 +144,7 @@ class MJPEGFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initialized by the user."""
errors: dict[str, str] = {}
@ -184,7 +188,7 @@ class MJPEGOptionsFlowHandler(OptionsFlow):
async def async_step_init(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Manage MJPEG IP Camera options."""
errors: dict[str, str] = {}

View File

@ -10,9 +10,8 @@ from homeassistant.components.bluetooth import (
BluetoothServiceInfoBleak,
async_discovered_service_info,
)
from homeassistant.config_entries import ConfigFlow
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_ADDRESS
from homeassistant.data_entry_flow import FlowResult
from .const import DOMAIN
@ -30,7 +29,7 @@ class MoatConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_bluetooth(
self, discovery_info: BluetoothServiceInfoBleak
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the bluetooth discovery step."""
await self.async_set_unique_id(discovery_info.address)
self._abort_if_unique_id_configured()
@ -43,7 +42,7 @@ class MoatConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_bluetooth_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Confirm discovery."""
assert self._discovered_device is not None
device = self._discovered_device
@ -62,7 +61,7 @@ class MoatConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the user step to pick discovered device."""
if user_input is not None:
address = user_input[CONF_ADDRESS]

View File

@ -1,15 +1,15 @@
"""Config flow for Mobile App."""
import uuid
from homeassistant import config_entries
from homeassistant.components import person
from homeassistant.config_entries import ConfigFlow
from homeassistant.const import ATTR_DEVICE_ID
from homeassistant.helpers import entity_registry as er
from .const import ATTR_APP_ID, ATTR_DEVICE_NAME, CONF_USER_ID, DOMAIN
class MobileAppFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class MobileAppFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a Mobile App config flow."""
VERSION = 1

View File

@ -8,10 +8,9 @@ import serial.tools.list_ports
from serial.tools.list_ports_common import ListPortInfo
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import usb
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_DEVICE, CONF_NAME
from homeassistant.data_entry_flow import FlowResult
from .const import DEFAULT_NAME, DOMAIN, EXCEPTIONS
@ -23,14 +22,16 @@ def _generate_unique_id(port: ListPortInfo) -> str:
return f"{port.vid}:{port.pid}_{port.serial_number}_{port.manufacturer}_{port.description}"
class PhoneModemFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class PhoneModemFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Phone Modem."""
def __init__(self) -> None:
"""Set up flow instance."""
self._device: str | None = None
async def async_step_usb(self, discovery_info: usb.UsbServiceInfo) -> FlowResult:
async def async_step_usb(
self, discovery_info: usb.UsbServiceInfo
) -> ConfigFlowResult:
"""Handle USB Discovery."""
dev_path = discovery_info.device
unique_id = f"{discovery_info.vid}:{discovery_info.pid}_{discovery_info.serial_number}_{discovery_info.manufacturer}_{discovery_info.description}"
@ -44,7 +45,7 @@ class PhoneModemFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_usb_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle USB Discovery confirmation."""
if user_input is not None:
return self.async_create_entry(
@ -56,7 +57,7 @@ class PhoneModemFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initiated by the user."""
errors: dict[str, str] | None = {}
if self._async_in_progress():

View File

@ -7,9 +7,8 @@ from aiomodernforms import ModernFormsConnectionError, ModernFormsDevice
import voluptuous as vol
from homeassistant.components import zeroconf
from homeassistant.config_entries import SOURCE_ZEROCONF, ConfigFlow
from homeassistant.config_entries import SOURCE_ZEROCONF, ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_HOST, CONF_MAC, CONF_NAME
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import DOMAIN
@ -22,13 +21,13 @@ class ModernFormsFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle setup by user for Modern Forms integration."""
return await self._handle_config_flow(user_input)
async def async_step_zeroconf(
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle zeroconf discovery."""
host = discovery_info.hostname.rstrip(".")
name, _ = host.rsplit(".")
@ -47,13 +46,13 @@ class ModernFormsFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_zeroconf_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initiated by zeroconf."""
return await self._handle_config_flow(user_input)
async def _handle_config_flow(
self, user_input: dict[str, Any] | None = None, prepare: bool = False
) -> FlowResult:
) -> ConfigFlowResult:
"""Config flow handler for ModernForms."""
source = self.context.get("source")
@ -97,7 +96,7 @@ class ModernFormsFlowHandler(ConfigFlow, domain=DOMAIN):
data={CONF_HOST: user_input[CONF_HOST], CONF_MAC: user_input[CONF_MAC]},
)
def _show_setup_form(self, errors: dict | None = None) -> FlowResult:
def _show_setup_form(self, errors: dict | None = None) -> ConfigFlowResult:
"""Show the setup form to the user."""
return self.async_show_form(
step_id="user",
@ -105,7 +104,7 @@ class ModernFormsFlowHandler(ConfigFlow, domain=DOMAIN):
errors=errors or {},
)
def _show_confirm_dialog(self, errors: dict | None = None) -> FlowResult:
def _show_confirm_dialog(self, errors: dict | None = None) -> ConfigFlowResult:
"""Show the confirm dialog to the user."""
name = self.context.get(CONF_NAME)
return self.async_show_form(

View File

@ -6,9 +6,8 @@ import aiohttp
from moehlenhoff_alpha2 import Alpha2Base
import voluptuous as vol
from homeassistant.config_entries import ConfigFlow
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_HOST
from homeassistant.data_entry_flow import FlowResult
from .const import DOMAIN
@ -43,7 +42,7 @@ class Alpha2BaseConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initialized by the user."""
errors = {}
if user_input is not None:

View File

@ -7,8 +7,10 @@ from pymonoprice import get_monoprice
from serial import SerialException
import voluptuous as vol
from homeassistant import config_entries, core, exceptions
from homeassistant.config_entries import ConfigEntry, ConfigFlow, OptionsFlow
from homeassistant.const import CONF_PORT
from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import HomeAssistantError
from .const import (
CONF_SOURCE_1,
@ -37,7 +39,7 @@ OPTIONS_FOR_DATA = {vol.Optional(source): str for source in SOURCES}
DATA_SCHEMA = vol.Schema({vol.Required(CONF_PORT): str, **OPTIONS_FOR_DATA})
@core.callback
@callback
def _sources_from_config(data):
sources_config = {
str(idx + 1): data.get(source) for idx, source in enumerate(SOURCES)
@ -50,7 +52,7 @@ def _sources_from_config(data):
}
async def validate_input(hass: core.HomeAssistant, data):
async def validate_input(hass: HomeAssistant, data):
"""Validate the user input allows us to connect.
Data has the keys from DATA_SCHEMA with values provided by the user.
@ -67,7 +69,7 @@ async def validate_input(hass: core.HomeAssistant, data):
return {CONF_PORT: data[CONF_PORT], CONF_SOURCES: sources}
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class MonoPriceConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Monoprice 6-Zone Amplifier."""
VERSION = 1
@ -91,15 +93,15 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
)
@staticmethod
@core.callback
@callback
def async_get_options_flow(
config_entry: config_entries.ConfigEntry,
config_entry: ConfigEntry,
) -> MonopriceOptionsFlowHandler:
"""Define the config flow to handle options."""
return MonopriceOptionsFlowHandler(config_entry)
@core.callback
@callback
def _key_for_source(index, source, previous_sources):
if str(index) in previous_sources:
key = vol.Optional(
@ -111,14 +113,14 @@ def _key_for_source(index, source, previous_sources):
return key
class MonopriceOptionsFlowHandler(config_entries.OptionsFlow):
class MonopriceOptionsFlowHandler(OptionsFlow):
"""Handle a Monoprice options flow."""
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
def __init__(self, config_entry: ConfigEntry) -> None:
"""Initialize."""
self.config_entry = config_entry
@core.callback
@callback
def _previous_sources(self):
if CONF_SOURCES in self.config_entry.options:
previous = self.config_entry.options[CONF_SOURCES]
@ -147,5 +149,5 @@ class MonopriceOptionsFlowHandler(config_entries.OptionsFlow):
)
class CannotConnect(exceptions.HomeAssistantError):
class CannotConnect(HomeAssistantError):
"""Error to indicate we cannot connect."""

View File

@ -3,8 +3,7 @@ from __future__ import annotations
from typing import Any
from homeassistant.config_entries import ConfigFlow
from homeassistant.data_entry_flow import FlowResult
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from .const import DEFAULT_NAME, DOMAIN
@ -16,7 +15,7 @@ class MoonConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initialized by the user."""
if self._async_current_entries():
return self.async_abort(reason="single_instance_allowed")

View File

@ -10,9 +10,8 @@ from homeassistant.components.bluetooth import (
BluetoothServiceInfoBleak,
async_discovered_service_info,
)
from homeassistant.config_entries import ConfigFlow
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_ADDRESS
from homeassistant.data_entry_flow import FlowResult
from .const import DOMAIN
@ -30,7 +29,7 @@ class MopekaConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_bluetooth(
self, discovery_info: BluetoothServiceInfoBleak
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the bluetooth discovery step."""
await self.async_set_unique_id(discovery_info.address)
self._abort_if_unique_id_configured()
@ -43,7 +42,7 @@ class MopekaConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_bluetooth_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Confirm discovery."""
assert self._discovered_device is not None
device = self._discovered_device
@ -62,7 +61,7 @@ class MopekaConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the user step to pick discovered device."""
if user_input is not None:
address = user_input[CONF_ADDRESS]

View File

@ -6,11 +6,15 @@ from typing import Any
from motionblinds import MotionDiscovery, MotionGateway
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import dhcp
from homeassistant.config_entries import (
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.const import CONF_API_KEY, CONF_HOST
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.device_registry import format_mac
from .const import (
@ -30,16 +34,16 @@ CONFIG_SCHEMA = vol.Schema(
)
class OptionsFlowHandler(config_entries.OptionsFlow):
class OptionsFlowHandler(OptionsFlow):
"""Options for the component."""
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
def __init__(self, config_entry: ConfigEntry) -> None:
"""Init object."""
self.config_entry = config_entry
async def async_step_init(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Manage the options."""
errors: dict[str, str] = {}
if user_input is not None:
@ -61,7 +65,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
)
class MotionBlindsFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class MotionBlindsFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a Motionblinds config flow."""
VERSION = 1
@ -75,12 +79,14 @@ class MotionBlindsFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
@staticmethod
@callback
def async_get_options_flow(
config_entry: config_entries.ConfigEntry,
config_entry: ConfigEntry,
) -> OptionsFlowHandler:
"""Get the options flow."""
return OptionsFlowHandler(config_entry)
async def async_step_dhcp(self, discovery_info: dhcp.DhcpServiceInfo) -> FlowResult:
async def async_step_dhcp(
self, discovery_info: dhcp.DhcpServiceInfo
) -> ConfigFlowResult:
"""Handle discovery via dhcp."""
mac_address = format_mac(discovery_info.macaddress).replace(":", "")
await self.async_set_unique_id(mac_address)
@ -107,7 +113,7 @@ class MotionBlindsFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initialized by the user."""
errors = {}
if user_input is not None:
@ -136,7 +142,7 @@ class MotionBlindsFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_select(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle multiple motion gateways found."""
if user_input is not None:
self._host = user_input["select_ip"]
@ -148,7 +154,7 @@ class MotionBlindsFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_connect(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Connect to the Motion Gateway."""
errors: dict[str, str] = {}
if user_input is not None:

View File

@ -16,11 +16,11 @@ from homeassistant.config_entries import (
SOURCE_REAUTH,
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.const import CONF_SOURCE, CONF_URL, CONF_WEBHOOK_ID
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.aiohttp_client import async_get_clientsession
@ -47,12 +47,12 @@ class MotionEyeConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the initial step."""
def _get_form(
user_input: dict[str, Any], errors: dict[str, str] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Show the form to the user."""
url_schema: dict[vol.Required, type[str]] = {}
if not self._hassio_discovery:
@ -157,11 +157,15 @@ class MotionEyeConfigFlow(ConfigFlow, domain=DOMAIN):
data=user_input,
)
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
async def async_step_reauth(
self, entry_data: Mapping[str, Any]
) -> ConfigFlowResult:
"""Handle a reauthentication flow."""
return await self.async_step_user()
async def async_step_hassio(self, discovery_info: HassioServiceInfo) -> FlowResult:
async def async_step_hassio(
self, discovery_info: HassioServiceInfo
) -> ConfigFlowResult:
"""Handle Supervisor discovery."""
self._hassio_discovery = discovery_info.config
await self._async_handle_discovery_without_unique_id()
@ -170,7 +174,7 @@ class MotionEyeConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_hassio_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Confirm Supervisor discovery."""
if user_input is None and self._hassio_discovery is not None:
return self.async_show_form(
@ -196,7 +200,7 @@ class MotionEyeOptionsFlow(OptionsFlow):
async def async_step_init(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Manage the options."""
if user_input is not None:
return self.async_create_entry(title="", data=user_input)

View File

@ -6,10 +6,13 @@ from typing import Any
import motionmount
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import zeroconf
from homeassistant.config_entries import (
DEFAULT_DISCOVERY_UNIQUE_ID,
ConfigFlow,
ConfigFlowResult,
)
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT, CONF_UUID
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.device_registry import format_mac
from .const import DOMAIN, EMPTY_MAC
@ -23,7 +26,7 @@ _LOGGER = logging.getLogger(__name__)
# 3. New CE but old Pro FW -> It doesn't supply the mac using DNS-SD but we can read it (returning the EMPTY_MAC)
# 4. New CE and new Pro FW -> Both DNS-SD and a read gives us the mac
# If we can't get the mac, we use DEFAULT_DISCOVERY_UNIQUE_ID as an ID, so we can always configure a single MotionMount. Most households will only have a single MotionMount
class MotionMountFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class MotionMountFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a Vogel's MotionMount config flow."""
VERSION = 1
@ -34,7 +37,7 @@ class MotionMountFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initiated by the user."""
if user_input is None:
return self._show_setup_form()
@ -55,13 +58,13 @@ class MotionMountFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
return self.async_abort(reason="already_configured")
# Otherwise we try to continue with the generic uid
info[CONF_UUID] = config_entries.DEFAULT_DISCOVERY_UNIQUE_ID
info[CONF_UUID] = DEFAULT_DISCOVERY_UNIQUE_ID
# If the device mac is valid we use it, otherwise we use the default id
if info.get(CONF_UUID, EMPTY_MAC) != EMPTY_MAC:
unique_id = info[CONF_UUID]
else:
unique_id = config_entries.DEFAULT_DISCOVERY_UNIQUE_ID
unique_id = DEFAULT_DISCOVERY_UNIQUE_ID
name = info.get(CONF_NAME, user_input[CONF_HOST])
@ -77,7 +80,7 @@ class MotionMountFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_zeroconf(
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle zeroconf discovery."""
# Extract information from discovery
@ -137,7 +140,7 @@ class MotionMountFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_zeroconf_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a confirmation flow initiated by zeroconf."""
if user_input is None:
return self.async_show_form(
@ -162,7 +165,9 @@ class MotionMountFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
return {CONF_UUID: format_mac(mm.mac.hex()), CONF_NAME: mm.name}
def _show_setup_form(self, errors: dict[str, str] | None = None) -> FlowResult:
def _show_setup_form(
self, errors: dict[str, str] | None = None
) -> ConfigFlowResult:
"""Show the setup form to the user."""
return self.async_show_form(
step_id="user",

View File

@ -14,7 +14,12 @@ import voluptuous as vol
from homeassistant.components.file_upload import process_uploaded_file
from homeassistant.components.hassio import HassioServiceInfo
from homeassistant.config_entries import ConfigEntry, ConfigFlow, OptionsFlow
from homeassistant.config_entries import (
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.const import (
CONF_CLIENT_ID,
CONF_DISCOVERY,
@ -26,7 +31,6 @@ from homeassistant.const import (
CONF_USERNAME,
)
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.json import json_dumps
from homeassistant.helpers.selector import (
@ -171,7 +175,7 @@ class FlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initialized by the user."""
if self._async_current_entries():
return self.async_abort(reason="single_instance_allowed")
@ -180,7 +184,7 @@ class FlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_broker(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Confirm the setup."""
errors: dict[str, str] = {}
fields: OrderedDict[Any, Any] = OrderedDict()
@ -211,7 +215,9 @@ class FlowHandler(ConfigFlow, domain=DOMAIN):
step_id="broker", data_schema=vol.Schema(fields), errors=errors
)
async def async_step_hassio(self, discovery_info: HassioServiceInfo) -> FlowResult:
async def async_step_hassio(
self, discovery_info: HassioServiceInfo
) -> ConfigFlowResult:
"""Receive a Hass.io discovery."""
await self._async_handle_discovery_without_unique_id()
@ -221,7 +227,7 @@ class FlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_hassio_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Confirm a Hass.io discovery."""
errors: dict[str, str] = {}
if TYPE_CHECKING:
@ -265,13 +271,13 @@ class MQTTOptionsFlowHandler(OptionsFlow):
self.broker_config: dict[str, str | int] = {}
self.options = config_entry.options
async def async_step_init(self, user_input: None = None) -> FlowResult:
async def async_step_init(self, user_input: None = None) -> ConfigFlowResult:
"""Manage the MQTT options."""
return await self.async_step_broker()
async def async_step_broker(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Manage the MQTT broker configuration."""
errors: dict[str, str] = {}
fields: OrderedDict[Any, Any] = OrderedDict()
@ -304,7 +310,7 @@ class MQTTOptionsFlowHandler(OptionsFlow):
async def async_step_options(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Manage the MQTT options."""
errors = {}
current_config = self.config_entry.data

View File

@ -1,18 +1,17 @@
"""Config flow for Mullvad VPN integration."""
from mullvad_api import MullvadAPI, MullvadAPIError
from homeassistant import config_entries
from homeassistant.data_entry_flow import FlowResult
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from .const import DOMAIN
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class MullvadConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Mullvad VPN."""
VERSION = 1
async def async_step_user(self, user_input=None) -> FlowResult:
async def async_step_user(self, user_input=None) -> ConfigFlowResult:
"""Handle the initial step."""
self._async_abort_entries_match()

View File

@ -8,9 +8,8 @@ import aiohttp
import mutesync
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResult
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.aiohttp_client import async_get_clientsession
@ -38,14 +37,14 @@ async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> dict[str,
return token
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class MuteSyncConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for mütesync."""
VERSION = 1
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the initial step."""
if user_input is None:
return self.async_show_form(

View File

@ -1,11 +1,11 @@
"""Config flow for MyQ integration."""
from homeassistant import config_entries
from homeassistant.config_entries import ConfigFlow
from . import DOMAIN
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class MyQConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for MyQ."""
VERSION = 1

View File

@ -11,16 +11,14 @@ from awesomeversion import (
)
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components.mqtt import (
DOMAIN as MQTT_DOMAIN,
valid_publish_topic,
valid_subscribe_topic,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_DEVICE
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import selector
import homeassistant.helpers.config_validation as cv
@ -120,7 +118,7 @@ def _is_same_device(
return True
class MySensorsConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class MySensorsConfigFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a config flow."""
def __init__(self) -> None:
@ -129,13 +127,13 @@ class MySensorsConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, str] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Create a config entry from frontend user input."""
return await self.async_step_select_gateway_type()
async def async_step_select_gateway_type(
self, user_input: dict[str, str] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Show the select gateway type menu."""
return self.async_show_menu(
step_id="select_gateway_type",
@ -144,7 +142,7 @@ class MySensorsConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_gw_serial(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Create config entry for a serial gateway."""
gw_type = self._gw_type = CONF_GATEWAY_TYPE_SERIAL
errors: dict[str, str] = {}
@ -173,7 +171,7 @@ class MySensorsConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_gw_tcp(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Create a config entry for a tcp gateway."""
gw_type = self._gw_type = CONF_GATEWAY_TYPE_TCP
errors: dict[str, str] = {}
@ -207,7 +205,7 @@ class MySensorsConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_gw_mqtt(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Create a config entry for a mqtt gateway."""
# Naive check that doesn't consider config entry state.
if MQTT_DOMAIN not in self.hass.config.components:
@ -262,7 +260,7 @@ class MySensorsConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
)
@callback
def _async_create_entry(self, user_input: dict[str, Any]) -> FlowResult:
def _async_create_entry(self, user_input: dict[str, Any]) -> ConfigFlowResult:
"""Create the config entry."""
return self.async_create_entry(
title=f"{user_input[CONF_DEVICE]}",

View File

@ -8,9 +8,8 @@ import pymystrom
from pymystrom.exceptions import MyStromConnectionError
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_HOST, CONF_NAME
from homeassistant.data_entry_flow import FlowResult
from .const import DOMAIN
@ -26,14 +25,14 @@ STEP_USER_DATA_SCHEMA = vol.Schema(
)
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class MyStromConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for myStrom."""
VERSION = 1
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the initial step."""
errors: dict[str, str] = {}

View File

@ -3,8 +3,7 @@ from collections.abc import Mapping
import logging
from typing import Any
from homeassistant.config_entries import ConfigEntry
from homeassistant.data_entry_flow import FlowResult
from homeassistant.config_entries import ConfigEntry, ConfigFlowResult
from homeassistant.helpers import config_entry_oauth2_flow
from .const import DOMAIN, OAUTH2_SCOPES
@ -29,7 +28,9 @@ class OAuth2FlowHandler(
"""Extra data that needs to be appended to the authorize url."""
return {"scope": " ".join(OAUTH2_SCOPES)}
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
async def async_step_reauth(
self, entry_data: Mapping[str, Any]
) -> ConfigFlowResult:
"""Perform reauth upon an API authentication error."""
self.config_entry_reauth = self.hass.config_entries.async_get_entry(
self.context["entry_id"]
@ -38,7 +39,7 @@ class OAuth2FlowHandler(
async def async_step_reauth_confirm(
self, user_input: Mapping[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Dialog that informs the user that reauth is required."""
if user_input is None:
return self.async_show_form(
@ -47,7 +48,7 @@ class OAuth2FlowHandler(
return await self.async_step_user()
async def async_oauth_create_entry(self, data: dict) -> FlowResult:
async def async_oauth_create_entry(self, data: dict) -> ConfigFlowResult:
"""Create or update the config entry."""
if self.config_entry_reauth:
return self.async_update_reload_and_abort(