Migrate integrations u-z to generic flowhandler (#111866)

pull/111881/head
Erik Montnemery 2024-02-29 20:08:16 +01:00 committed by GitHub
parent e06446d0fa
commit 9ec9ac4fd4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
64 changed files with 577 additions and 454 deletions

View File

@ -7,7 +7,7 @@ import aiohttp
from uasiren.client import Client
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigFlow
from homeassistant.const import CONF_NAME, CONF_REGION
from homeassistant.helpers.aiohttp_client import async_get_clientsession
@ -16,7 +16,7 @@ from .const import DOMAIN
_LOGGER = logging.getLogger(__name__)
class UkraineAlarmConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class UkraineAlarmConfigFlow(ConfigFlow, domain=DOMAIN):
"""Config flow for Ukraine Alarm."""
VERSION = 1

View File

@ -17,8 +17,13 @@ from urllib.parse import urlparse
from aiounifi.interfaces.sites import Sites
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import ssdp
from homeassistant.config_entries import (
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.const import (
CONF_HOST,
CONF_PASSWORD,
@ -27,7 +32,6 @@ from homeassistant.const import (
CONF_VERIFY_SSL,
)
from homeassistant.core import HomeAssistant, callback
from homeassistant.data_entry_flow import FlowResult
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.device_registry import format_mac
@ -61,7 +65,7 @@ MODEL_PORTS = {
}
class UnifiFlowHandler(config_entries.ConfigFlow, domain=UNIFI_DOMAIN):
class UnifiFlowHandler(ConfigFlow, domain=UNIFI_DOMAIN):
"""Handle a UniFi Network config flow."""
VERSION = 1
@ -71,7 +75,7 @@ class UnifiFlowHandler(config_entries.ConfigFlow, domain=UNIFI_DOMAIN):
@staticmethod
@callback
def async_get_options_flow(
config_entry: config_entries.ConfigEntry,
config_entry: ConfigEntry,
) -> UnifiOptionsFlowHandler:
"""Get the options flow for this handler."""
return UnifiOptionsFlowHandler(config_entry)
@ -79,12 +83,12 @@ class UnifiFlowHandler(config_entries.ConfigFlow, domain=UNIFI_DOMAIN):
def __init__(self) -> None:
"""Initialize the UniFi Network flow."""
self.config: dict[str, Any] = {}
self.reauth_config_entry: config_entries.ConfigEntry | None = None
self.reauth_config_entry: ConfigEntry | None = None
self.reauth_schema: dict[vol.Marker, Any] = {}
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initialized by the user."""
errors = {}
@ -144,7 +148,7 @@ class UnifiFlowHandler(config_entries.ConfigFlow, domain=UNIFI_DOMAIN):
async def async_step_site(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Select site to control."""
if user_input is not None:
unique_id = user_input[CONF_SITE_ID]
@ -181,7 +185,9 @@ class UnifiFlowHandler(config_entries.ConfigFlow, domain=UNIFI_DOMAIN):
data_schema=vol.Schema({vol.Required(CONF_SITE_ID): vol.In(site_names)}),
)
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
async def async_step_reauth(
self, entry_data: Mapping[str, Any]
) -> ConfigFlowResult:
"""Trigger a reauthentication flow."""
config_entry = self.hass.config_entries.async_get_entry(
self.context["entry_id"]
@ -206,7 +212,9 @@ class UnifiFlowHandler(config_entries.ConfigFlow, domain=UNIFI_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 UniFi device."""
parsed_url = urlparse(discovery_info.ssdp_location)
model_description = discovery_info.upnp[ssdp.ATTR_UPNP_MODEL_DESCRIPTION]
@ -235,19 +243,19 @@ class UnifiFlowHandler(config_entries.ConfigFlow, domain=UNIFI_DOMAIN):
return await self.async_step_user()
class UnifiOptionsFlowHandler(config_entries.OptionsFlow):
class UnifiOptionsFlowHandler(OptionsFlow):
"""Handle Unifi Network options."""
hub: UnifiHub
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
def __init__(self, config_entry: ConfigEntry) -> None:
"""Initialize UniFi Network options flow."""
self.config_entry = config_entry
self.options = dict(config_entry.options)
async def async_step_init(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Manage the UniFi Network options."""
if self.config_entry.entry_id not in self.hass.data[UNIFI_DOMAIN]:
return self.async_abort(reason="integration_not_setup")
@ -261,7 +269,7 @@ class UnifiOptionsFlowHandler(config_entries.OptionsFlow):
async def async_step_simple_options(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""For users without advanced settings enabled."""
if user_input is not None:
self.options.update(user_input)
@ -296,7 +304,7 @@ class UnifiOptionsFlowHandler(config_entries.OptionsFlow):
async def async_step_configure_entity_sources(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Select sources for entities."""
if user_input is not None:
self.options.update(user_input)
@ -329,7 +337,7 @@ class UnifiOptionsFlowHandler(config_entries.OptionsFlow):
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:
self.options.update(user_input)
@ -390,7 +398,7 @@ class UnifiOptionsFlowHandler(config_entries.OptionsFlow):
async def async_step_client_control(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Manage configuration of network access controlled clients."""
if user_input is not None:
self.options.update(user_input)
@ -429,7 +437,7 @@ class UnifiOptionsFlowHandler(config_entries.OptionsFlow):
async def async_step_statistics_sensors(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Manage the statistics sensors options."""
if user_input is not None:
self.options.update(user_input)
@ -452,7 +460,7 @@ class UnifiOptionsFlowHandler(config_entries.OptionsFlow):
last_step=True,
)
async def _update_options(self) -> FlowResult:
async def _update_options(self) -> ConfigFlowResult:
"""Update config entry options."""
return self.async_create_entry(title="", data=self.options)

View File

@ -13,8 +13,15 @@ from pyunifiprotect.exceptions import ClientError, NotAuthorized
from unifi_discovery import async_console_is_alive
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import dhcp, ssdp
from homeassistant.config_entries import (
SOURCE_IGNORE,
ConfigEntry,
ConfigEntryState,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.const import (
CONF_HOST,
CONF_ID,
@ -24,7 +31,6 @@ from homeassistant.const import (
CONF_VERIFY_SSL,
)
from homeassistant.core import HomeAssistant, callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import (
async_create_clientsession,
async_get_clientsession,
@ -54,8 +60,8 @@ from .utils import _async_resolve, _async_short_mac, _async_unifi_mac_from_hass
_LOGGER = logging.getLogger(__name__)
ENTRY_FAILURE_STATES = (
config_entries.ConfigEntryState.SETUP_ERROR,
config_entries.ConfigEntryState.SETUP_RETRY,
ConfigEntryState.SETUP_ERROR,
ConfigEntryState.SETUP_RETRY,
)
@ -72,7 +78,7 @@ def _host_is_direct_connect(host: str) -> bool:
async def _async_console_is_offline(
hass: HomeAssistant,
entry: config_entries.ConfigEntry,
entry: ConfigEntry,
) -> bool:
"""Check if a console is offline.
@ -89,7 +95,7 @@ async def _async_console_is_offline(
)
class ProtectFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class ProtectFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a UniFi Protect config flow."""
VERSION = 2
@ -97,20 +103,24 @@ class ProtectFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
def __init__(self) -> None:
"""Init the config flow."""
super().__init__()
self.entry: config_entries.ConfigEntry | None = None
self.entry: ConfigEntry | None = None
self._discovered_device: dict[str, str] = {}
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."""
_LOGGER.debug("Starting discovery via: %s", discovery_info)
return await self._async_discovery_handoff()
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 UniFi device."""
_LOGGER.debug("Starting discovery via: %s", discovery_info)
return await self._async_discovery_handoff()
async def _async_discovery_handoff(self) -> FlowResult:
async def _async_discovery_handoff(self) -> ConfigFlowResult:
"""Ensure discovery is active."""
# Discovery requires an additional check so we use
# SSDP and DHCP to tell us to start it so it only
@ -120,7 +130,7 @@ class ProtectFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_integration_discovery(
self, discovery_info: DiscoveryInfoType
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle integration discovery."""
self._discovered_device = discovery_info
mac = _async_unifi_mac_from_hass(discovery_info["hw_addr"])
@ -128,7 +138,7 @@ class ProtectFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
source_ip = discovery_info["source_ip"]
direct_connect_domain = discovery_info["direct_connect_domain"]
for entry in self._async_current_entries():
if entry.source == config_entries.SOURCE_IGNORE:
if entry.source == SOURCE_IGNORE:
if entry.unique_id == mac:
return self.async_abort(reason="already_configured")
continue
@ -164,7 +174,7 @@ class ProtectFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_discovery_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Confirm discovery."""
errors: dict[str, str] = {}
discovery_info = self._discovered_device
@ -212,13 +222,13 @@ class ProtectFlowHandler(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)
@callback
def _async_create_entry(self, title: str, data: dict[str, Any]) -> FlowResult:
def _async_create_entry(self, title: str, data: dict[str, Any]) -> ConfigFlowResult:
return self.async_create_entry(
title=title,
data={**data, CONF_ID: title},
@ -279,7 +289,9 @@ class ProtectFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
return nvr_data, 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"])
@ -287,7 +299,7 @@ class ProtectFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_reauth_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Confirm reauth."""
errors: dict[str, str] = {}
assert self.entry is not None
@ -321,7 +333,7 @@ class ProtectFlowHandler(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] = {}
@ -362,16 +374,16 @@ class ProtectFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
)
class OptionsFlowHandler(config_entries.OptionsFlow):
class OptionsFlowHandler(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[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

@ -7,8 +7,9 @@ from urllib.parse import urlparse
import upb_lib
import voluptuous as vol
from homeassistant import config_entries, exceptions
from homeassistant.config_entries import ConfigFlow
from homeassistant.const import CONF_ADDRESS, CONF_FILE_PATH, CONF_HOST, CONF_PROTOCOL
from homeassistant.exceptions import HomeAssistantError
from .const import DOMAIN
@ -70,7 +71,7 @@ def _make_url_from_data(data):
return f"{protocol}{address}"
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class UPBConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for UPB PIM."""
VERSION = 1
@ -128,9 +129,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
return urlparse(url).hostname in existing_hosts
class CannotConnect(exceptions.HomeAssistantError):
class CannotConnect(HomeAssistantError):
"""Error to indicate we cannot connect."""
class InvalidUpbFile(exceptions.HomeAssistantError):
class InvalidUpbFile(HomeAssistantError):
"""Error to indicate there is invalid or missing UPB config file."""

View File

@ -9,17 +9,21 @@ import requests.exceptions
import upcloud_api
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import (
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.const import CONF_PASSWORD, CONF_SCAN_INTERVAL, CONF_USERNAME
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from .const import DEFAULT_SCAN_INTERVAL, DOMAIN
_LOGGER = logging.getLogger(__name__)
class UpCloudConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class UpCloudConfigFlow(ConfigFlow, domain=DOMAIN):
"""UpCloud config flow."""
VERSION = 1
@ -29,7 +33,7 @@ class UpCloudConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle user initiated flow."""
if user_input is None:
return self._async_show_form(step_id="user")
@ -66,7 +70,7 @@ class UpCloudConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
step_id: str,
user_input: dict[str, Any] | None = None,
errors: dict[str, str] | None = None,
) -> FlowResult:
) -> ConfigFlowResult:
"""Show our form."""
if user_input is None:
user_input = {}
@ -88,22 +92,22 @@ class UpCloudConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
@staticmethod
@callback
def async_get_options_flow(
config_entry: config_entries.ConfigEntry,
config_entry: ConfigEntry,
) -> UpCloudOptionsFlow:
"""Get options flow."""
return UpCloudOptionsFlow(config_entry)
class UpCloudOptionsFlow(config_entries.OptionsFlow):
class UpCloudOptionsFlow(OptionsFlow):
"""UpCloud options flow."""
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:

View File

@ -7,11 +7,10 @@ from urllib.parse import urlparse
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import ssdp
from homeassistant.components.ssdp import SsdpServiceInfo
from homeassistant.config_entries import SOURCE_IGNORE, ConfigFlow, ConfigFlowResult
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResult
from .const import (
CONFIG_ENTRY_HOST,
@ -74,7 +73,7 @@ def _is_igd_device(discovery_info: ssdp.SsdpServiceInfo) -> bool:
return root_device_info.get(ssdp.ATTR_UPNP_DEVICE_TYPE) in {ST_IGD_V1, ST_IGD_V2}
class UpnpFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class UpnpFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a UPnP/IGD config flow."""
VERSION = 1
@ -100,7 +99,7 @@ class UpnpFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: Mapping[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow start."""
LOGGER.debug("async_step_user: user_input: %s", user_input)
@ -151,7 +150,9 @@ class UpnpFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
data_schema=data_schema,
)
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 UPnP/IGD device.
This flow is triggered by the SSDP component. It will check if the
@ -201,7 +202,7 @@ class UpnpFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
# Check ssdp_st to prevent swapping between IGDv1 and IGDv2.
continue
if entry.source == config_entries.SOURCE_IGNORE:
if entry.source == SOURCE_IGNORE:
# Host was already ignored. Don't update ignored entries.
return self.async_abort(reason="discovery_ignored")
@ -225,7 +226,7 @@ class UpnpFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_ssdp_confirm(
self, user_input: Mapping[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Confirm integration via SSDP."""
LOGGER.debug("async_step_ssdp_confirm: user_input: %s", user_input)
if user_input is None:
@ -235,7 +236,7 @@ class UpnpFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
discovery = self._remove_discovery(self.unique_id)
return await self._async_create_entry_from_discovery(discovery)
async def async_step_ignore(self, user_input: dict[str, Any]) -> FlowResult:
async def async_step_ignore(self, user_input: dict[str, Any]) -> ConfigFlowResult:
"""Ignore this config flow."""
usn = user_input["unique_id"]
discovery = self._remove_discovery(usn)
@ -255,7 +256,7 @@ class UpnpFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def _async_create_entry_from_discovery(
self,
discovery: SsdpServiceInfo,
) -> FlowResult:
) -> ConfigFlowResult:
"""Create an entry from discovery."""
LOGGER.debug(
"_async_create_entry_from_discovery: discovery: %s",

View File

@ -5,8 +5,7 @@ from typing import Any
import voluptuous as vol
from homeassistant.config_entries import ConfigFlow
from homeassistant.data_entry_flow import FlowResult
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from .const import DOMAIN
@ -18,7 +17,7 @@ class UptimeConfigFlow(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

@ -14,9 +14,8 @@ from pyuptimerobot import (
)
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_API_KEY
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import API_ATTR_OK, DOMAIN, LOGGER
@ -24,7 +23,7 @@ from .const import API_ATTR_OK, DOMAIN, LOGGER
STEP_USER_DATA_SCHEMA = vol.Schema({vol.Required(CONF_API_KEY): str})
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class UptimeRobotConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for UptimeRobot."""
VERSION = 1
@ -68,7 +67,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 user_input is None:
return self.async_show_form(
@ -85,13 +84,15 @@ 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:
"""Return the reauth confirm step."""
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

@ -8,9 +8,8 @@ from pytrydan import Trydan
from pytrydan.exceptions import TrydanError
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_HOST
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.httpx_client import get_async_client
from .const import DOMAIN
@ -24,14 +23,14 @@ STEP_USER_DATA_SCHEMA = vol.Schema(
)
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class V2CConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for V2C."""
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,10 +7,9 @@ from typing import Any
from vallox_websocket_api import Vallox, ValloxApiException
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.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResult
from homeassistant.exceptions import HomeAssistantError
from homeassistant.util.network import is_ip_address
@ -35,14 +34,14 @@ async def validate_host(hass: HomeAssistant, host: str) -> None:
await client.fetch_metric_data()
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class ValloxConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for the Vallox integration."""
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

@ -7,16 +7,15 @@ import velbusaio.controller
from velbusaio.exceptions import VelbusConnectionFailed
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_NAME, CONF_PORT
from homeassistant.data_entry_flow import FlowResult
from homeassistant.util import slugify
from .const import DOMAIN
class VelbusConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class VelbusConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow."""
VERSION = 2
@ -27,7 +26,7 @@ class VelbusConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
self._device: str = ""
self._title: str = ""
def _create_device(self, name: str, prt: str) -> FlowResult:
def _create_device(self, name: str, prt: str) -> ConfigFlowResult:
"""Create an entry async."""
return self.async_create_entry(title=name, data={CONF_PORT: prt})
@ -44,7 +43,7 @@ class VelbusConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Step when user initializes a integration."""
self._errors = {}
if user_input is not None:
@ -69,7 +68,9 @@ class VelbusConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
errors=self._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."""
await self.async_set_unique_id(
f"{discovery_info.vid}:{discovery_info.pid}_{discovery_info.serial_number}_{discovery_info.manufacturer}_{discovery_info.description}"
@ -89,7 +90,7 @@ class VelbusConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_discovery_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle Discovery confirmation."""
if user_input is not None:
return self._create_device(self._title, self._device)

View File

@ -7,7 +7,6 @@ import voluptuous as vol
from homeassistant import config_entries
from homeassistant.const import CONF_HOST, CONF_PASSWORD
from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN
from homeassistant.data_entry_flow import FlowResult
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
@ -24,7 +23,9 @@ DATA_SCHEMA = vol.Schema(
class VeluxConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
"""Handle a config flow for velux."""
async def async_step_import(self, config: dict[str, Any]) -> FlowResult:
async def async_step_import(
self, config: dict[str, Any]
) -> config_entries.ConfigFlowResult:
"""Import a config entry."""
def create_repair(error: str | None = None) -> None:
@ -79,7 +80,7 @@ class VeluxConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, str] | None = None
) -> FlowResult:
) -> config_entries.ConfigFlowResult:
"""Handle the initial step."""
errors: dict[str, str] = {}

View File

@ -4,7 +4,7 @@ from typing import Any
from venstarcolortouch import VenstarColorTouch
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,
@ -13,7 +13,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 homeassistant.helpers.typing import ConfigType
@ -54,7 +53,7 @@ class VenstarConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Create config entry. Show the setup form to the user."""
errors = {}
@ -85,7 +84,7 @@ class VenstarConfigFlow(ConfigFlow, domain=DOMAIN):
errors=errors,
)
async def async_step_import(self, import_data: ConfigType) -> FlowResult:
async def async_step_import(self, import_data: ConfigType) -> ConfigFlowResult:
"""Import entry from configuration.yaml."""
self._async_abort_entries_match({CONF_HOST: import_data[CONF_HOST]})
return await self.async_step_user(

View File

@ -10,11 +10,16 @@ import pyvera as pv
from requests.exceptions import RequestException
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigEntry
from homeassistant.config_entries import (
SOURCE_IMPORT,
SOURCE_USER,
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.const import CONF_EXCLUDE, CONF_LIGHTS, CONF_SOURCE
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import entity_registry as er
from .const import CONF_CONTROLLER, CONF_LEGACY_UNIQUE_ID, DOMAIN
@ -68,7 +73,7 @@ def options_data(user_input: dict[str, str]) -> dict[str, list[int]]:
)
class OptionsFlowHandler(config_entries.OptionsFlow):
class OptionsFlowHandler(OptionsFlow):
"""Options for the component."""
def __init__(self, config_entry: ConfigEntry) -> None:
@ -78,7 +83,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
async def async_step_init(
self,
user_input: dict[str, str] | None = None,
) -> FlowResult:
) -> ConfigFlowResult:
"""Manage the options."""
if user_input is not None:
return self.async_create_entry(
@ -92,7 +97,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
)
class VeraFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class VeraFlowHandler(ConfigFlow, domain=DOMAIN):
"""Vera config flow."""
@staticmethod
@ -103,14 +108,14 @@ class VeraFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle user initiated flow."""
if user_input is not None:
return await self.async_step_finish(
{
**user_input,
**options_data(user_input),
**{CONF_SOURCE: config_entries.SOURCE_USER},
**{CONF_SOURCE: SOURCE_USER},
**{CONF_LEGACY_UNIQUE_ID: False},
}
)
@ -122,7 +127,7 @@ class VeraFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
),
)
async def async_step_import(self, config: dict[str, Any]) -> FlowResult:
async def async_step_import(self, config: dict[str, Any]) -> ConfigFlowResult:
"""Handle a flow initialized by import."""
# If there are entities with the legacy unique_id, then this imported config
@ -142,12 +147,12 @@ class VeraFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
return await self.async_step_finish(
{
**config,
**{CONF_SOURCE: config_entries.SOURCE_IMPORT},
**{CONF_SOURCE: SOURCE_IMPORT},
**{CONF_LEGACY_UNIQUE_ID: use_legacy_unique_id},
}
)
async def async_step_finish(self, config: dict[str, Any]) -> FlowResult:
async def async_step_finish(self, config: dict[str, Any]) -> ConfigFlowResult:
"""Validate and create config entry."""
base_url = config[CONF_CONTROLLER] = config[CONF_CONTROLLER].rstrip("/")
controller = pv.VeraController(base_url)

View File

@ -12,10 +12,14 @@ from verisure import (
)
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_CODE, CONF_EMAIL, CONF_PASSWORD
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.storage import STORAGE_DIR
from .const import (
@ -45,7 +49,7 @@ class VerisureConfigFlowHandler(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] = {}
@ -102,7 +106,7 @@ class VerisureConfigFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_mfa(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle multifactor authentication step."""
errors: dict[str, str] = {}
@ -134,7 +138,7 @@ class VerisureConfigFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_installation(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Select Verisure installation to add."""
installations_data = await self.hass.async_add_executor_job(
self.verisure.get_installations
@ -170,7 +174,9 @@ class VerisureConfigFlowHandler(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:
"""Handle initiation of re-authentication with Verisure."""
self.entry = cast(
ConfigEntry,
@ -180,7 +186,7 @@ class VerisureConfigFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_reauth_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle re-authentication with Verisure."""
errors: dict[str, str] = {}
@ -250,7 +256,7 @@ class VerisureConfigFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_reauth_mfa(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle multifactor authentication step during re-authentication."""
errors: dict[str, str] = {}
@ -303,7 +309,7 @@ class VerisureOptionsFlowHandler(OptionsFlow):
async def async_step_init(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Manage Verisure options."""
errors: dict[str, Any] = {}

View File

@ -5,9 +5,8 @@ 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_SOURCE
from homeassistant.data_entry_flow import FlowResult
from .const import (
ATTR_VERSION_SOURCE,
@ -33,7 +32,7 @@ from .const import (
)
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class VersionConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Version."""
VERSION = 1
@ -45,7 +44,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 user step."""
if user_input is None:
self._entry_data = DEFAULT_CONFIGURATION.copy()
@ -78,7 +77,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_version_source(
self,
user_input: dict[str, Any] | None = None,
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the version_source step."""
if user_input is None:
if self._entry_data[CONF_SOURCE] in (

View File

@ -4,14 +4,14 @@ from collections import OrderedDict
from pyvesync import VeSync
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigFlow
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import callback
from .const import DOMAIN
class VeSyncFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class VeSyncFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a config flow."""
VERSION = 1

View File

@ -11,10 +11,9 @@ from PyViCare.PyViCareUtils import (
)
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import dhcp
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_CLIENT_ID, CONF_PASSWORD, CONF_USERNAME
from homeassistant.data_entry_flow import FlowResult
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.device_registry import format_mac
@ -46,15 +45,15 @@ USER_SCHEMA = REAUTH_SCHEMA.extend(
)
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class ViCareConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for ViCare."""
VERSION = 1
entry: config_entries.ConfigEntry | None
entry: ConfigEntry | None
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Invoke when a user initiates a flow via the user interface."""
if self._async_current_entries():
return self.async_abort(reason="single_instance_allowed")
@ -77,14 +76,16 @@ class ConfigFlow(config_entries.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:
"""Handle re-authentication with ViCare."""
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:
"""Confirm re-authentication with ViCare."""
errors: dict[str, str] = {}
assert self.entry is not None
@ -115,7 +116,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
errors=errors,
)
async def async_step_dhcp(self, discovery_info: dhcp.DhcpServiceInfo) -> FlowResult:
async def async_step_dhcp(
self, discovery_info: dhcp.DhcpServiceInfo
) -> ConfigFlowResult:
"""Invoke when a Viessmann MAC address is discovered on the network."""
formatted_mac = format_mac(discovery_info.macaddress)
_LOGGER.debug("Found device with mac %s", formatted_mac)

View File

@ -8,8 +8,10 @@ from vilfo.exceptions import (
)
import voluptuous as vol
from homeassistant import config_entries, core, exceptions
from homeassistant.config_entries import ConfigFlow
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_HOST, CONF_ID, CONF_MAC
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
from homeassistant.util.network import is_host_valid
from .const import DOMAIN, ROUTER_DEFAULT_HOST
@ -62,7 +64,7 @@ def _try_connect_and_fetch_basic_info(host, token):
return result
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.
@ -91,7 +93,7 @@ async def validate_input(hass: core.HomeAssistant, data):
return config
class DomainConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class DomainConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Vilfo Router."""
VERSION = 1
@ -122,13 +124,13 @@ class DomainConfigFlow(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 InvalidHost(exceptions.HomeAssistantError):
class InvalidHost(HomeAssistantError):
"""Error to indicate that hostname/IP address is invalid."""

View File

@ -10,7 +10,6 @@ from pyvizio import VizioAsync, async_guess_device_type
from pyvizio.const import APP_HOME
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import zeroconf
from homeassistant.components.media_player import MediaPlayerDeviceClass
from homeassistant.config_entries import (
@ -18,6 +17,9 @@ from homeassistant.config_entries import (
SOURCE_IMPORT,
SOURCE_ZEROCONF,
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.const import (
CONF_ACCESS_TOKEN,
@ -29,7 +31,6 @@ from homeassistant.const import (
CONF_PIN,
)
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
from homeassistant.util.network import is_ip_address
@ -103,7 +104,7 @@ def _host_is_same(host1: str, host2: str) -> bool:
return host1 == host2
class VizioOptionsConfigFlow(config_entries.OptionsFlow):
class VizioOptionsConfigFlow(OptionsFlow):
"""Handle Vizio options."""
def __init__(self, config_entry: ConfigEntry) -> None:
@ -112,7 +113,7 @@ class VizioOptionsConfigFlow(config_entries.OptionsFlow):
async def async_step_init(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Manage the vizio options."""
if user_input is not None:
if user_input.get(CONF_APPS_TO_INCLUDE_OR_EXCLUDE):
@ -173,7 +174,7 @@ class VizioOptionsConfigFlow(config_entries.OptionsFlow):
return self.async_show_form(step_id="init", data_schema=options)
class VizioConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class VizioConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a Vizio config flow."""
VERSION = 1
@ -193,7 +194,7 @@ class VizioConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
self._data: dict[str, Any] | None = None
self._apps: dict[str, list] = {}
async def _create_entry(self, input_dict: dict[str, Any]) -> FlowResult:
async def _create_entry(self, input_dict: dict[str, Any]) -> ConfigFlowResult:
"""Create vizio config entry."""
# Remove extra keys that will not be used by entry setup
input_dict.pop(CONF_APPS_TO_INCLUDE_OR_EXCLUDE, None)
@ -206,7 +207,7 @@ class VizioConfigFlow(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: dict[str, str] = {}
@ -283,7 +284,9 @@ class VizioConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
return self.async_show_form(step_id="user", data_schema=schema, 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:
"""Import a config entry from configuration.yaml."""
# Check if new config entry matches any existing config entries
for entry in self._async_current_entries():
@ -347,7 +350,7 @@ class VizioConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_zeroconf(
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle zeroconf discovery."""
host = discovery_info.host
# If host already has port, no need to add it again
@ -387,7 +390,7 @@ class VizioConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_pair_tv(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Start pairing process for TV.
Ask user for PIN to complete pairing process.
@ -452,7 +455,7 @@ class VizioConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
errors=errors,
)
async def _pairing_complete(self, step_id: str) -> FlowResult:
async def _pairing_complete(self, step_id: str) -> ConfigFlowResult:
"""Handle config flow completion."""
assert self._data
if not self._must_show_form:
@ -466,7 +469,7 @@ class VizioConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_pairing_complete(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Complete non-import sourced config flow.
Display final message to user confirming pairing.
@ -475,7 +478,7 @@ class VizioConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_pairing_complete_import(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Complete import sourced config flow.
Display final message to user confirming pairing and displaying

View File

@ -9,11 +9,11 @@ from aiovlc.client import Client
from aiovlc.exceptions import AuthError, ConnectError
import voluptuous as vol
from homeassistant import core, exceptions
from homeassistant.components.hassio import HassioServiceInfo
from homeassistant.config_entries import ConfigEntry, ConfigFlow
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PASSWORD, CONF_PORT
from homeassistant.data_entry_flow import FlowResult
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
from .const import DEFAULT_PORT, DOMAIN
@ -46,9 +46,7 @@ async def vlc_connect(vlc: Client) -> None:
await vlc.disconnect()
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."""
vlc = Client(
password=data[CONF_PASSWORD],
@ -76,7 +74,7 @@ class VLCTelnetConfigFlow(ConfigFlow, domain=DOMAIN):
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(
@ -105,7 +103,9 @@ class VLCTelnetConfigFlow(ConfigFlow, domain=DOMAIN):
step_id="user", data_schema=user_form_schema(user_input), 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:
"""Handle reauth flow."""
self.entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
assert self.entry
@ -114,7 +114,7 @@ class VLCTelnetConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_reauth_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle reauth confirm."""
assert self.entry
errors = {}
@ -149,7 +149,9 @@ class VLCTelnetConfigFlow(ConfigFlow, domain=DOMAIN):
errors=errors,
)
async def async_step_hassio(self, discovery_info: HassioServiceInfo) -> FlowResult:
async def async_step_hassio(
self, discovery_info: HassioServiceInfo
) -> ConfigFlowResult:
"""Handle the discovery step via hassio."""
await self.async_set_unique_id("hassio")
self._abort_if_unique_id_configured(discovery_info.config)
@ -160,7 +162,7 @@ class VLCTelnetConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_hassio_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Confirm Supervisor discovery."""
assert self.hassio_discovery
if user_input is None:
@ -184,9 +186,9 @@ class VLCTelnetConfigFlow(ConfigFlow, domain=DOMAIN):
return self.async_create_entry(title=info["title"], data=self.hassio_discovery)
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

@ -14,12 +14,12 @@ from homeassistant.components.device_tracker import (
from homeassistant.config_entries import (
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
OptionsFlowWithConfigEntry,
)
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import HomeAssistant, callback
from homeassistant.data_entry_flow import FlowResult
from .const import _LOGGER, DEFAULT_HOST, DEFAULT_USERNAME, DOMAIN
@ -69,7 +69,7 @@ class VodafoneStationConfigFlow(ConfigFlow, domain=DOMAIN):
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(
@ -101,7 +101,9 @@ class VodafoneStationConfigFlow(ConfigFlow, domain=DOMAIN):
step_id="user", data_schema=user_form_schema(user_input), 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:
"""Handle reauth flow."""
self.entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
assert self.entry
@ -110,7 +112,7 @@ class VodafoneStationConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_reauth_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle reauth confirm."""
assert self.entry
errors = {}
@ -153,7 +155,7 @@ class VodafoneStationOptionsFlowHandler(OptionsFlowWithConfigEntry):
async def async_step_init(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle options flow."""
if user_input is not None:

View File

@ -6,22 +6,26 @@ from typing import Any
from voip_utils import SIP_PORT
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import (
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import config_validation as cv
from .const import CONF_SIP_PORT, DOMAIN
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class VoIPConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for VoIP integration."""
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")
@ -39,22 +43,22 @@ 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:
"""Create the options flow."""
return VoipOptionsFlowHandler(config_entry)
class VoipOptionsFlowHandler(config_entries.OptionsFlow):
class VoipOptionsFlowHandler(OptionsFlow):
"""Handle VoIP 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 the options."""
if user_input is not None:
return self.async_create_entry(title="", data=user_input)

View File

@ -6,11 +6,11 @@ import logging
from pyvolumio import CannotConnectError, Volumio
import voluptuous as vol
from homeassistant import config_entries, exceptions
from homeassistant.components import zeroconf
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_HOST, CONF_ID, CONF_NAME, CONF_PORT
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import DOMAIN
@ -33,7 +33,7 @@ async def validate_input(hass, host, port):
raise CannotConnect from error
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class VolumioConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Volumio."""
VERSION = 1
@ -96,7 +96,7 @@ class ConfigFlow(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
@ -121,5 +121,5 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
)
class CannotConnect(exceptions.HomeAssistantError):
class CannotConnect(HomeAssistantError):
"""Error to indicate we cannot connect."""

View File

@ -8,14 +8,13 @@ from typing import Any
import voluptuous as vol
from volvooncall import Connection
from homeassistant import config_entries
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.const import (
CONF_PASSWORD,
CONF_REGION,
CONF_UNIT_SYSTEM,
CONF_USERNAME,
)
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from . import VolvoData
@ -31,15 +30,15 @@ from .errors import InvalidAuth
_LOGGER = logging.getLogger(__name__)
class VolvoOnCallConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class VolvoOnCallConfigFlow(ConfigFlow, domain=DOMAIN):
"""VolvoOnCall config flow."""
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 user step."""
errors = {}
defaults = {
@ -106,7 +105,9 @@ class VolvoOnCallConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
step_id="user", data_schema=user_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

@ -16,9 +16,8 @@ from vulcan import (
Vulcan,
)
from homeassistant import config_entries
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_PIN, CONF_REGION, CONF_TOKEN
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from . import DOMAIN
@ -33,7 +32,7 @@ LOGIN_SCHEMA = {
}
class VulcanFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class VulcanFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a Uonet+ Vulcan config flow."""
VERSION = 1
@ -241,7 +240,9 @@ class VulcanFlowHandler(config_entries.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."""
return await self.async_step_reauth_confirm()

View File

@ -7,9 +7,9 @@ from typing import Any
import voluptuous as vol
from wallbox import Wallbox
from homeassistant import config_entries, core
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.data_entry_flow import FlowResult
from homeassistant.core import HomeAssistant
from .const import CONF_STATION, DOMAIN
from .coordinator import InvalidAuth, WallboxCoordinator
@ -25,9 +25,7 @@ STEP_USER_DATA_SCHEMA = 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 to connect.
Data has the keys from STEP_USER_DATA_SCHEMA with values provided by the user.
@ -41,14 +39,16 @@ async def validate_input(
return {"title": "Wallbox Portal"}
class ConfigFlow(config_entries.ConfigFlow, domain=COMPONENT_DOMAIN):
class WallboxConfigFlow(ConfigFlow, domain=COMPONENT_DOMAIN):
"""Handle a config flow for Wallbox."""
def __init__(self) -> None:
"""Start the Wallbox config flow."""
self._reauth_entry: config_entries.ConfigEntry | None = None
self._reauth_entry: ConfigEntry | None = None
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"]
@ -58,7 +58,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=COMPONENT_DOMAIN):
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

@ -12,7 +12,7 @@ from aiowaqi import (
)
import voluptuous as vol
from homeassistant.config_entries import ConfigFlow
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import (
CONF_API_KEY,
CONF_LATITUDE,
@ -22,7 +22,7 @@ from homeassistant.const import (
CONF_NAME,
)
from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN
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.issue_registry import IssueSeverity, async_create_issue
from homeassistant.helpers.selector import (
@ -66,7 +66,7 @@ class WAQIConfigFlow(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] = {}
if user_input is not None:
@ -107,7 +107,7 @@ class WAQIConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_map(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Add measuring station via map."""
errors: dict[str, str] = {}
if user_input is not None:
@ -149,7 +149,7 @@ class WAQIConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_station_number(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Add measuring station via station number."""
errors: dict[str, str] = {}
if user_input is not None:
@ -182,7 +182,7 @@ class WAQIConfigFlow(ConfigFlow, domain=DOMAIN):
async def _async_create_entry(
self, measuring_station: WAQIAirQuality
) -> FlowResult:
) -> ConfigFlowResult:
await self.async_set_unique_id(str(measuring_station.station_id))
self._abort_if_unique_id_configured()
return self.async_create_entry(
@ -193,7 +193,7 @@ class WAQIConfigFlow(ConfigFlow, domain=DOMAIN):
},
)
async def async_step_import(self, import_config: ConfigType) -> FlowResult:
async def async_step_import(self, import_config: ConfigType) -> ConfigFlowResult:
"""Handle importing from yaml."""
await self.async_set_unique_id(str(import_config[CONF_STATION_NUMBER]))
try:

View File

@ -8,8 +8,12 @@ from aiowatttime import Client
from aiowatttime.errors import CoordinatesNotFoundError, InvalidCredentialsError
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigEntry, OptionsFlow
from homeassistant.config_entries import (
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.const import (
CONF_LATITUDE,
CONF_LONGITUDE,
@ -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 aiohttp_client, config_validation as cv
from .const import (
@ -68,7 +71,7 @@ def get_unique_id(data: dict[str, Any]) -> str:
return f"{data[CONF_LATITUDE]}, {data[CONF_LONGITUDE]}"
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class WattTimeConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for WattTime."""
VERSION = 1
@ -80,7 +83,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def _async_validate_credentials(
self, username: str, password: str, error_step_id: str, error_schema: vol.Schema
) -> FlowResult:
) -> ConfigFlowResult:
"""Validate input credentials and proceed accordingly."""
session = aiohttp_client.async_get_clientsession(self.hass)
@ -128,7 +131,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_coordinates(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the coordinates step."""
if not user_input:
return self.async_show_form(
@ -174,7 +177,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 "pick a location" step."""
if not user_input:
return self.async_show_form(
@ -190,14 +193,16 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
)
return await self.async_step_coordinates()
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 = {**entry_data}
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-auth completion."""
if not user_input:
return self.async_show_form(
@ -217,7 +222,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 not user_input:
return self.async_show_form(
@ -232,7 +237,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
)
class WattTimeOptionsFlowHandler(config_entries.OptionsFlow):
class WattTimeOptionsFlowHandler(OptionsFlow):
"""Handle a WattTime options flow."""
def __init__(self, entry: ConfigEntry) -> None:
@ -241,7 +246,7 @@ class WattTimeOptionsFlowHandler(config_entries.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(data=user_input)

View File

@ -3,10 +3,14 @@ from __future__ import annotations
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import (
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.const import CONF_NAME, CONF_REGION
from homeassistant.core import HomeAssistant, callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.selector import (
BooleanSelector,
SelectSelector,
@ -86,14 +90,14 @@ def default_options(hass: HomeAssistant) -> dict[str, str | bool]:
return defaults
class WazeOptionsFlow(config_entries.OptionsFlow):
class WazeOptionsFlow(OptionsFlow):
"""Handle an options flow for Waze Travel Time."""
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
def __init__(self, config_entry: ConfigEntry) -> None:
"""Initialize waze options flow."""
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:
"""Handle the initial step."""
if user_input is not None:
return self.async_create_entry(
@ -109,7 +113,7 @@ class WazeOptionsFlow(config_entries.OptionsFlow):
)
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class WazeConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Waze Travel Time."""
VERSION = 1
@ -117,12 +121,12 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
@staticmethod
@callback
def async_get_options_flow(
config_entry: config_entries.ConfigEntry,
config_entry: ConfigEntry,
) -> WazeOptionsFlow:
"""Get the options flow for this handler."""
return WazeOptionsFlow(config_entry)
async def async_step_user(self, user_input=None) -> FlowResult:
async def async_step_user(self, user_input=None) -> ConfigFlowResult:
"""Handle the initial step."""
errors = {}
user_input = user_input or {}

View File

@ -9,9 +9,8 @@ from typing import Any
from pyweatherflowudp.client import EVENT_DEVICE_DISCOVERED, WeatherFlowListener
from pyweatherflowudp.errors import AddressInUseError, EndpointError, ListenerError
from homeassistant import config_entries
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from .const import (
DOMAIN,
@ -42,14 +41,14 @@ async def _async_can_discover_devices() -> bool:
return True
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class WeatherFlowConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for WeatherFlow."""
VERSION = 1
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initialized by the user."""
# Only allow a single instance of integration since the listener

View File

@ -10,7 +10,6 @@ from weatherflow4py.api import WeatherFlowRestAPI
from homeassistant import config_entries
from homeassistant.const import CONF_API_TOKEN
from homeassistant.data_entry_flow import FlowResult
from .const import DOMAIN
@ -32,7 +31,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
VERSION = 1
async def async_step_reauth(self, user_input: Mapping[str, Any]) -> FlowResult:
async def async_step_reauth(
self, user_input: Mapping[str, Any]
) -> config_entries.ConfigFlowResult:
"""Handle a flow for reauth."""
errors = {}
@ -58,7 +59,7 @@ class ConfigFlow(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 initialized by the user."""
errors = {}

View File

@ -12,7 +12,7 @@ from apple_weatherkit.client import (
)
import voluptuous as vol
from homeassistant import config_entries, data_entry_flow
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_LATITUDE, CONF_LOCATION, CONF_LONGITUDE
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.selector import (
@ -53,7 +53,7 @@ class WeatherKitUnsupportedLocationError(Exception):
"""Error to indicate a location is unsupported."""
class WeatherKitFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class WeatherKitFlowHandler(ConfigFlow, domain=DOMAIN):
"""Config flow for WeatherKit."""
VERSION = 1
@ -61,7 +61,7 @@ class WeatherKitFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user(
self,
user_input: dict[str, Any] | None = None,
) -> data_entry_flow.FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initialized by the user."""
errors = {}
if user_input is not None:

View File

@ -10,10 +10,15 @@ from aiowebostv import WebOsTvPairError
import voluptuous as vol
from homeassistant.components import ssdp
from homeassistant.config_entries import ConfigEntry, ConfigFlow, OptionsFlow
from homeassistant.config_entries import (
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.const import CONF_CLIENT_SECRET, CONF_HOST, CONF_NAME
from homeassistant.core import 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 . import async_control_connect, update_client_key
@ -51,7 +56,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."""
errors: dict[str, str] = {}
if user_input is not None:
@ -82,7 +87,7 @@ class FlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_pairing(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Display pairing form."""
self._async_check_configured_entry()
@ -107,7 +112,9 @@ class FlowHandler(ConfigFlow, domain=DOMAIN):
return self.async_show_form(step_id="pairing", 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 flow initialized by discovery."""
assert discovery_info.ssdp_location
host = urlparse(discovery_info.ssdp_location).hostname
@ -129,7 +136,9 @@ class FlowHandler(ConfigFlow, domain=DOMAIN):
self._uuid = uuid
return await self.async_step_pairing()
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 WebOsTvPairError."""
self._host = entry_data[CONF_HOST]
self._entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
@ -137,7 +146,7 @@ class FlowHandler(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."""
assert self._entry is not None
@ -168,7 +177,7 @@ class OptionsFlowHandler(OptionsFlow):
async def async_step_init(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Manage the options."""
errors = {}
if user_input is not None:

View File

@ -8,9 +8,8 @@ from typing import Any, get_type_hints
import pywemo
import voluptuous as vol
from homeassistant.config_entries import ConfigEntry, OptionsFlow
from homeassistant.config_entries import ConfigEntry, ConfigFlowResult, OptionsFlow
from homeassistant.core import HomeAssistant, callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.config_entry_flow import DiscoveryFlowHandler
from .const import DOMAIN
@ -45,7 +44,7 @@ class WemoOptionsFlow(OptionsFlow):
async def async_step_init(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Manage options for the WeMo component."""
errors: dict[str, str] | None = None
if user_input is not None:

View File

@ -11,9 +11,10 @@ from whirlpool.appliancesmanager import AppliancesManager
from whirlpool.auth import Auth
from whirlpool.backendselector import BackendSelector
from homeassistant import config_entries, core, exceptions
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_PASSWORD, CONF_REGION, CONF_USERNAME
from homeassistant.data_entry_flow import FlowResult
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import CONF_REGIONS_MAP, DOMAIN
@ -33,9 +34,7 @@ STEP_USER_DATA_SCHEMA = vol.Schema(
REAUTH_SCHEMA = vol.Schema({vol.Required(CONF_PASSWORD): str})
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.
Data has the keys from STEP_USER_DATA_SCHEMA with values provided by the user.
@ -61,13 +60,15 @@ async def validate_input(
return {"title": data[CONF_USERNAME]}
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class WhirlpoolConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Whirlpool Sixth Sense."""
VERSION = 1
entry: config_entries.ConfigEntry | None
entry: ConfigEntry | None
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 re-authentication with Whirlpool Sixth Sense."""
self.entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
@ -75,7 +76,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_reauth_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Confirm re-authentication with Whirlpool Sixth Sense."""
errors: dict[str, str] = {}
@ -110,7 +111,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
errors=errors,
)
async def async_step_user(self, user_input=None) -> FlowResult:
async def async_step_user(self, user_input=None) -> ConfigFlowResult:
"""Handle the initial step."""
if user_input is None:
return self.async_show_form(
@ -142,13 +143,13 @@ 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 NoAppliances(exceptions.HomeAssistantError):
class NoAppliances(HomeAssistantError):
"""Error to indicate no supported appliances in the user account."""

View File

@ -12,9 +12,8 @@ from whois.exceptions import (
WhoisCommandFailed,
)
from homeassistant.config_entries import ConfigFlow
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_DOMAIN
from homeassistant.data_entry_flow import FlowResult
from .const import DOMAIN
@ -28,7 +27,7 @@ class WhoisFlowHandler(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

@ -9,14 +9,14 @@ import errno
import voluptuous as vol
from wiffi import WiffiTcpServer
from homeassistant import config_entries
from homeassistant.config_entries import ConfigEntry, ConfigFlow, OptionsFlow
from homeassistant.const import CONF_PORT, CONF_TIMEOUT
from homeassistant.core import callback
from .const import DEFAULT_PORT, DEFAULT_TIMEOUT, DOMAIN
class WiffiFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class WiffiFlowHandler(ConfigFlow, domain=DOMAIN):
"""Wiffi server setup config flow."""
VERSION = 1
@ -24,7 +24,7 @@ class WiffiFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
@staticmethod
@callback
def async_get_options_flow(
config_entry: config_entries.ConfigEntry,
config_entry: ConfigEntry,
) -> OptionsFlowHandler:
"""Create Wiffi server setup option flow."""
return OptionsFlowHandler(config_entry)
@ -67,10 +67,10 @@ class WiffiFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
)
class OptionsFlowHandler(config_entries.OptionsFlow):
class OptionsFlowHandler(OptionsFlow):
"""Wiffi server setup option flow."""
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

@ -4,9 +4,8 @@ from urllib.parse import urlparse
import pywilight
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 homeassistant.data_entry_flow import FlowResult
from . import DOMAIN
@ -50,7 +49,9 @@ class WiLightFlowHandler(ConfigFlow, domain=DOMAIN):
}
return self.async_create_entry(title=self._title, data=data)
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 WiLight."""
# Filter out basic information
if (

View File

@ -8,9 +8,8 @@ from typing import Any
from aiowithings import AuthScope
from homeassistant.components.webhook import async_generate_id
from homeassistant.config_entries import ConfigEntry
from homeassistant.config_entries import ConfigEntry, ConfigFlowResult
from homeassistant.const import CONF_TOKEN, CONF_WEBHOOK_ID
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import config_entry_oauth2_flow
from .const import CONF_USE_WEBHOOK, DEFAULT_TITLE, DOMAIN
@ -44,7 +43,9 @@ class WithingsFlowHandler(
)
}
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"]
@ -53,13 +54,13 @@ class WithingsFlowHandler(
async def async_step_reauth_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Confirm reauth dialog."""
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 entry for the flow, or update existing entry."""
user_id = str(data[CONF_TOKEN]["userid"])
if not self.reauth_entry:

View File

@ -10,9 +10,9 @@ from pywizlight.exceptions import WizLightConnectionError, WizLightTimeOutError
import voluptuous as vol
from homeassistant.components import dhcp, onboarding
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 AbortFlow, FlowResult
from homeassistant.data_entry_flow import AbortFlow
from homeassistant.util.network import is_ip_address
from .const import DEFAULT_NAME, DISCOVER_SCAN_TIMEOUT, DOMAIN, WIZ_CONNECT_EXCEPTIONS
@ -36,7 +36,9 @@ class WizConfigFlow(ConfigFlow, domain=DOMAIN):
"""Initialize the config flow."""
self._discovered_devices: dict[str, DiscoveredBulb] = {}
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."""
self._discovered_device = DiscoveredBulb(
discovery_info.ip, discovery_info.macaddress
@ -45,14 +47,14 @@ class WizConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_integration_discovery(
self, discovery_info: dict[str, str]
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle integration discovery."""
self._discovered_device = DiscoveredBulb(
discovery_info["ip_address"], discovery_info["mac_address"]
)
return await self._async_handle_discovery()
async def _async_handle_discovery(self) -> FlowResult:
async def _async_handle_discovery(self) -> ConfigFlowResult:
"""Handle any discovery."""
device = self._discovered_device
_LOGGER.debug("Discovered device: %s", device)
@ -81,7 +83,7 @@ class WizConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_discovery_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Confirm discovery."""
ip_address = self._discovered_device.ip_address
if user_input is not None or not onboarding.async_is_onboarded(self.hass):
@ -104,7 +106,7 @@ class WizConfigFlow(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:
device = self._discovered_devices[user_input[CONF_DEVICE]]
@ -146,7 +148,7 @@ class WizConfigFlow(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,10 +7,14 @@ import voluptuous as vol
from wled import WLED, Device, WLEDConnectionError
from homeassistant.components import onboarding, zeroconf
from homeassistant.config_entries import ConfigEntry, ConfigFlow, OptionsFlow
from homeassistant.config_entries import (
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.const import CONF_HOST, CONF_MAC
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import CONF_KEEP_MAIN_LIGHT, DEFAULT_KEEP_MAIN_LIGHT, DOMAIN
@ -31,7 +35,7 @@ class WLEDFlowHandler(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 = {}
@ -64,7 +68,7 @@ class WLEDFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_zeroconf(
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle zeroconf discovery."""
# Abort quick if the mac address is provided by discovery info
if mac := discovery_info.properties.get(CONF_MAC):
@ -95,7 +99,7 @@ class WLEDFlowHandler(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."""
if user_input is not None or not onboarding.async_is_onboarded(self.hass):
return self.async_create_entry(
@ -126,7 +130,7 @@ class WLEDOptionsFlowHandler(OptionsFlow):
async def async_step_init(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Manage WLED options."""
if user_input is not None:
return self.async_create_entry(title="", data=user_input)

View File

@ -6,7 +6,7 @@ import voluptuous as vol
from wolf_comm.token_auth import InvalidAuth
from wolf_comm.wolf_client import WolfClient
from homeassistant import config_entries
from homeassistant.config_entries import ConfigFlow
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from .const import DEVICE_GATEWAY, DEVICE_ID, DEVICE_NAME, DOMAIN
@ -18,7 +18,7 @@ USER_SCHEMA = vol.Schema(
)
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class WolfLinkConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Wolf SmartSet Service."""
VERSION = 1

View File

@ -10,11 +10,12 @@ import voluptuous as vol
from homeassistant.config_entries import (
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlowWithConfigEntry,
)
from homeassistant.const import CONF_COUNTRY, CONF_LANGUAGE, CONF_NAME
from homeassistant.core import callback
from homeassistant.data_entry_flow import AbortFlow, FlowResult
from homeassistant.data_entry_flow import AbortFlow
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.selector import (
CountrySelector,
@ -200,7 +201,7 @@ class WorkdayConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the user initial step."""
errors: dict[str, str] = {}
@ -228,7 +229,7 @@ class WorkdayConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_options(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle remaining flow."""
errors: dict[str, str] = {}
if user_input is not None:
@ -290,7 +291,7 @@ class WorkdayOptionsFlowHandler(OptionsFlowWithConfigEntry):
async def async_step_init(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Manage Workday options."""
errors: dict[str, str] = {}

View File

@ -7,8 +7,10 @@ from typing import Any
from pyws66i import WS66i, get_ws66i
import voluptuous as vol
from homeassistant import config_entries, core, exceptions
from homeassistant.config_entries import ConfigEntry, ConfigFlow, OptionsFlow
from homeassistant.const import CONF_IP_ADDRESS
from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import HomeAssistantError
from .const import (
CONF_SOURCE_1,
@ -40,7 +42,7 @@ DATA_SCHEMA = vol.Schema({vol.Required(CONF_IP_ADDRESS): str})
FIRST_ZONE = 11
@core.callback
@callback
def _sources_from_config(data):
sources_config = {
str(idx + 1): data.get(source) for idx, source in enumerate(SOURCES)
@ -70,7 +72,7 @@ def _verify_connection(ws66i: WS66i) -> bool:
async def validate_input(
hass: core.HomeAssistant, input_data: dict[str, Any]
hass: HomeAssistant, input_data: dict[str, Any]
) -> dict[str, Any]:
"""Validate the user input.
@ -86,7 +88,7 @@ async def validate_input(
return {CONF_IP_ADDRESS: input_data[CONF_IP_ADDRESS]}
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class WS66iConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for WS66i 6-Zone Amplifier."""
VERSION = 1
@ -115,15 +117,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,
) -> Ws66iOptionsFlowHandler:
"""Define the config flow to handle options."""
return Ws66iOptionsFlowHandler(config_entry)
@core.callback
@callback
def _key_for_source(index, source, previous_sources):
key = vol.Required(
source, description={"suggested_value": previous_sources[str(index)]}
@ -132,10 +134,10 @@ def _key_for_source(index, source, previous_sources):
return key
class Ws66iOptionsFlowHandler(config_entries.OptionsFlow):
class Ws66iOptionsFlowHandler(OptionsFlow):
"""Handle a WS66i options flow."""
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
def __init__(self, config_entry: ConfigEntry) -> None:
"""Initialize."""
self.config_entry = config_entry
@ -160,5 +162,5 @@ class Ws66iOptionsFlowHandler(config_entries.OptionsFlow):
)
class CannotConnect(exceptions.HomeAssistantError):
class CannotConnect(HomeAssistantError):
"""Error to indicate we cannot connect."""

View File

@ -7,10 +7,9 @@ from urllib.parse import urlparse
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import hassio, zeroconf
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT
from homeassistant.data_entry_flow import FlowResult
from .const import DOMAIN
from .data import WyomingService
@ -25,7 +24,7 @@ STEP_USER_DATA_SCHEMA = vol.Schema(
)
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class WyomingConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Wyoming integration."""
VERSION = 1
@ -36,7 +35,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 user_input is None:
return self.async_show_form(
@ -62,7 +61,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_hassio(
self, discovery_info: hassio.HassioServiceInfo
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle Supervisor add-on discovery."""
_LOGGER.debug("Supervisor discovery info: %s", discovery_info)
await self.async_set_unique_id(discovery_info.uuid)
@ -79,7 +78,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 Supervisor discovery."""
errors: dict[str, str] = {}
@ -104,7 +103,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_zeroconf(
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle zeroconf discovery."""
_LOGGER.debug("Zeroconf discovery info: %s", discovery_info)
if discovery_info.port is None:
@ -131,7 +130,7 @@ class ConfigFlow(config_entries.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."""
assert self._service is not None
assert self._name is not None

View File

@ -5,11 +5,10 @@ from socket import gaierror
import voluptuous as vol
from xiaomi_gateway import MULTICAST_PORT, XiaomiGateway, XiaomiGatewayDiscovery
from homeassistant import config_entries
from homeassistant.components import zeroconf
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_HOST, CONF_MAC, CONF_NAME, CONF_PORT, CONF_PROTOCOL
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.device_registry import format_mac
from .const import (
@ -44,7 +43,7 @@ GATEWAY_SETTINGS = vol.Schema(
)
class XiaomiAqaraFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class XiaomiAqaraFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a Xiaomi Aqara config flow."""
VERSION = 1
@ -148,7 +147,7 @@ class XiaomiAqaraFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_zeroconf(
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle zeroconf discovery."""
name = discovery_info.name
self.host = discovery_info.host

View File

@ -16,9 +16,8 @@ from homeassistant.components.bluetooth import (
async_discovered_service_info,
async_process_advertisements,
)
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
@ -76,7 +75,7 @@ class XiaomiConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_bluetooth(
self, discovery_info: BluetoothServiceInfo
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the bluetooth discovery step."""
await self.async_set_unique_id(discovery_info.address)
self._abort_if_unique_id_configured()
@ -109,7 +108,7 @@ class XiaomiConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_get_encryption_key_legacy(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Enter a legacy bindkey for a v2/v3 MiBeacon device."""
assert self._discovery_info
assert self._discovered_device
@ -143,7 +142,7 @@ class XiaomiConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_get_encryption_key_4_5(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Enter a bindkey for a v4/v5 MiBeacon device."""
assert self._discovery_info
assert self._discovered_device
@ -177,7 +176,7 @@ class XiaomiConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_bluetooth_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Confirm discovery."""
if user_input is not None or not onboarding.async_is_onboarded(self.hass):
return self._async_get_or_create_entry()
@ -190,7 +189,7 @@ class XiaomiConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_confirm_slow(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Ack that device is slow."""
if user_input is not None:
return self._async_get_or_create_entry()
@ -203,7 +202,7 @@ class XiaomiConfigFlow(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]
@ -260,7 +259,9 @@ class XiaomiConfigFlow(ConfigFlow, domain=DOMAIN):
data_schema=vol.Schema({vol.Required(CONF_ADDRESS): vol.In(titles)}),
)
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 flow initialized by a reauth event."""
entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
assert entry is not None
@ -279,7 +280,9 @@ class XiaomiConfigFlow(ConfigFlow, domain=DOMAIN):
# Otherwise there wasn't actually encryption so abort
return self.async_abort(reason="reauth_successful")
def _async_get_or_create_entry(self, bindkey: str | None = None) -> FlowResult:
def _async_get_or_create_entry(
self, bindkey: str | None = None
) -> ConfigFlowResult:
data: dict[str, Any] = {}
if bindkey:

View File

@ -10,12 +10,16 @@ from micloud import MiCloud
from micloud.micloudexception import MiCloudAccessDenied
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import zeroconf
from homeassistant.config_entries import SOURCE_REAUTH, ConfigEntry
from homeassistant.config_entries import (
SOURCE_REAUTH,
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.const import CONF_DEVICE, CONF_HOST, CONF_MAC, CONF_MODEL, CONF_TOKEN
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.device_registry import format_mac
from .const import (
@ -56,16 +60,16 @@ DEVICE_CLOUD_CONFIG = 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 = {}
if user_input is not None:
@ -104,7 +108,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
)
class XiaomiMiioFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class XiaomiMiioFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a Xiaomi Miio config flow."""
VERSION = 1
@ -127,7 +131,9 @@ class XiaomiMiioFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
"""Get the options flow."""
return OptionsFlowHandler(config_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 authentication error or missing cloud credentials."""
self.host = entry_data[CONF_HOST]
self.token = entry_data[CONF_TOKEN]
@ -137,7 +143,7 @@ class XiaomiMiioFlowHandler(config_entries.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 user_input is not None:
return await self.async_step_cloud()
@ -145,13 +151,13 @@ class XiaomiMiioFlowHandler(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_cloud()
async def async_step_zeroconf(
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle zeroconf discovery."""
name = discovery_info.name
self.host = discovery_info.host
@ -213,7 +219,7 @@ class XiaomiMiioFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_cloud(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Configure a xiaomi miio device through the Miio Cloud."""
errors = {}
if user_input is not None:
@ -290,7 +296,7 @@ class XiaomiMiioFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_select(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle multiple cloud devices found."""
errors: dict[str, str] = {}
if user_input is not None:
@ -308,7 +314,7 @@ class XiaomiMiioFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_manual(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Configure a xiaomi miio device Manually."""
errors: dict[str, str] = {}
if user_input is not None:
@ -327,7 +333,7 @@ class XiaomiMiioFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_connect(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Connect to a xiaomi miio device."""
errors: dict[str, str] = {}
if self.host is None or self.token is None:

View File

@ -8,10 +8,14 @@ import voluptuous as vol
from yalesmartalarmclient.client import YaleSmartAlarmClient
from yalesmartalarmclient.exceptions import AuthenticationError
from homeassistant.config_entries import ConfigEntry, ConfigFlow, OptionsFlow
from homeassistant.config_entries import (
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.const import CONF_NAME, CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
import homeassistant.helpers.config_validation as cv
from .const import (
@ -54,14 +58,16 @@ class YaleConfigFlow(ConfigFlow, domain=DOMAIN):
"""Get the options flow for this handler."""
return YaleOptionsFlowHandler(config_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:
"""Handle initiation of re-authentication with Yale."""
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 = {}
@ -102,7 +108,7 @@ class YaleConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the initial step."""
errors = {}
@ -153,7 +159,7 @@ class YaleOptionsFlowHandler(OptionsFlow):
async def async_step_init(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Manage Yale options."""
errors: dict[str, Any] = {}

View File

@ -16,15 +16,20 @@ from yalexs_ble import (
)
from yalexs_ble.const import YALE_MFR_ID
from homeassistant import config_entries, data_entry_flow
from homeassistant.components.bluetooth import (
BluetoothServiceInfoBleak,
async_ble_device_from_address,
async_discovered_service_info,
)
from homeassistant.config_entries import (
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.const import CONF_ADDRESS
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.data_entry_flow import AbortFlow
from homeassistant.helpers.typing import DiscoveryInfoType
from .const import CONF_ALWAYS_CONNECTED, CONF_KEY, CONF_LOCAL_NAME, CONF_SLOT, DOMAIN
@ -57,7 +62,7 @@ async def async_validate_lock_or_error(
return {}
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class YalexsConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Yale Access Bluetooth."""
VERSION = 1
@ -67,11 +72,11 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
self._discovery_info: BluetoothServiceInfoBleak | None = None
self._discovered_devices: dict[str, BluetoothServiceInfoBleak] = {}
self._lock_cfg: ValidatedLockConfig | None = None
self._reauth_entry: config_entries.ConfigEntry | None = None
self._reauth_entry: ConfigEntry | None = None
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()
@ -86,7 +91,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_integration_discovery(
self, discovery_info: DiscoveryInfoType
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a discovered integration."""
lock_cfg = ValidatedLockConfig(
discovery_info["name"],
@ -137,7 +142,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
# and entered the keys. We abort the discovery flow since
# we assume they do not want to use the discovered keys for
# some reason.
raise data_entry_flow.AbortFlow("already_in_progress")
raise AbortFlow("already_in_progress")
hass.config_entries.flow.async_abort(progress["flow_id"])
self._lock_cfg = lock_cfg
@ -150,7 +155,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_integration_discovery_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a confirmation of discovered integration."""
assert self._discovery_info is not None
assert self._lock_cfg is not None
@ -174,7 +179,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:
"""Handle configuration by re-auth."""
self._reauth_entry = self.hass.config_entries.async_get_entry(
self.context["entry_id"]
@ -183,7 +190,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_reauth_validate(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle reauth and validation."""
errors = {}
reauth_entry = self._reauth_entry
@ -221,7 +228,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] = {}
@ -296,28 +303,28 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
@staticmethod
@callback
def async_get_options_flow(
config_entry: config_entries.ConfigEntry,
config_entry: ConfigEntry,
) -> YaleXSBLEOptionsFlowHandler:
"""Get the options flow for this handler."""
return YaleXSBLEOptionsFlowHandler(config_entry)
class YaleXSBLEOptionsFlowHandler(config_entries.OptionsFlow):
class YaleXSBLEOptionsFlowHandler(OptionsFlow):
"""Handle YaleXSBLE options."""
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
def __init__(self, config_entry: ConfigEntry) -> None:
"""Initialize YaleXSBLE options flow."""
self.entry = config_entry
async def async_step_init(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Manage the YaleXSBLE options."""
return await self.async_step_device_options()
async def async_step_device_options(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Manage the YaleXSBLE devices options."""
if user_input is not None:
return self.async_create_entry(

View File

@ -32,7 +32,7 @@ class MusicCastFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> data_entry_flow.FlowResult:
) -> data_entry_flow.ConfigFlowResult:
"""Handle a flow initiated by the user."""
# Request user input, unless we are preparing discovery flow
if user_input is None:
@ -74,7 +74,7 @@ class MusicCastFlowHandler(ConfigFlow, domain=DOMAIN):
def _show_setup_form(
self, errors: dict | None = None
) -> data_entry_flow.FlowResult:
) -> data_entry_flow.ConfigFlowResult:
"""Show the setup form to the user."""
return self.async_show_form(
step_id="user",
@ -84,7 +84,7 @@ class MusicCastFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_ssdp(
self, discovery_info: ssdp.SsdpServiceInfo
) -> data_entry_flow.FlowResult:
) -> data_entry_flow.ConfigFlowResult:
"""Handle ssdp discoveries."""
if not await MusicCastDevice.check_yamaha_ssdp(
discovery_info.ssdp_location, async_get_clientsession(self.hass)
@ -116,7 +116,9 @@ class MusicCastFlowHandler(ConfigFlow, domain=DOMAIN):
return await self.async_step_confirm()
async def async_step_confirm(self, user_input=None) -> data_entry_flow.FlowResult:
async def async_step_confirm(
self, user_input=None
) -> data_entry_flow.ConfigFlowResult:
"""Allow the user to confirm adding the device."""
if user_input is not None:
return self.async_create_entry(

View File

@ -12,9 +12,8 @@ from pyyardian import (
)
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_HOST
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import DOMAIN, PRODUCT_NAME
@ -29,7 +28,7 @@ STEP_USER_DATA_SCHEMA = vol.Schema(
)
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class YardianConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Yardian."""
VERSION = 1
@ -45,7 +44,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: dict[str, str] = {}
if user_input is not None:

View File

@ -9,12 +9,17 @@ import yeelight
from yeelight.aio import AsyncBulb
from yeelight.main import get_known_models
from homeassistant import config_entries, exceptions
from homeassistant.components import dhcp, onboarding, ssdp, zeroconf
from homeassistant.config_entries import ConfigEntry, ConfigEntryState
from homeassistant.config_entries import (
ConfigEntry,
ConfigEntryState,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.const import CONF_DEVICE, CONF_HOST, CONF_ID, CONF_MODEL, CONF_NAME
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.exceptions import HomeAssistantError
import homeassistant.helpers.config_validation as cv
from .const import (
@ -40,7 +45,7 @@ MODEL_UNKNOWN = "unknown"
_LOGGER = logging.getLogger(__name__)
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class YeelightConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Yeelight."""
VERSION = 1
@ -59,19 +64,21 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_homekit(
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle discovery from homekit."""
self._discovered_ip = discovery_info.host
return await self._async_handle_discovery()
async def async_step_dhcp(self, discovery_info: dhcp.DhcpServiceInfo) -> FlowResult:
async def async_step_dhcp(
self, discovery_info: dhcp.DhcpServiceInfo
) -> ConfigFlowResult:
"""Handle discovery from dhcp."""
self._discovered_ip = discovery_info.ip
return await self._async_handle_discovery()
async def async_step_zeroconf(
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle discovery from zeroconf."""
self._discovered_ip = discovery_info.host
await self.async_set_unique_id(
@ -79,7 +86,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
)
return await self._async_handle_discovery_with_unique_id()
async def async_step_ssdp(self, discovery_info: ssdp.SsdpServiceInfo) -> FlowResult:
async def async_step_ssdp(
self, discovery_info: ssdp.SsdpServiceInfo
) -> ConfigFlowResult:
"""Handle discovery from ssdp."""
self._discovered_ip = urlparse(discovery_info.ssdp_headers["location"]).hostname
await self.async_set_unique_id(discovery_info.ssdp_headers["id"])
@ -272,7 +281,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
return MODEL_UNKNOWN
class OptionsFlowHandler(config_entries.OptionsFlow):
class OptionsFlowHandler(OptionsFlow):
"""Handle a option flow for Yeelight."""
def __init__(self, config_entry: ConfigEntry) -> None:
@ -323,5 +332,5 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
)
class CannotConnect(exceptions.HomeAssistantError):
class CannotConnect(HomeAssistantError):
"""Error to indicate we cannot connect."""

View File

@ -5,8 +5,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
@ -31,20 +30,22 @@ class OAuth2FlowHandler(
scopes = ["create"]
return {"scope": " ".join(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._reauth_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=None) -> FlowResult:
async def async_step_reauth_confirm(self, user_input=None) -> 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) -> FlowResult:
async def async_oauth_create_entry(self, data: dict) -> ConfigFlowResult:
"""Create an oauth config entry or update existing entry for reauth."""
if existing_entry := self._reauth_entry:
self.hass.config_entries.async_update_entry(
@ -56,7 +57,7 @@ class OAuth2FlowHandler(
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow start."""
existing_entry = await self.async_set_unique_id(DOMAIN)
if existing_entry and not self._reauth_entry:

View File

@ -8,9 +8,8 @@ from urllib.error import HTTPError, URLError
import voluptuous as vol
from youless_api import YoulessAPI
from homeassistant.config_entries import ConfigFlow
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_DEVICE, CONF_HOST
from homeassistant.data_entry_flow import FlowResult
from .const import DOMAIN
@ -26,7 +25,7 @@ class YoulessConfigFlow(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:

View File

@ -10,10 +10,13 @@ from youtubeaio.helper import first
from youtubeaio.types import AuthScope, ForbiddenError
from youtubeaio.youtube import YouTube
from homeassistant.config_entries import ConfigEntry, OptionsFlowWithConfigEntry
from homeassistant.config_entries import (
ConfigEntry,
ConfigFlowResult,
OptionsFlowWithConfigEntry,
)
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_TOKEN
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import config_entry_oauth2_flow
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.selector import (
@ -67,7 +70,9 @@ class OAuth2FlowHandler(
"prompt": "consent",
}
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"]
@ -76,7 +81,7 @@ class OAuth2FlowHandler(
async def async_step_reauth_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Confirm reauth dialog."""
if user_input is None:
return self.async_show_form(step_id="reauth_confirm")
@ -89,7 +94,7 @@ class OAuth2FlowHandler(
await self._youtube.set_user_authentication(token, [AuthScope.READ_ONLY])
return self._youtube
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 entry for the flow, or update existing entry."""
try:
youtube = await self.get_resource(data[CONF_TOKEN][CONF_ACCESS_TOKEN])
@ -129,7 +134,7 @@ class OAuth2FlowHandler(
async def async_step_channels(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Select which channels to track."""
if user_input:
return self.async_create_entry(
@ -164,7 +169,7 @@ class YouTubeOptionsFlowHandler(OptionsFlowWithConfigEntry):
async def async_step_init(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Initialize form."""
if user_input is not None:
return self.async_create_entry(

View File

@ -7,14 +7,13 @@ import voluptuous as vol
from zamg import ZamgData
from zamg.exceptions import ZamgApiError, ZamgNoDataError
from homeassistant import config_entries
from homeassistant.data_entry_flow import FlowResult
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import CONF_STATION_ID, DOMAIN, LOGGER
class ZamgConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class ZamgConfigFlow(ConfigFlow, domain=DOMAIN):
"""Config flow for zamg integration."""
VERSION = 1
@ -23,7 +22,7 @@ class ZamgConfigFlow(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 self._client is None:
self._client = ZamgData()

View File

@ -7,9 +7,8 @@ from typing import Any
import voluptuous as vol
import zeversolar
from homeassistant import config_entries
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_HOST
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import config_validation as cv
from .const import DOMAIN
@ -23,14 +22,14 @@ STEP_USER_DATA_SCHEMA = vol.Schema(
)
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class ZeverSolarConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for zeversolar."""
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

@ -12,15 +12,24 @@ import voluptuous as vol
import zigpy.backups
from zigpy.config import CONF_DEVICE, CONF_DEVICE_PATH
from homeassistant import config_entries
from homeassistant.components import onboarding, usb, zeroconf
from homeassistant.components.file_upload import process_uploaded_file
from homeassistant.components.hassio import AddonError, AddonState
from homeassistant.components.homeassistant_hardware import silabs_multiprotocol_addon
from homeassistant.components.homeassistant_yellow import hardware as yellow_hardware
from homeassistant.config_entries import (
SOURCE_IGNORE,
SOURCE_ZEROCONF,
ConfigEntry,
ConfigEntryBaseFlow,
ConfigEntryState,
ConfigFlow,
ConfigFlowResult,
OperationNotAllowed,
OptionsFlow,
)
from homeassistant.const import CONF_NAME
from homeassistant.core import HomeAssistant, callback
from homeassistant.data_entry_flow import FlowHandler, FlowResult
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.selector import FileSelector, FileSelectorConfig
from homeassistant.util import dt as dt_util
@ -122,7 +131,7 @@ async def list_serial_ports(hass: HomeAssistant) -> list[ListPortInfo]:
return ports
class BaseZhaFlow(FlowHandler):
class BaseZhaFlow(ConfigEntryBaseFlow):
"""Mixin for common ZHA flow steps and forms."""
_hass: HomeAssistant
@ -146,7 +155,7 @@ class BaseZhaFlow(FlowHandler):
self._hass = hass
self._radio_mgr.hass = hass
async def _async_create_radio_entry(self) -> FlowResult:
async def _async_create_radio_entry(self) -> ConfigFlowResult:
"""Create a config entry with the current flow state."""
assert self._title is not None
assert self._radio_mgr.radio_type is not None
@ -168,7 +177,7 @@ class BaseZhaFlow(FlowHandler):
async def async_step_choose_serial_port(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Choose a serial port."""
ports = await list_serial_ports(self.hass)
list_of_ports = [
@ -232,7 +241,7 @@ class BaseZhaFlow(FlowHandler):
async def async_step_manual_pick_radio_type(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Manually select the radio type."""
if user_input is not None:
self._radio_mgr.radio_type = RadioType.get_by_description(
@ -257,7 +266,7 @@ class BaseZhaFlow(FlowHandler):
async def async_step_manual_port_config(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Enter port settings specific for this type of radio."""
assert self._radio_mgr.radio_type is not None
errors = {}
@ -286,7 +295,7 @@ class BaseZhaFlow(FlowHandler):
if param not in SUPPORTED_PORT_SETTINGS:
continue
if source == config_entries.SOURCE_ZEROCONF and param == CONF_BAUDRATE:
if source == SOURCE_ZEROCONF and param == CONF_BAUDRATE:
value = 115200
param = vol.Required(CONF_BAUDRATE, default=value)
elif (
@ -307,7 +316,7 @@ class BaseZhaFlow(FlowHandler):
async def async_step_verify_radio(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Add a warning step to dissuade the use of deprecated radios."""
assert self._radio_mgr.radio_type is not None
@ -327,7 +336,7 @@ class BaseZhaFlow(FlowHandler):
async def async_step_choose_formation_strategy(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Choose how to deal with the current radio's settings."""
await self._radio_mgr.async_load_network_settings()
@ -370,20 +379,20 @@ class BaseZhaFlow(FlowHandler):
async def async_step_reuse_settings(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Reuse the existing network settings on the stick."""
return await self._async_create_radio_entry()
async def async_step_form_initial_network(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Form an initial network."""
# This step exists only for translations, it does nothing new
return await self.async_step_form_new_network(user_input)
async def async_step_form_new_network(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Form a brand-new network."""
await self._radio_mgr.async_form_network()
return await self._async_create_radio_entry()
@ -399,7 +408,7 @@ class BaseZhaFlow(FlowHandler):
async def async_step_upload_manual_backup(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Upload and restore a coordinator backup JSON file."""
errors = {}
@ -427,7 +436,7 @@ class BaseZhaFlow(FlowHandler):
async def async_step_choose_automatic_backup(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Choose an automatic backup."""
if self.show_advanced_options:
# Always show the PAN IDs when in advanced mode
@ -466,7 +475,7 @@ class BaseZhaFlow(FlowHandler):
async def async_step_maybe_confirm_ezsp_restore(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Confirm restore for EZSP radios that require permanent IEEE writes."""
call_step_2 = await self._radio_mgr.async_restore_backup_step_1()
if not call_step_2:
@ -486,7 +495,7 @@ class BaseZhaFlow(FlowHandler):
)
class ZhaConfigFlowHandler(BaseZhaFlow, config_entries.ConfigFlow, domain=DOMAIN):
class ZhaConfigFlowHandler(BaseZhaFlow, ConfigFlow, domain=DOMAIN):
"""Handle a config flow."""
VERSION = 4
@ -512,14 +521,14 @@ class ZhaConfigFlowHandler(BaseZhaFlow, config_entries.ConfigFlow, domain=DOMAIN
@staticmethod
@callback
def async_get_options_flow(
config_entry: config_entries.ConfigEntry,
) -> config_entries.OptionsFlow:
config_entry: ConfigEntry,
) -> OptionsFlow:
"""Create the options flow."""
return ZhaOptionsFlowHandler(config_entry)
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a ZHA config flow start."""
if self._async_current_entries():
return self.async_abort(reason="single_instance_allowed")
@ -528,7 +537,7 @@ class ZhaConfigFlowHandler(BaseZhaFlow, config_entries.ConfigFlow, domain=DOMAIN
async def async_step_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Confirm a discovery."""
self._set_confirm_only()
@ -566,7 +575,9 @@ class ZhaConfigFlowHandler(BaseZhaFlow, config_entries.ConfigFlow, domain=DOMAIN
description_placeholders={CONF_NAME: self._title},
)
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."""
vid = discovery_info.vid
pid = discovery_info.pid
@ -585,7 +596,7 @@ class ZhaConfigFlowHandler(BaseZhaFlow, config_entries.ConfigFlow, domain=DOMAIN
if self.hass.config_entries.flow.async_progress_by_handler(DECONZ_DOMAIN):
return self.async_abort(reason="not_zha_device")
for entry in self.hass.config_entries.async_entries(DECONZ_DOMAIN):
if entry.source != config_entries.SOURCE_IGNORE:
if entry.source != SOURCE_IGNORE:
return self.async_abort(reason="not_zha_device")
self._radio_mgr.device_path = dev_path
@ -602,7 +613,7 @@ class ZhaConfigFlowHandler(BaseZhaFlow, config_entries.ConfigFlow, domain=DOMAIN
async def async_step_zeroconf(
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle zeroconf discovery."""
# Hostname is format: livingroom.local.
@ -638,7 +649,7 @@ class ZhaConfigFlowHandler(BaseZhaFlow, config_entries.ConfigFlow, domain=DOMAIN
async def async_step_hardware(
self, data: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle hardware flow."""
try:
discovery_data = HARDWARE_DISCOVERY_SCHEMA(data)
@ -664,10 +675,10 @@ class ZhaConfigFlowHandler(BaseZhaFlow, config_entries.ConfigFlow, domain=DOMAIN
return await self.async_step_confirm()
class ZhaOptionsFlowHandler(BaseZhaFlow, config_entries.OptionsFlow):
class ZhaOptionsFlowHandler(BaseZhaFlow, OptionsFlow):
"""Handle an options flow."""
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
def __init__(self, config_entry: ConfigEntry) -> None:
"""Initialize options flow."""
super().__init__()
self.config_entry = config_entry
@ -679,11 +690,11 @@ class ZhaOptionsFlowHandler(BaseZhaFlow, config_entries.OptionsFlow):
async def async_step_init(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Launch the options flow."""
if user_input is not None:
# OperationNotAllowed: ZHA is not running
with suppress(config_entries.OperationNotAllowed):
with suppress(OperationNotAllowed):
await self.hass.config_entries.async_unload(self.config_entry.entry_id)
return await self.async_step_prompt_migrate_or_reconfigure()
@ -692,7 +703,7 @@ class ZhaOptionsFlowHandler(BaseZhaFlow, config_entries.OptionsFlow):
async def async_step_prompt_migrate_or_reconfigure(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Confirm if we are migrating adapters or just re-configuring."""
return self.async_show_menu(
@ -705,13 +716,13 @@ class ZhaOptionsFlowHandler(BaseZhaFlow, config_entries.OptionsFlow):
async def async_step_intent_reconfigure(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Virtual step for when the user is reconfiguring the integration."""
return await self.async_step_choose_serial_port()
async def async_step_intent_migrate(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Confirm the user wants to reset their current radio."""
if user_input is not None:
@ -723,7 +734,7 @@ class ZhaOptionsFlowHandler(BaseZhaFlow, config_entries.OptionsFlow):
async def async_step_instruct_unplug(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Instruct the user to unplug the current radio, if possible."""
if user_input is not None:
@ -758,8 +769,8 @@ class ZhaOptionsFlowHandler(BaseZhaFlow, config_entries.OptionsFlow):
def async_remove(self):
"""Maybe reload ZHA if the flow is aborted."""
if self.config_entry.state not in (
config_entries.ConfigEntryState.SETUP_ERROR,
config_entries.ConfigEntryState.NOT_LOADED,
ConfigEntryState.SETUP_ERROR,
ConfigEntryState.NOT_LOADED,
):
return

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 ZodiacConfigFlow(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

@ -4,10 +4,10 @@ This is no longer in use. This file is around so that existing
config entries will remain to be loaded and then automatically
migrated to the storage collection.
"""
from homeassistant import config_entries
from homeassistant.config_entries import ConfigFlow
from .const import DOMAIN
class ZoneConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class ZoneConfigFlow(ConfigFlow, domain=DOMAIN):
"""Stub zone config flow class."""

View File

@ -6,10 +6,9 @@ import logging
from url_normalize import url_normalize
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components.zeroconf import ZeroconfServiceInfo
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_TOKEN, CONF_URL
from homeassistant.data_entry_flow import FlowResult
from . import helpers
from .const import DOMAIN
@ -17,7 +16,7 @@ from .const import DOMAIN
_LOGGER = logging.getLogger(__name__)
class ZWaveMeConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class ZWaveMeConfigFlow(ConfigFlow, domain=DOMAIN):
"""ZWaveMe integration config flow."""
def __init__(self) -> None:
@ -28,7 +27,7 @@ class ZWaveMeConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, str] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initialized by the user or started with zeroconf."""
errors = {}
placeholders = {
@ -88,7 +87,7 @@ class ZWaveMeConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_zeroconf(
self, discovery_info: ZeroconfServiceInfo
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a discovered Z-Wave accessory - get url to pass into user step.
This flow is triggered by the discovery component.

View File

@ -42,7 +42,7 @@ test_response = json.loads(
async def test_show_set_form(hass: HomeAssistant) -> None:
"""Test that the setup form is served."""
flow = config_flow.ConfigFlow()
flow = config_flow.WallboxConfigFlow()
flow.hass = hass
result = await flow.async_step_user(user_input=None)