Migrate integrations a-d to generic flowhandler (#111861)

This commit is contained in:
Erik Montnemery 2024-02-29 20:07:14 +01:00 committed by GitHub
parent ba4120d779
commit 6fe28d3764
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
111 changed files with 841 additions and 758 deletions

View File

@ -14,16 +14,15 @@ from jaraco.abode.helpers.errors import MFA_CODE_REQUIRED
from requests.exceptions import ConnectTimeout, HTTPError
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.data_entry_flow import FlowResult
from .const import CONF_POLLING, DOMAIN, LOGGER
CONF_MFA = "mfa_code"
class AbodeFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class AbodeFlowHandler(ConfigFlow, domain=DOMAIN):
"""Config flow for Abode."""
VERSION = 1
@ -43,7 +42,7 @@ class AbodeFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
self._polling: bool = False
self._username: str | None = None
async def _async_abode_login(self, step_id: str) -> FlowResult:
async def _async_abode_login(self, step_id: str) -> ConfigFlowResult:
"""Handle login with Abode."""
errors = {}
@ -74,7 +73,7 @@ class AbodeFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
return await self._async_create_entry()
async def _async_abode_mfa_login(self) -> FlowResult:
async def _async_abode_mfa_login(self) -> ConfigFlowResult:
"""Handle multi-factor authentication (MFA) login with Abode."""
try:
# Create instance to access login method for passing MFA code
@ -92,7 +91,7 @@ class AbodeFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
return await self._async_create_entry()
async def _async_create_entry(self) -> FlowResult:
async def _async_create_entry(self) -> ConfigFlowResult:
"""Create the config entry."""
config_data = {
CONF_USERNAME: self._username,
@ -118,7 +117,7 @@ class AbodeFlowHandler(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."""
if self._async_current_entries():
return self.async_abort(reason="single_instance_allowed")
@ -135,7 +134,7 @@ class AbodeFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_mfa(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a multi-factor authentication (MFA) flow."""
if user_input is None:
return self.async_show_form(
@ -146,7 +145,9 @@ class AbodeFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
return await self._async_abode_mfa_login()
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 reauthorization request from Abode."""
self._username = entry_data[CONF_USERNAME]
@ -154,7 +155,7 @@ class AbodeFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_reauth_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle reauthorization flow."""
if user_input is None:
return self.async_show_form(

View File

@ -9,11 +9,9 @@ from aiohttp import ClientError
from aiohttp.client_exceptions import ClientConnectorError
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigEntry
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.schema_config_entry_flow import (
@ -33,14 +31,14 @@ OPTIONS_FLOW = {
}
class AccuWeatherFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class AccuWeatherFlowHandler(ConfigFlow, domain=DOMAIN):
"""Config flow for AccuWeather."""
VERSION = 1
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initialized by the user."""
# Under the terms of use of the API, one user can use one free API key. Due to
# the small number of requests allowed, we only allow one integration instance.

View File

@ -8,14 +8,13 @@ from typing import Any
import aiopulse
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_HOST, CONF_ID
from homeassistant.data_entry_flow import FlowResult
from .const import DOMAIN
class AcmedaFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class AcmedaFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a Acmeda config flow."""
VERSION = 1
@ -26,7 +25,7 @@ class AcmedaFlowHandler(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."""
if (
user_input is not None
@ -66,7 +65,7 @@ class AcmedaFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
),
)
async def async_create(self, hub: aiopulse.Hub) -> FlowResult:
async def async_create(self, hub: aiopulse.Hub) -> ConfigFlowResult:
"""Create the Acmeda Hub entry."""
await self.async_set_unique_id(hub.id, raise_on_progress=False)
return self.async_create_entry(title=hub.id, data={CONF_HOST: hub.host})

View File

@ -8,14 +8,13 @@ import adax
import adax_local
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import (
CONF_IP_ADDRESS,
CONF_PASSWORD,
CONF_TOKEN,
CONF_UNIQUE_ID,
)
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import (
@ -31,14 +30,14 @@ from .const import (
_LOGGER = logging.getLogger(__name__)
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class AdaxConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Adax."""
VERSION = 2
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the initial step."""
data_schema = vol.Schema(
{
@ -63,7 +62,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_local(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the local step."""
data_schema = vol.Schema(
{vol.Required(WIFI_SSID): str, vol.Required(WIFI_PSWD): str}
@ -110,7 +109,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_cloud(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the cloud step."""
data_schema = vol.Schema(
{vol.Required(ACCOUNT_ID): int, vol.Required(CONF_PASSWORD): str}

View File

@ -7,7 +7,7 @@ from adguardhome import AdGuardHome, AdGuardHomeConnectionError
import voluptuous as vol
from homeassistant.components.hassio import HassioServiceInfo
from homeassistant.config_entries import ConfigFlow
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import (
CONF_HOST,
CONF_PASSWORD,
@ -16,7 +16,6 @@ from homeassistant.const import (
CONF_USERNAME,
CONF_VERIFY_SSL,
)
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import DOMAIN
@ -31,7 +30,7 @@ class AdGuardHomeFlowHandler(ConfigFlow, domain=DOMAIN):
async def _show_setup_form(
self, errors: dict[str, str] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Show the setup form to the user."""
return self.async_show_form(
step_id="user",
@ -50,7 +49,7 @@ class AdGuardHomeFlowHandler(ConfigFlow, domain=DOMAIN):
async def _show_hassio_form(
self, errors: dict[str, str] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Show the Hass.io confirmation form to the user."""
assert self._hassio_discovery
return self.async_show_form(
@ -61,7 +60,7 @@ class AdGuardHomeFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initiated by the user."""
if user_input is None:
return await self._show_setup_form(user_input)
@ -104,7 +103,9 @@ class AdGuardHomeFlowHandler(ConfigFlow, domain=DOMAIN):
},
)
async def async_step_hassio(self, discovery_info: HassioServiceInfo) -> FlowResult:
async def async_step_hassio(
self, discovery_info: HassioServiceInfo
) -> ConfigFlowResult:
"""Prepare configuration for a Hass.io AdGuard Home add-on.
This flow is triggered by the discovery component.
@ -116,7 +117,7 @@ class AdGuardHomeFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_hassio_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Confirm Supervisor discovery."""
if user_input is None:
return await self._show_hassio_form()

View File

@ -6,9 +6,8 @@ from typing import Any
from advantage_air import ApiError, advantage_air
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_IP_ADDRESS, CONF_PORT
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import ADVANTAGE_AIR_RETRY, DOMAIN
@ -23,7 +22,7 @@ ADVANTAGE_AIR_SCHEMA = vol.Schema(
)
class AdvantageAirConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class AdvantageAirConfigFlow(ConfigFlow, domain=DOMAIN):
"""Config Advantage Air API connection."""
VERSION = 1
@ -32,7 +31,7 @@ class AdvantageAirConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Get configuration from the user."""
errors = {}
if user_input:

View File

@ -7,10 +7,9 @@ from aemet_opendata.exceptions import AuthError
from aemet_opendata.interface import AEMET, ConnectionOptions
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import aiohttp_client, config_validation as cv
from homeassistant.helpers.schema_config_entry_flow import (
SchemaFlowFormStep,
@ -29,12 +28,12 @@ OPTIONS_FLOW = {
}
class AemetConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class AemetConfigFlow(ConfigFlow, domain=DOMAIN):
"""Config flow for AEMET OpenData."""
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initialized by the user."""
errors = {}
@ -75,7 +74,7 @@ class AemetConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
@staticmethod
@callback
def async_get_options_flow(
config_entry: config_entries.ConfigEntry,
config_entry: ConfigEntry,
) -> SchemaOptionsFlowHandler:
"""Get the options flow for this handler."""
return SchemaOptionsFlowHandler(config_entry, OPTIONS_FLOW)

View File

@ -7,10 +7,9 @@ from typing import Any
from pyaftership import AfterShip, AfterShipException
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_NAME
from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
@ -26,7 +25,7 @@ class AfterShipConfigFlow(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:
@ -49,7 +48,7 @@ class AfterShipConfigFlow(ConfigFlow, domain=DOMAIN):
errors=errors,
)
async def async_step_import(self, config: dict[str, Any]) -> FlowResult:
async def async_step_import(self, config: dict[str, Any]) -> ConfigFlowResult:
"""Import configuration from yaml."""
async_create_issue(
self.hass,

View File

@ -6,9 +6,8 @@ from agent import AgentConnectionError, AgentError
from agent.a import Agent
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_HOST, CONF_PORT
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import DOMAIN, SERVER_URL
@ -17,12 +16,12 @@ from .helpers import generate_url
DEFAULT_PORT = 8090
class AgentFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class AgentFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle an Agent config flow."""
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle an Agent config flow."""
errors = {}

View File

@ -10,23 +10,22 @@ from airly import Airly
from airly.exceptions import AirlyError
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
import homeassistant.helpers.config_validation as cv
from .const import CONF_USE_NEAREST, DOMAIN, NO_AIRLY_SENSORS
class AirlyFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class AirlyFlowHandler(ConfigFlow, domain=DOMAIN):
"""Config flow for Airly."""
VERSION = 1
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initialized by the user."""
errors = {}
use_nearest = False

View File

@ -6,16 +6,15 @@ from pyairnow import WebServiceAPI
from pyairnow.errors import AirNowError, EmptyResponseError, InvalidKeyError
import voluptuous as vol
from homeassistant import core
from homeassistant.config_entries import (
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
OptionsFlowWithConfigEntry,
)
from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE, CONF_RADIUS
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResult
from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.aiohttp_client import async_get_clientsession
import homeassistant.helpers.config_validation as cv
@ -62,7 +61,7 @@ class AirNowConfigFlow(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:
@ -117,7 +116,7 @@ class AirNowConfigFlow(ConfigFlow, domain=DOMAIN):
)
@staticmethod
@core.callback
@callback
def async_get_options_flow(
config_entry: ConfigEntry,
) -> OptionsFlow:
@ -130,7 +129,7 @@ class AirNowOptionsFlowHandler(OptionsFlowWithConfigEntry):
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

@ -8,9 +8,8 @@ from aioairq import AirQ, InvalidAuth
from aiohttp.client_exceptions import ClientConnectionError
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_IP_ADDRESS, CONF_PASSWORD
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import DOMAIN
@ -25,14 +24,14 @@ STEP_USER_DATA_SCHEMA = vol.Schema(
)
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class AirQConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for air-Q."""
VERSION = 1
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the initial (authentication) configuration step."""
if user_input is None:
return self.async_show_form(

View File

@ -7,9 +7,8 @@ from typing import Any
import airthings
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_ID
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import CONF_SECRET, DOMAIN
@ -24,14 +23,14 @@ STEP_USER_DATA_SCHEMA = vol.Schema(
)
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class AirthingsConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Airthings."""
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

@ -15,9 +15,8 @@ from homeassistant.components.bluetooth import (
BluetoothServiceInfo,
async_discovered_service_info,
)
from homeassistant.config_entries import ConfigFlow
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_ADDRESS
from homeassistant.data_entry_flow import FlowResult
from .const import DOMAIN, MFCT_ID
@ -93,7 +92,7 @@ class AirthingsConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_bluetooth(
self, discovery_info: BluetoothServiceInfo
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the bluetooth discovery step."""
_LOGGER.debug("Discovered BT device: %s", discovery_info)
await self.async_set_unique_id(discovery_info.address)
@ -114,7 +113,7 @@ class AirthingsConfigFlow(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:
return self.async_create_entry(
@ -129,7 +128,7 @@ class AirthingsConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the user step to pick discovered device."""
if user_input is not None:
address = user_input[CONF_ADDRESS]

View File

@ -2,7 +2,7 @@
from airtouch4pyapi import AirTouch, AirTouchStatus
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigFlow
from homeassistant.const import CONF_HOST
from .const import DOMAIN
@ -10,7 +10,7 @@ from .const import DOMAIN
DATA_SCHEMA = vol.Schema({vol.Required(CONF_HOST): str})
class AirtouchConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class AirtouchConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle an Airtouch config flow."""
VERSION = 1

View File

@ -9,7 +9,6 @@ import voluptuous as vol
from homeassistant import config_entries
from homeassistant.const import CONF_HOST
from homeassistant.data_entry_flow import FlowResult
from .const import DOMAIN
@ -25,7 +24,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> config_entries.ConfigFlowResult:
"""Handle the initial step."""
errors: dict[str, str] | None = None
if user_input is not None:

View File

@ -15,8 +15,7 @@ from pyairvisual.cloud_api import (
from pyairvisual.errors import AirVisualError
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigEntry
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.const import (
CONF_API_KEY,
CONF_COUNTRY,
@ -26,7 +25,6 @@ from homeassistant.const import (
CONF_STATE,
)
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import aiohttp_client, config_validation as cv
from homeassistant.helpers.schema_config_entry_flow import (
SchemaFlowFormStep,
@ -70,7 +68,7 @@ OPTIONS_FLOW = {
}
class AirVisualFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class AirVisualFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle an AirVisual config flow."""
VERSION = 3
@ -96,7 +94,7 @@ class AirVisualFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def _async_finish_geography(
self, user_input: dict[str, str], integration_type: str
) -> FlowResult:
) -> ConfigFlowResult:
"""Validate a Cloud API key."""
errors = {}
websession = aiohttp_client.async_get_clientsession(self.hass)
@ -155,7 +153,7 @@ class AirVisualFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def _async_init_geography(
self, user_input: dict[str, str], integration_type: str
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the initialization of the integration via the cloud API."""
self._geo_id = async_get_geography_id(user_input)
await self._async_set_unique_id(self._geo_id)
@ -173,7 +171,7 @@ class AirVisualFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
"""Define the config flow to handle options."""
return SchemaOptionsFlowHandler(config_entry, OPTIONS_FLOW)
async def async_step_import(self, import_data: dict[str, str]) -> FlowResult:
async def async_step_import(self, import_data: dict[str, str]) -> ConfigFlowResult:
"""Handle import of config entry version 1 data."""
import_source = import_data.pop("import_source")
if import_source == "geography_by_coords":
@ -182,7 +180,7 @@ class AirVisualFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_geography_by_coords(
self, user_input: dict[str, str] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the initialization of the cloud API based on latitude/longitude."""
if not user_input:
return self.async_show_form(
@ -195,7 +193,7 @@ class AirVisualFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_geography_by_name(
self, user_input: dict[str, str] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the initialization of the cloud API based on city/state/country."""
if not user_input:
return self.async_show_form(
@ -206,7 +204,9 @@ class AirVisualFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
user_input, INTEGRATION_TYPE_GEOGRAPHY_NAME
)
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
async def async_step_reauth(
self, entry_data: Mapping[str, Any]
) -> ConfigFlowResult:
"""Handle configuration by re-auth."""
self._entry_data_for_reauth = entry_data
self._geo_id = async_get_geography_id(entry_data)
@ -214,7 +214,7 @@ class AirVisualFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_reauth_confirm(
self, user_input: dict[str, str] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle re-auth completion."""
if not user_input:
return self.async_show_form(
@ -229,7 +229,7 @@ class AirVisualFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, str] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the start of the config flow."""
if not user_input:
return self.async_show_form(

View File

@ -13,10 +13,8 @@ from pyairvisual.node import (
)
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigEntry
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_IP_ADDRESS, CONF_PASSWORD
from homeassistant.data_entry_flow import FlowResult
from .const import DOMAIN, LOGGER
@ -72,7 +70,7 @@ async def async_validate_credentials(
return ValidationResult(errors=errors)
class AirVisualProFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class AirVisualProFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle an AirVisual Pro config flow."""
VERSION = 1
@ -81,11 +79,15 @@ class AirVisualProFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
"""Initialize."""
self._reauth_entry: ConfigEntry | None = None
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."""
return await self.async_step_user(import_config)
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"]
@ -94,7 +96,7 @@ class AirVisualProFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_reauth_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the re-auth step."""
if user_input is None:
return self.async_show_form(
@ -124,7 +126,7 @@ class AirVisualProFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, str] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the initial step."""
if not user_input:
return self.async_show_form(step_id="user", data_schema=STEP_USER_SCHEMA)

View File

@ -9,10 +9,10 @@ from aioairzone.exceptions import AirzoneError, InvalidSystem
from aioairzone.localapi import AirzoneLocalApi, ConnectionOptions
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import dhcp
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_HOST, CONF_ID, CONF_PORT
from homeassistant.data_entry_flow import AbortFlow, FlowResult
from homeassistant.data_entry_flow import AbortFlow
from homeassistant.helpers import aiohttp_client
from homeassistant.helpers.device_registry import format_mac
@ -38,7 +38,7 @@ def short_mac(addr: str) -> str:
return addr.replace(":", "")[-4:].upper()
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class AirZoneConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle config flow for an Airzone device."""
_discovered_ip: str | None = None
@ -46,7 +46,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the initial step."""
data_schema = CONFIG_SCHEMA
errors = {}
@ -91,7 +91,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:
"""Handle DHCP discovery."""
self._discovered_ip = discovery_info.ip
self._discovered_mac = discovery_info.macaddress
@ -118,7 +120,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_discovered_connection(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Confirm discovery."""
assert self._discovered_ip is not None
assert self._discovered_mac is not None

View File

@ -9,9 +9,8 @@ from aioairzone_cloud.const import AZD_ID, AZD_NAME, AZD_WEBSERVERS
from aioairzone_cloud.exceptions import AirzoneCloudError, LoginError
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_ID, CONF_PASSWORD, CONF_USERNAME
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import aiohttp_client
from homeassistant.helpers.selector import (
SelectOptionDict,
@ -23,14 +22,14 @@ from homeassistant.helpers.selector import (
from .const import DOMAIN
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class AirZoneCloudConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle config flow for an Airzone Cloud device."""
airzone: AirzoneCloudApi
async def async_step_inst_pick(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the installation selection."""
errors = {}
options: dict[str, str] = {}
@ -81,7 +80,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 = {}

View File

@ -9,10 +9,9 @@ import AIOAladdinConnect.session_manager as Aladdin
from aiohttp.client_exceptions import ClientError
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResult
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.aiohttp_client import async_get_clientsession
@ -48,13 +47,15 @@ async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> None:
raise InvalidAuth from ex
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class AladdinConnectConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Aladdin Connect."""
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 Aladdin Connect."""
self.entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
@ -62,7 +63,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 Aladdin Connect."""
errors: dict[str, str] = {}
@ -102,7 +103,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(

View File

@ -9,14 +9,17 @@ from alarmdecoder.devices import SerialDevice, SocketDevice
from alarmdecoder.util import NoDeviceError
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components.binary_sensor import (
DEVICE_CLASSES_SCHEMA as BINARY_SENSOR_DEVICE_CLASSES_SCHEMA,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.config_entries import (
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.const import CONF_HOST, CONF_PORT, CONF_PROTOCOL
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from .const import (
CONF_ALT_NIGHT_MODE,
@ -52,7 +55,7 @@ EDIT_SETTINGS = "Arming Settings"
_LOGGER = logging.getLogger(__name__)
class AlarmDecoderFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class AlarmDecoderFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a AlarmDecoder config flow."""
VERSION = 1
@ -64,14 +67,14 @@ class AlarmDecoderFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
@staticmethod
@callback
def async_get_options_flow(
config_entry: config_entries.ConfigEntry,
config_entry: ConfigEntry,
) -> AlarmDecoderOptionsFlowHandler:
"""Get the options flow for AlarmDecoder."""
return AlarmDecoderOptionsFlowHandler(config_entry)
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initialized by the user."""
if user_input is not None:
self.protocol = user_input[CONF_PROTOCOL]
@ -90,7 +93,7 @@ class AlarmDecoderFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_protocol(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle AlarmDecoder protocol setup."""
errors = {}
if user_input is not None:
@ -150,12 +153,12 @@ class AlarmDecoderFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
)
class AlarmDecoderOptionsFlowHandler(config_entries.OptionsFlow):
class AlarmDecoderOptionsFlowHandler(OptionsFlow):
"""Handle AlarmDecoder options."""
selected_zone: str | None = None
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
def __init__(self, config_entry: ConfigEntry) -> None:
"""Initialize AlarmDecoder options flow."""
self.arm_options = config_entry.options.get(OPTIONS_ARM, DEFAULT_ARM_OPTIONS)
self.zone_options = config_entry.options.get(
@ -164,7 +167,7 @@ class AlarmDecoderOptionsFlowHandler(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:
if user_input[EDIT_KEY] == EDIT_SETTINGS:
@ -185,7 +188,7 @@ class AlarmDecoderOptionsFlowHandler(config_entries.OptionsFlow):
async def async_step_arm_settings(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Arming options form."""
if user_input is not None:
return self.async_create_entry(
@ -214,7 +217,7 @@ class AlarmDecoderOptionsFlowHandler(config_entries.OptionsFlow):
async def async_step_zone_select(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Zone selection form."""
errors = _validate_zone_input(user_input)
@ -232,7 +235,7 @@ class AlarmDecoderOptionsFlowHandler(config_entries.OptionsFlow):
async def async_step_zone_details(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Zone details form."""
errors = _validate_zone_input(user_input)

View File

@ -6,9 +6,8 @@ from amberelectric.api import amber_api
from amberelectric.model.site import Site, SiteStatus
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_API_TOKEN
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.selector import (
SelectOptionDict,
SelectSelector,
@ -43,7 +42,7 @@ def filter_sites(sites: list[Site]) -> list[Site]:
return filtered
class AmberElectricConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class AmberElectricConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow."""
VERSION = 1
@ -73,7 +72,7 @@ class AmberElectricConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, str] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Step when user initializes a integration."""
self._errors = {}
self._sites = None
@ -107,7 +106,7 @@ class AmberElectricConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_site(
self, user_input: dict[str, str] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Step to select site."""
self._errors = {}

View File

@ -5,11 +5,10 @@ from typing import Any
from aiohttp import web
import ambiclimate
from homeassistant import config_entries
from homeassistant.components.http import HomeAssistantView
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET
from homeassistant.core import HomeAssistant, callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.network import get_url
from homeassistant.helpers.storage import Store
@ -44,7 +43,7 @@ def register_flow_implementation(
}
class AmbiclimateFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class AmbiclimateFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a config flow."""
VERSION = 1
@ -56,7 +55,7 @@ class AmbiclimateFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle external yaml configuration."""
self._async_abort_entries_match()
@ -70,7 +69,7 @@ class AmbiclimateFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_auth(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow start."""
self._async_abort_entries_match()
@ -91,7 +90,7 @@ class AmbiclimateFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
errors=errors,
)
async def async_step_code(self, code: str | None = None) -> FlowResult:
async def async_step_code(self, code: str | None = None) -> ConfigFlowResult:
"""Received code for authentication."""
self._async_abort_entries_match()

View File

@ -5,15 +5,14 @@ from aioambient import API
from aioambient.errors import AmbientError
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 import aiohttp_client
from .const import CONF_APP_KEY, DOMAIN
class AmbientStationFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class AmbientStationFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle an Ambient PWS config flow."""
VERSION = 2
@ -24,7 +23,7 @@ class AmbientStationFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
{vol.Required(CONF_API_KEY): str, vol.Required(CONF_APP_KEY): str}
)
async def _show_form(self, errors: dict | None = None) -> FlowResult:
async def _show_form(self, errors: dict | None = None) -> ConfigFlowResult:
"""Show the form to the user."""
return self.async_show_form(
step_id="user",
@ -32,7 +31,7 @@ class AmbientStationFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
errors=errors if errors else {},
)
async def async_step_user(self, user_input: dict | None = None) -> FlowResult:
async def async_step_user(self, user_input: dict | None = None) -> ConfigFlowResult:
"""Handle the start of the config flow."""
if not user_input:
return await self._show_form()

View File

@ -13,11 +13,11 @@ import voluptuous as vol
from homeassistant.config_entries import (
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
OptionsFlowWithConfigEntry,
)
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.selector import (
SelectOptionDict,
@ -50,7 +50,7 @@ class HomeassistantAnalyticsConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the initial step."""
self._async_abort_entries_match()
errors: dict[str, str] = {}
@ -120,7 +120,7 @@ class HomeassistantAnalyticsOptionsFlowHandler(OptionsFlowWithConfigEntry):
async def async_step_init(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Manage the options."""
errors: dict[str, str] = {}
if user_input is not None:

View File

@ -7,10 +7,9 @@ from pydroid_ipcam import PyDroidIPCam
from pydroid_ipcam.exceptions import PyDroidIPCamException, Unauthorized
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT, CONF_USERNAME
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.aiohttp_client import async_get_clientsession
@ -50,14 +49,14 @@ async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> dict[str,
return errors
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class AndroidIPWebcamConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Android IP Webcam."""
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

@ -11,11 +11,11 @@ import voluptuous as vol
from homeassistant.config_entries import (
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlowWithConfigEntry,
)
from homeassistant.const import CONF_DEVICE_CLASS, CONF_HOST, CONF_PORT
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.selector import (
ObjectSelector,
@ -81,7 +81,7 @@ class AndroidTVFlowHandler(ConfigFlow, domain=DOMAIN):
self,
user_input: dict[str, Any] | None = None,
error: str | None = None,
) -> FlowResult:
) -> ConfigFlowResult:
"""Show the setup form to the user."""
host = user_input.get(CONF_HOST, "") if user_input else ""
data_schema = vol.Schema(
@ -144,7 +144,7 @@ class AndroidTVFlowHandler(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."""
error = None
@ -199,7 +199,7 @@ class OptionsFlowHandler(OptionsFlowWithConfigEntry):
self._conf_rule_id: str | None = None
@callback
def _save_config(self, data: dict[str, Any]) -> FlowResult:
def _save_config(self, data: dict[str, Any]) -> ConfigFlowResult:
"""Save the updated options."""
new_data = {
k: v
@ -215,7 +215,7 @@ class OptionsFlowHandler(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:
if sel_app := user_input.get(CONF_APPS):
@ -227,7 +227,7 @@ class OptionsFlowHandler(OptionsFlowWithConfigEntry):
return self._async_init_form()
@callback
def _async_init_form(self) -> FlowResult:
def _async_init_form(self) -> ConfigFlowResult:
"""Return initial configuration form."""
apps_list = {k: f"{v} ({k})" if v else k for k, v in self._apps.items()}
@ -280,7 +280,7 @@ class OptionsFlowHandler(OptionsFlowWithConfigEntry):
async def async_step_apps(
self, user_input: dict[str, Any] | None = None, app_id: str | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle options flow for apps list."""
if app_id is not None:
self._conf_app_id = app_id if app_id != APPS_NEW_ID else None
@ -297,7 +297,7 @@ class OptionsFlowHandler(OptionsFlowWithConfigEntry):
return await self.async_step_init()
@callback
def _async_apps_form(self, app_id: str) -> FlowResult:
def _async_apps_form(self, app_id: str) -> ConfigFlowResult:
"""Return configuration form for apps."""
app_schema = {
vol.Optional(
@ -322,7 +322,7 @@ class OptionsFlowHandler(OptionsFlowWithConfigEntry):
async def async_step_rules(
self, user_input: dict[str, Any] | None = None, rule_id: str | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle options flow for detection rules."""
if rule_id is not None:
self._conf_rule_id = rule_id if rule_id != RULES_NEW_ID else None
@ -348,7 +348,7 @@ class OptionsFlowHandler(OptionsFlowWithConfigEntry):
@callback
def _async_rules_form(
self, rule_id: str, default_id: str = "", errors: dict[str, str] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Return configuration form for detection rules."""
rule_schema = {
vol.Optional(

View File

@ -16,11 +16,11 @@ from homeassistant.components import zeroconf
from homeassistant.config_entries import (
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlowWithConfigEntry,
)
from homeassistant.const import CONF_HOST, CONF_MAC, CONF_NAME
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.device_registry import format_mac
from .const import CONF_ENABLE_IME, DOMAIN
@ -54,7 +54,7 @@ class AndroidTVRemoteConfigFlow(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:
@ -78,7 +78,7 @@ class AndroidTVRemoteConfigFlow(ConfigFlow, domain=DOMAIN):
errors=errors,
)
async def _async_start_pair(self) -> FlowResult:
async def _async_start_pair(self) -> ConfigFlowResult:
"""Start pairing with the Android TV. Navigate to the pair flow to enter the PIN shown on screen."""
assert self.host
self.api = create_api(self.hass, self.host, enable_ime=False)
@ -88,7 +88,7 @@ class AndroidTVRemoteConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_pair(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the pair step."""
errors: dict[str, str] = {}
if user_input is not None:
@ -136,7 +136,7 @@ class AndroidTVRemoteConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_zeroconf(
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle zeroconf discovery."""
self.host = discovery_info.host
self.name = discovery_info.name.removesuffix("._androidtvremote2._tcp.local.")
@ -152,7 +152,7 @@ class AndroidTVRemoteConfigFlow(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:
try:
@ -166,7 +166,9 @@ class AndroidTVRemoteConfigFlow(ConfigFlow, domain=DOMAIN):
description_placeholders={CONF_NAME: self.name},
)
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
async def async_step_reauth(
self, entry_data: Mapping[str, Any]
) -> ConfigFlowResult:
"""Handle configuration by re-auth."""
self.host = entry_data[CONF_HOST]
self.name = entry_data[CONF_NAME]
@ -178,7 +180,7 @@ class AndroidTVRemoteConfigFlow(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."""
errors: dict[str, str] = {}
if user_input is not None:
@ -207,7 +209,7 @@ class AndroidTVRemoteOptionsFlowHandler(OptionsFlowWithConfigEntry):
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

@ -4,9 +4,8 @@ from __future__ import annotations
from anova_wifi import AnovaApi, InvalidLogin, NoDevicesFound
import voluptuous as vol
from homeassistant.config_entries import ConfigFlow
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_DEVICES, CONF_PASSWORD, CONF_USERNAME
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import DOMAIN
@ -20,7 +19,7 @@ class AnovaConfligFlow(ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, str] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initiated by the user."""
errors: dict[str, str] = {}
if user_input is not None:

View File

@ -9,9 +9,8 @@ from anthemav.connection import Connection
from anthemav.device_error import DeviceError
import voluptuous as vol
from homeassistant.config_entries import ConfigFlow
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_HOST, CONF_MAC, CONF_MODEL, CONF_PORT
from homeassistant.data_entry_flow import FlowResult
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.device_registry import format_mac
@ -44,7 +43,7 @@ class AnthemAVConfigFlow(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(

View File

@ -8,9 +8,8 @@ from typing import Any
from py_aosmith import AOSmithAPIClient, AOSmithInvalidCredentialsException
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import aiohttp_client
from .const import DOMAIN
@ -18,7 +17,7 @@ from .const import DOMAIN
_LOGGER = logging.getLogger(__name__)
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class AOSmithConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for A. O. Smith."""
VERSION = 1
@ -44,7 +43,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:
@ -73,14 +72,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:
"""Perform reauth if the user credentials have changed."""
self._reauth_email = entry_data[CONF_EMAIL]
return await self.async_step_reauth_confirm()
async def async_step_reauth_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle user's reauth credentials."""
errors: dict[str, str] = {}
if user_input is not None and self._reauth_email is not None:

View File

@ -5,9 +5,8 @@ from typing import Any
import voluptuous as vol
from homeassistant.config_entries import ConfigFlow
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_HOST, CONF_PORT
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import selector
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.update_coordinator import UpdateFailed
@ -38,7 +37,7 @@ class ConfigFlowHandler(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:

View File

@ -16,11 +16,17 @@ from pyatv.helpers import get_unique_id
from pyatv.interface import BaseConfig, PairingHandler
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import zeroconf
from homeassistant.config_entries import (
SOURCE_IGNORE,
SOURCE_ZEROCONF,
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
)
from homeassistant.const import CONF_ADDRESS, CONF_NAME, CONF_PIN
from homeassistant.core import HomeAssistant, callback
from homeassistant.data_entry_flow import AbortFlow, FlowResult
from homeassistant.data_entry_flow import AbortFlow
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.schema_config_entry_flow import (
@ -85,7 +91,7 @@ async def device_scan(
return None, None
class AppleTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class AppleTVConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Apple TV."""
VERSION = 1
@ -100,7 +106,7 @@ class AppleTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
@staticmethod
@callback
def async_get_options_flow(
config_entry: config_entries.ConfigEntry,
config_entry: ConfigEntry,
) -> SchemaOptionsFlowHandler:
"""Get options flow for this handler."""
return SchemaOptionsFlowHandler(config_entry, OPTIONS_FLOW)
@ -141,7 +147,9 @@ class AppleTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
return entry.unique_id
return 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 initial step when updating invalid credentials."""
self.context["title_placeholders"] = {
"name": entry_data[CONF_NAME],
@ -153,7 +161,7 @@ class AppleTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_reconfigure(
self, user_input: dict[str, str] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Inform user that reconfiguration is about to start."""
if user_input is not None:
return await self.async_find_device_wrapper(
@ -164,7 +172,7 @@ class AppleTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, str] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the initial step."""
errors = {}
if user_input is not None:
@ -194,7 +202,7 @@ class AppleTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_zeroconf(
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle device found via zeroconf."""
if discovery_info.ip_address.version == 6:
return self.async_abort(reason="ipv6_not_supported")
@ -276,7 +284,7 @@ class AppleTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
for flow in self._async_in_progress(include_uninitialized=True):
context = flow["context"]
if (
context.get("source") != config_entries.SOURCE_ZEROCONF
context.get("source") != SOURCE_ZEROCONF
or context.get(CONF_ADDRESS) != host
):
continue
@ -290,7 +298,7 @@ class AppleTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_found_zeroconf_device(
self, user_input: dict[str, str] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle device found after Zeroconf discovery."""
assert self.atv
self.context["all_identifiers"] = self.atv.all_identifiers
@ -306,9 +314,9 @@ class AppleTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_find_device_wrapper(
self,
next_func: Callable[[], Awaitable[FlowResult]],
next_func: Callable[[], Awaitable[ConfigFlowResult]],
allow_exist: bool = False,
) -> FlowResult:
) -> ConfigFlowResult:
"""Find a specific device and call another function when done.
This function will do error handling and bail out when an error
@ -370,7 +378,7 @@ class AppleTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
CONF_IDENTIFIERS: list(combined_identifiers),
},
)
if entry.source != config_entries.SOURCE_IGNORE:
if entry.source != SOURCE_IGNORE:
self.hass.async_create_task(
self.hass.config_entries.async_reload(entry.entry_id)
)
@ -379,7 +387,7 @@ class AppleTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_confirm(
self, user_input: dict[str, str] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle user-confirmation of discovered node."""
assert self.atv
if user_input is not None:
@ -407,7 +415,7 @@ class AppleTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
},
)
async def async_pair_next_protocol(self) -> FlowResult:
async def async_pair_next_protocol(self) -> ConfigFlowResult:
"""Start pairing process for the next available protocol."""
await self._async_cleanup()
@ -481,7 +489,7 @@ class AppleTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_protocol_disabled(
self, user_input: dict[str, str] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Inform user that a protocol is disabled and cannot be paired."""
assert self.protocol
if user_input is not None:
@ -493,7 +501,7 @@ class AppleTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_pair_with_pin(
self, user_input: dict[str, str] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle pairing step where a PIN is required from the user."""
errors = {}
assert self.pairing
@ -520,7 +528,7 @@ class AppleTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_pair_no_pin(
self, user_input: dict[str, str] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle step where user has to enter a PIN on the device."""
assert self.pairing
assert self.protocol
@ -545,7 +553,7 @@ class AppleTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_service_problem(
self, user_input: dict[str, str] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Inform user that a service will not be added."""
assert self.protocol
if user_input is not None:
@ -558,7 +566,7 @@ class AppleTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_password(
self, user_input: dict[str, str] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Inform user that password is not supported."""
assert self.protocol
if user_input is not None:
@ -575,7 +583,7 @@ class AppleTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
await self.pairing.close()
self.pairing = None
async def _async_get_entry(self) -> FlowResult:
async def _async_get_entry(self) -> ConfigFlowResult:
"""Return config entry or update existing config entry."""
# Abort if no protocols were paired
if not self.credentials:

View File

@ -10,7 +10,6 @@ import voluptuous as vol
from homeassistant import config_entries
from homeassistant.const import CONF_HOST, CONF_PORT
from homeassistant.data_entry_flow import FlowResult
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.device_registry import format_mac
@ -34,7 +33,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 the initial step."""
if user_input is None:

View File

@ -7,13 +7,13 @@ from typing import Any
from aranet4.client import Aranet4Advertisement, Version as AranetVersion
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components.bluetooth import (
BluetoothServiceInfoBleak,
async_discovered_service_info,
)
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_ADDRESS
from homeassistant.data_entry_flow import AbortFlow, FlowResult
from homeassistant.data_entry_flow import AbortFlow
from .const import DOMAIN
@ -22,7 +22,7 @@ _LOGGER = logging.getLogger(__name__)
MIN_VERSION = AranetVersion(1, 2, 0)
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class AranetConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Aranet."""
VERSION = 1
@ -45,7 +45,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_bluetooth(
self, discovery_info: BluetoothServiceInfoBleak
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the Bluetooth discovery step."""
await self.async_set_unique_id(discovery_info.address)
self._abort_if_unique_id_configured()
@ -58,7 +58,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_bluetooth_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Confirm discovery."""
assert self._discovered_device is not None
adv = self._discovered_device
@ -77,7 +77,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."""
if user_input is not None:
address = user_input[CONF_ADDRESS]

View File

@ -8,23 +8,22 @@ from arcam.fmj.client import Client, ConnectionFailed
from arcam.fmj.utils import get_uniqueid_from_host, get_uniqueid_from_udn
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import ssdp
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_HOST, CONF_PORT
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import DEFAULT_NAME, DEFAULT_PORT, DOMAIN, DOMAIN_DATA_ENTRIES
def get_entry_client(hass: HomeAssistant, entry: config_entries.ConfigEntry) -> Client:
def get_entry_client(hass: HomeAssistant, entry: ConfigEntry) -> Client:
"""Retrieve client associated with a config entry."""
client: Client = hass.data[DOMAIN_DATA_ENTRIES][entry.entry_id]
return client
class ArcamFmjFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class ArcamFmjFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle config flow."""
VERSION = 1
@ -35,7 +34,7 @@ class ArcamFmjFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
await self.async_set_unique_id(uuid)
self._abort_if_unique_id_configured({CONF_HOST: host, CONF_PORT: port})
async def _async_check_and_create(self, host: str, port: int) -> FlowResult:
async def _async_check_and_create(self, host: str, port: int) -> ConfigFlowResult:
client = Client(host, port)
try:
await client.start()
@ -51,7 +50,7 @@ class ArcamFmjFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a discovered device."""
errors: dict[str, str] = {}
@ -79,7 +78,7 @@ class ArcamFmjFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle user-confirmation of discovered node."""
context = self.context
placeholders = {
@ -96,7 +95,9 @@ class ArcamFmjFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
step_id="confirm", description_placeholders=placeholders
)
async def async_step_ssdp(self, discovery_info: ssdp.SsdpServiceInfo) -> FlowResult:
async def async_step_ssdp(
self, discovery_info: ssdp.SsdpServiceInfo
) -> ConfigFlowResult:
"""Handle a discovered device."""
host = str(urlparse(discovery_info.ssdp_location).hostname)
port = DEFAULT_PORT

View File

@ -7,14 +7,13 @@ from typing import Any
from aioaseko import APIUnavailable, InvalidAuthCredentials, MobileAccount, WebAccount
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import (
CONF_ACCESS_TOKEN,
CONF_EMAIL,
CONF_PASSWORD,
CONF_UNIQUE_ID,
)
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import DOMAIN
@ -22,7 +21,7 @@ from .const import DOMAIN
_LOGGER = logging.getLogger(__name__)
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class AsekoConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Aseko Pool Live."""
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 = {}
if user_input is not None:

View File

@ -14,7 +14,7 @@ from homeassistant.components.device_tracker import (
CONF_CONSIDER_HOME,
DEFAULT_CONSIDER_HOME,
)
from homeassistant.config_entries import ConfigEntry, ConfigFlow
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.const import (
CONF_BASE,
CONF_HOST,
@ -25,7 +25,6 @@ from homeassistant.const import (
CONF_USERNAME,
)
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.schema_config_entry_flow import (
SchemaCommonFlowHandler,
@ -139,7 +138,7 @@ class AsusWrtFlowHandler(ConfigFlow, domain=DOMAIN):
self._config_data: dict[str, Any] = {}
@callback
def _show_setup_form(self, error: str | None = None) -> FlowResult:
def _show_setup_form(self, error: str | None = None) -> ConfigFlowResult:
"""Show the setup form to the user."""
user_input = self._config_data
@ -228,7 +227,7 @@ class AsusWrtFlowHandler(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 there's one entry without unique ID, we abort config flow
@ -276,7 +275,7 @@ class AsusWrtFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_legacy(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow for legacy settings."""
if user_input is None:
return self.async_show_form(step_id="legacy", data_schema=LEGACY_SCHEMA)
@ -284,7 +283,7 @@ class AsusWrtFlowHandler(ConfigFlow, domain=DOMAIN):
self._config_data.update(user_input)
return await self._async_save_entry()
async def _async_save_entry(self) -> FlowResult:
async def _async_save_entry(self) -> ConfigFlowResult:
"""Save entry data if unique id is valid."""
return self.async_create_entry(
title=self._config_data[CONF_HOST],

View File

@ -4,9 +4,8 @@ from typing import Any
import pyatag
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_HOST, CONF_PORT
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from . import DOMAIN
@ -17,14 +16,14 @@ DATA_SCHEMA = {
}
class AtagConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class AtagConfigFlow(ConfigFlow, domain=DOMAIN):
"""Config flow for Atag."""
VERSION = 1
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initialized by the user."""
if not user_input:
@ -44,7 +43,9 @@ class AtagConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
return self.async_create_entry(title=atag.id, data=user_input)
async def _show_form(self, errors: dict[str, str] | None = None) -> FlowResult:
async def _show_form(
self, errors: dict[str, str] | None = None
) -> ConfigFlowResult:
"""Show the form to the user."""
return self.async_show_form(
step_id="user",

View File

@ -9,10 +9,9 @@ import voluptuous as vol
from yalexs.authenticator import ValidationResult
from yalexs.const import BRANDS, DEFAULT_BRAND
from homeassistant import config_entries
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from .const import (
CONF_ACCESS_TOKEN_CACHE_FILE,
@ -75,7 +74,7 @@ class ValidateResult:
description_placeholders: dict[str, str]
class AugustConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class AugustConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for August."""
VERSION = 1
@ -91,13 +90,13 @@ class AugustConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the initial step."""
return await self.async_step_user_validate()
async def async_step_user_validate(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle authentication."""
errors: dict[str, str] = {}
description_placeholders: dict[str, str] = {}
@ -137,7 +136,7 @@ class AugustConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_validation(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle validation (2fa) step."""
if user_input:
if self._mode == "reauth":
@ -174,7 +173,9 @@ class AugustConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
self._aiohttp_session.detach()
self._august_gateway = 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 configuration by re-auth."""
self._user_auth_details = dict(entry_data)
self._mode = "reauth"
@ -183,7 +184,7 @@ class AugustConfigFlow(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: dict[str, str] = {}
description_placeholders: dict[str, str] = {}
@ -261,7 +262,9 @@ class AugustConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
validation_required, info, errors, description_placeholders
)
async def _async_update_or_create_entry(self, info: dict[str, Any]) -> FlowResult:
async def _async_update_or_create_entry(
self, info: dict[str, Any]
) -> ConfigFlowResult:
"""Update existing entry or create a new one."""
self._async_shutdown_gateway()

View File

@ -8,10 +8,9 @@ from aiohttp import ClientError
from auroranoaa import AuroraForecast
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import aiohttp_client, config_validation as cv
from homeassistant.helpers.schema_config_entry_flow import (
SchemaFlowFormStep,
@ -34,7 +33,7 @@ OPTIONS_FLOW = {
}
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class AuroraConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for NOAA Aurora Integration."""
VERSION = 1
@ -42,14 +41,14 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
@staticmethod
@callback
def async_get_options_flow(
config_entry: config_entries.ConfigEntry,
config_entry: ConfigEntry,
) -> SchemaOptionsFlowHandler:
"""Get the options flow for this handler."""
return SchemaOptionsFlowHandler(config_entry, OPTIONS_FLOW)
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the initial step."""
errors: dict[str, str] = {}

View File

@ -9,9 +9,9 @@ from aurorapy.client import AuroraError, AuroraSerialClient
import serial.tools.list_ports
import voluptuous as vol
from homeassistant import config_entries, core
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import ATTR_SERIAL_NUMBER, CONF_ADDRESS, CONF_PORT
from homeassistant.data_entry_flow import FlowResult
from homeassistant.core import HomeAssistant
from .const import (
ATTR_FIRMWARE,
@ -27,7 +27,7 @@ _LOGGER = logging.getLogger(__name__)
def validate_and_connect(
hass: core.HomeAssistant, data: Mapping[str, Any]
hass: HomeAssistant, data: Mapping[str, Any]
) -> dict[str, str]:
"""Validate the user input allows us to connect.
@ -69,7 +69,7 @@ def scan_comports() -> tuple[list[str] | None, str | None]:
return None, None
class AuroraABBConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class AuroraABBConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Aurora ABB PowerOne."""
VERSION = 1
@ -82,7 +82,7 @@ class AuroraABBConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initialised by the user."""
errors = {}

View File

@ -9,15 +9,14 @@ from aussiebb.asyncio import AussieBB, AuthenticationException
from aussiebb.const import FETCH_TYPES
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import CONF_SERVICES, DOMAIN
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class AussieBroadbandConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Aussie Broadband."""
VERSION = 1
@ -47,7 +46,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the initial step."""
errors: dict[str, str] | None = None
if user_input is not None:
@ -77,7 +76,9 @@ 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 reauth on credential failure."""
self._reauth_username = entry_data[CONF_USERNAME]
@ -85,7 +86,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_reauth_confirm(
self, user_input: dict[str, str] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle users reauth credentials."""
errors: dict[str, str] | None = None

View File

@ -11,10 +11,9 @@ from python_awair.user import AwairUser
import voluptuous as vol
from homeassistant.components import onboarding, zeroconf
from homeassistant.config_entries import SOURCE_ZEROCONF, ConfigFlow
from homeassistant.config_entries import SOURCE_ZEROCONF, ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_DEVICE, CONF_HOST
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import DOMAIN, LOGGER
@ -29,7 +28,7 @@ class AwairFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_zeroconf(
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle zeroconf discovery."""
host = discovery_info.host
@ -58,7 +57,7 @@ class AwairFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_discovery_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):
title = f"{self._device.model} ({self._device.device_id})"
@ -79,12 +78,12 @@ class AwairFlowHandler(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."""
return self.async_show_menu(step_id="user", menu_options=["local", "cloud"])
async def async_step_cloud(self, user_input: Mapping[str, Any]) -> FlowResult:
async def async_step_cloud(self, user_input: Mapping[str, Any]) -> ConfigFlowResult:
"""Handle collecting and verifying Awair Cloud API credentials."""
errors = {}
@ -129,7 +128,7 @@ class AwairFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_local(
self, user_input: Mapping[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Show how to enable local API."""
if user_input is not None:
return await self.async_step_local_pick()
@ -143,7 +142,7 @@ class AwairFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_local_pick(
self, user_input: Mapping[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle collecting and verifying Awair Local API hosts."""
errors = {}
@ -188,13 +187,15 @@ class AwairFlowHandler(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-auth if token invalid."""
return await self.async_step_reauth_confirm()
async def async_step_reauth_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Confirm reauth dialog."""
errors = {}

View File

@ -3,18 +3,19 @@
from collections.abc import Mapping
from typing import Any
from homeassistant import config_entries
from homeassistant.data_entry_flow import FlowResult
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from .const import DOMAIN
class AWSFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class AWSFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a config flow."""
VERSION = 1
async def async_step_import(self, user_input: Mapping[str, Any]) -> FlowResult:
async def async_step_import(
self, user_input: Mapping[str, Any]
) -> ConfigFlowResult:
"""Import a config entry."""
if self._async_current_entries():
return self.async_abort(reason="single_instance_allowed")

View File

@ -9,9 +9,14 @@ from urllib.parse import urlsplit
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import dhcp, ssdp, zeroconf
from homeassistant.config_entries import SOURCE_IGNORE, ConfigEntry
from homeassistant.config_entries import (
SOURCE_IGNORE,
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlowWithConfigEntry,
)
from homeassistant.const import (
CONF_HOST,
CONF_MAC,
@ -22,7 +27,6 @@ from homeassistant.const import (
CONF_USERNAME,
)
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.device_registry import format_mac
from homeassistant.util.network import is_link_local
@ -40,7 +44,7 @@ AXIS_OUI = {"00:40:8c", "ac:cc:8e", "b8:a4:4f"}
DEFAULT_PORT = 80
class AxisFlowHandler(config_entries.ConfigFlow, domain=AXIS_DOMAIN):
class AxisFlowHandler(ConfigFlow, domain=AXIS_DOMAIN):
"""Handle a Axis config flow."""
VERSION = 3
@ -58,7 +62,7 @@ class AxisFlowHandler(config_entries.ConfigFlow, domain=AXIS_DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a Axis config flow start.
Manage device specific parameters.
@ -111,7 +115,7 @@ class AxisFlowHandler(config_entries.ConfigFlow, domain=AXIS_DOMAIN):
errors=errors,
)
async def _create_entry(self, serial: str) -> FlowResult:
async def _create_entry(self, serial: str) -> ConfigFlowResult:
"""Create entry for device.
Generate a name to be used as a prefix for device entities.
@ -134,7 +138,9 @@ class AxisFlowHandler(config_entries.ConfigFlow, domain=AXIS_DOMAIN):
title = f"{model} - {serial}"
return self.async_create_entry(title=title, data=self.device_config)
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."""
self.context["title_placeholders"] = {
CONF_NAME: entry_data[CONF_NAME],
@ -150,7 +156,9 @@ class AxisFlowHandler(config_entries.ConfigFlow, domain=AXIS_DOMAIN):
return await self.async_step_user()
async def async_step_dhcp(self, discovery_info: dhcp.DhcpServiceInfo) -> FlowResult:
async def async_step_dhcp(
self, discovery_info: dhcp.DhcpServiceInfo
) -> ConfigFlowResult:
"""Prepare configuration for a DHCP discovered Axis device."""
return await self._process_discovered_device(
{
@ -161,7 +169,9 @@ class AxisFlowHandler(config_entries.ConfigFlow, domain=AXIS_DOMAIN):
}
)
async def async_step_ssdp(self, discovery_info: ssdp.SsdpServiceInfo) -> FlowResult:
async def async_step_ssdp(
self, discovery_info: ssdp.SsdpServiceInfo
) -> ConfigFlowResult:
"""Prepare configuration for a SSDP discovered Axis device."""
url = urlsplit(discovery_info.upnp[ssdp.ATTR_UPNP_PRESENTATION_URL])
return await self._process_discovered_device(
@ -175,7 +185,7 @@ class AxisFlowHandler(config_entries.ConfigFlow, domain=AXIS_DOMAIN):
async def async_step_zeroconf(
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
) -> ConfigFlowResult:
"""Prepare configuration for a Zeroconf discovered Axis device."""
return await self._process_discovered_device(
{
@ -186,7 +196,9 @@ class AxisFlowHandler(config_entries.ConfigFlow, domain=AXIS_DOMAIN):
}
)
async def _process_discovered_device(self, device: dict[str, Any]) -> FlowResult:
async def _process_discovered_device(
self, device: dict[str, Any]
) -> ConfigFlowResult:
"""Prepare configuration for a discovered Axis device."""
if device[CONF_MAC][:8] not in AXIS_OUI:
return self.async_abort(reason="not_axis_device")
@ -223,21 +235,21 @@ class AxisFlowHandler(config_entries.ConfigFlow, domain=AXIS_DOMAIN):
return await self.async_step_user()
class AxisOptionsFlowHandler(config_entries.OptionsFlowWithConfigEntry):
class AxisOptionsFlowHandler(OptionsFlowWithConfigEntry):
"""Handle Axis device options."""
device: AxisNetworkDevice
async def async_step_init(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Manage the Axis device options."""
self.device = self.hass.data[AXIS_DOMAIN][self.config_entry.entry_id]
return await self.async_step_configure_stream()
async def async_step_configure_stream(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Manage the Axis device stream options."""
if user_input is not None:
self.options.update(user_input)

View File

@ -8,8 +8,7 @@ from aioazuredevops.client import DevOpsClient
import aiohttp
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 CONF_ORG, CONF_PAT, CONF_PROJECT, DOMAIN
@ -27,7 +26,7 @@ class AzureDevOpsFlowHandler(ConfigFlow, domain=DOMAIN):
async def _show_setup_form(
self, errors: dict[str, str] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Show the setup form to the user."""
return self.async_show_form(
step_id="user",
@ -41,7 +40,7 @@ class AzureDevOpsFlowHandler(ConfigFlow, domain=DOMAIN):
errors=errors or {},
)
async def _show_reauth_form(self, errors: dict[str, str]) -> FlowResult:
async def _show_reauth_form(self, errors: dict[str, str]) -> ConfigFlowResult:
"""Show the reauth form to the user."""
return self.async_show_form(
step_id="reauth",
@ -75,7 +74,7 @@ class AzureDevOpsFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, str] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initiated by the user."""
if user_input is None:
return await self._show_setup_form()
@ -92,7 +91,9 @@ class AzureDevOpsFlowHandler(ConfigFlow, domain=DOMAIN):
return await self._show_setup_form(errors)
return self._async_create_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 configuration by re-auth."""
if entry_data.get(CONF_ORG) and entry_data.get(CONF_PROJECT):
self._organization = entry_data[CONF_ORG]
@ -121,7 +122,7 @@ class AzureDevOpsFlowHandler(ConfigFlow, domain=DOMAIN):
)
return self.async_abort(reason="reauth_successful")
def _async_create_entry(self) -> FlowResult:
def _async_create_entry(self) -> ConfigFlowResult:
"""Handle create entry."""
return self.async_create_entry(
title=f"{self._organization}/{self._project}",

View File

@ -8,9 +8,8 @@ from typing import Any
from azure.eventhub.exceptions import EventHubError
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.schema_config_entry_flow import (
SchemaFlowFormStep,
SchemaOptionsFlowHandler,
@ -79,7 +78,7 @@ async def validate_data(data: dict[str, Any]) -> dict[str, str] | None:
return None
class AEHConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class AEHConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for azure event hub."""
VERSION: int = 1
@ -93,14 +92,14 @@ class AEHConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
@staticmethod
@callback
def async_get_options_flow(
config_entry: config_entries.ConfigEntry,
config_entry: ConfigEntry,
) -> SchemaOptionsFlowHandler:
"""Get the options flow for this handler."""
return SchemaOptionsFlowHandler(config_entry, OPTIONS_FLOW)
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the initial user step."""
if self._async_current_entries():
return self.async_abort(reason="single_instance_allowed")
@ -116,7 +115,7 @@ class AEHConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_conn_string(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the connection string steps."""
errors = await self.async_update_and_validate_data(user_input)
if user_input is None or errors is not None:
@ -136,7 +135,7 @@ class AEHConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_sas(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the sas steps."""
errors = await self.async_update_and_validate_data(user_input)
if user_input is None or errors is not None:
@ -154,7 +153,9 @@ class AEHConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
options=self._options,
)
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 config from configuration.yaml."""
if self._async_current_entries():
return self.async_abort(reason="single_instance_allowed")

View File

@ -9,10 +9,9 @@ from aiobafi6 import Device, Service
from aiobafi6.discovery import PORT
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import zeroconf
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_IP_ADDRESS
from homeassistant.data_entry_flow import FlowResult
from .const import DOMAIN, RUN_TIMEOUT
from .models import BAFDiscovery
@ -34,7 +33,7 @@ async def async_try_connect(ip_address: str) -> Device:
return device
class BAFFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class BAFFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle BAF discovery config flow."""
VERSION = 1
@ -45,7 +44,7 @@ class BAFFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_zeroconf(
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle zeroconf discovery."""
if discovery_info.ip_address.version == 6:
return self.async_abort(reason="ipv6_not_supported")
@ -61,7 +60,7 @@ class BAFFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_discovery_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Confirm discovery."""
assert self.discovery is not None
discovery = self.discovery
@ -83,7 +82,7 @@ class BAFFlowHandler(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 = {}
ip_address = (user_input or {}).get(CONF_IP_ADDRESS, "")

View File

@ -8,11 +8,10 @@ from pybalboa import SpaClient
from pybalboa.exceptions import SpaConnectionError
import voluptuous as vol
from homeassistant import exceptions
from homeassistant.config_entries import ConfigEntry, ConfigFlow
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_HOST
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.device_registry import format_mac
from homeassistant.helpers.schema_config_entry_flow import (
SchemaFlowFormStep,
@ -65,7 +64,7 @@ class BalboaSpaClientFlowHandler(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:
@ -87,5 +86,5 @@ class BalboaSpaClientFlowHandler(ConfigFlow, domain=DOMAIN):
)
class CannotConnect(exceptions.HomeAssistantError):
class CannotConnect(HomeAssistantError):
"""Error to indicate we cannot connect."""

View File

@ -10,9 +10,8 @@ from mozart_api.mozart_client import MozartClient
import voluptuous as vol
from homeassistant.components.zeroconf import ZeroconfServiceInfo
from homeassistant.config_entries import ConfigFlow
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_HOST, CONF_MODEL
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.selector import SelectSelector, SelectSelectorConfig
from .const import (
@ -62,7 +61,7 @@ class BangOlufsenConfigFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the initial step."""
data_schema = vol.Schema(
{
@ -121,7 +120,7 @@ class BangOlufsenConfigFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_zeroconf(
self, discovery_info: ZeroconfServiceInfo
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle discovery using Zeroconf."""
# Check if the discovered device is a Mozart device
@ -149,7 +148,7 @@ class BangOlufsenConfigFlowHandler(ConfigFlow, domain=DOMAIN):
return await self.async_step_zeroconf_confirm()
async def _create_entry(self) -> FlowResult:
async def _create_entry(self) -> ConfigFlowResult:
"""Create the config entry for a discovered or manually configured Bang & Olufsen device."""
# Ensure that created entities have a unique and easily identifiable id and not a "friendly name"
self._name = f"{self._model}-{self._serial_number}"
@ -166,7 +165,7 @@ class BangOlufsenConfigFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_zeroconf_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Confirm the configuration of the device."""
if user_input is not None:
return await self._create_entry()

View File

@ -14,10 +14,9 @@ from blebox_uniapi.error import (
from blebox_uniapi.session import ApiHost
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import zeroconf
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT, CONF_USERNAME
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from . import get_maybe_authenticated_session
@ -65,7 +64,7 @@ LOG_MSG = {
}
class BleBoxConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class BleBoxConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for BleBox devices."""
VERSION = 1
@ -89,7 +88,7 @@ class BleBoxConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_zeroconf(
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle zeroconf discovery."""
hass = self.hass
ipaddress = (discovery_info.host, discovery_info.port)
@ -126,7 +125,7 @@ class BleBoxConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_confirm_discovery(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle discovery confirmation."""
if user_input is not None:
return self.async_create_entry(

View File

@ -9,10 +9,9 @@ from blinkpy.auth import Auth, LoginError, TokenRefreshFailed
from blinkpy.blinkpy import Blink, BlinkSetupError
import voluptuous as vol
from homeassistant.config_entries import ConfigFlow
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_PASSWORD, CONF_PIN, CONF_USERNAME
from homeassistant.core import HomeAssistant, callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.aiohttp_client import async_get_clientsession
@ -51,7 +50,7 @@ class BlinkConfigFlow(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 = {}
if user_input is not None:
@ -86,7 +85,7 @@ class BlinkConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_2fa(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle 2FA step."""
errors = {}
if user_input is not None:
@ -113,12 +112,14 @@ class BlinkConfigFlow(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 migration of old entries."""
return await self.async_step_user(dict(entry_data))
@callback
def _async_finish_flow(self) -> FlowResult:
def _async_finish_flow(self) -> ConfigFlowResult:
"""Finish with setup."""
assert self.auth
return self.async_create_entry(title=DOMAIN, data=self.auth.login_attributes)

View File

@ -13,24 +13,23 @@ from bluecurrent_api.exceptions import (
)
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_API_TOKEN
from homeassistant.data_entry_flow import FlowResult
from .const import DOMAIN, LOGGER
DATA_SCHEMA = vol.Schema({vol.Required(CONF_API_TOKEN): str})
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class BlueCurrentConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle the config flow for Blue Current."""
VERSION = 1
_reauth_entry: config_entries.ConfigEntry | None = None
_reauth_entry: ConfigEntry | None = None
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the initial step."""
errors = {}
if user_input is not None:
@ -75,7 +74,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
step_id="user", data_schema=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:
"""Handle a reauthorization flow request."""
self._reauth_entry = self.hass.config_entries.async_get_entry(
self.context["entry_id"]

View File

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

View File

@ -1,7 +1,7 @@
"""Config flow to configure the Bluetooth integration."""
from __future__ import annotations
from typing import TYPE_CHECKING, Any, cast
from typing import Any, cast
from bluetooth_adapters import (
ADAPTER_ADDRESS,
@ -13,7 +13,7 @@ from bluetooth_adapters import (
import voluptuous as vol
from homeassistant.components import onboarding
from homeassistant.config_entries import ConfigEntry, ConfigFlow
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.core import callback
from homeassistant.helpers.schema_config_entry_flow import (
SchemaFlowFormStep,
@ -24,9 +24,6 @@ from homeassistant.helpers.typing import DiscoveryInfoType
from . import models
from .const import CONF_ADAPTER, CONF_DETAILS, CONF_PASSIVE, DOMAIN
if TYPE_CHECKING:
from homeassistant.data_entry_flow import FlowResult
OPTIONS_SCHEMA = vol.Schema(
{
vol.Required(CONF_PASSIVE, default=False): bool,
@ -50,7 +47,7 @@ class BluetoothConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_integration_discovery(
self, discovery_info: DiscoveryInfoType
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initialized by discovery."""
self._adapter = cast(str, discovery_info[CONF_ADAPTER])
self._details = cast(AdapterDetails, discovery_info[CONF_DETAILS])
@ -63,7 +60,7 @@ class BluetoothConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_single_adapter(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Select an adapter."""
adapter = self._adapter
details = self._details
@ -86,7 +83,7 @@ class BluetoothConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_multiple_adapters(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initialized by the user."""
if user_input is not None:
assert self._adapters is not None
@ -138,7 +135,7 @@ class BluetoothConfigFlow(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_multiple_adapters()

View File

@ -10,10 +10,15 @@ from bimmer_connected.models import MyBMWAPIError, MyBMWAuthError
from httpx import RequestError
import voluptuous as vol
from homeassistant import config_entries, core, exceptions
from homeassistant.config_entries import (
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlowWithConfigEntry,
)
from homeassistant.const import CONF_PASSWORD, CONF_REGION, CONF_SOURCE, CONF_USERNAME
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import HomeAssistantError
from . import DOMAIN
from .const import CONF_ALLOWED_REGIONS, CONF_GCID, CONF_READ_ONLY, CONF_REFRESH_TOKEN
@ -27,9 +32,7 @@ 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 us to connect.
Data has the keys from DATA_SCHEMA with values provided by the user.
@ -56,16 +59,16 @@ async def validate_input(
return retval
class BMWConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class BMWConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for MyBMW."""
VERSION = 1
_reauth_entry: config_entries.ConfigEntry | None = None
_reauth_entry: ConfigEntry | None = None
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the initial step."""
errors: dict[str, str] = {}
@ -112,7 +115,9 @@ class BMWConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
return self.async_show_form(step_id="user", data_schema=schema, errors=errors)
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
async def async_step_reauth(
self, entry_data: Mapping[str, Any]
) -> ConfigFlowResult:
"""Handle configuration by re-auth."""
self._reauth_entry = self.hass.config_entries.async_get_entry(
self.context["entry_id"]
@ -122,24 +127,24 @@ class BMWConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
@staticmethod
@callback
def async_get_options_flow(
config_entry: config_entries.ConfigEntry,
config_entry: ConfigEntry,
) -> BMWOptionsFlow:
"""Return a MyBMW option flow."""
return BMWOptionsFlow(config_entry)
class BMWOptionsFlow(config_entries.OptionsFlowWithConfigEntry):
class BMWOptionsFlow(OptionsFlowWithConfigEntry):
"""Handle a option flow for MyBMW."""
async def async_step_init(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Manage the options."""
return await self.async_step_account_options()
async def async_step_account_options(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the initial step."""
if user_input is not None:
# Manually update & reload the config entry after options change.
@ -166,9 +171,9 @@ class BMWOptionsFlow(config_entries.OptionsFlowWithConfigEntry):
)
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

@ -10,12 +10,11 @@ from aiohttp import ClientConnectionError, ClientResponseError
from bond_async import Bond
import voluptuous as vol
from homeassistant import config_entries, exceptions
from homeassistant.components import zeroconf
from homeassistant.config_entries import ConfigEntryState
from homeassistant.config_entries import ConfigEntryState, ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_HOST, CONF_NAME
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResult
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import DOMAIN
@ -66,7 +65,7 @@ async def _validate_input(hass: HomeAssistant, data: dict[str, Any]) -> tuple[st
return hub.bond_id, hub.name
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class BondConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Bond."""
VERSION = 1
@ -98,7 +97,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_zeroconf(
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initialized by zeroconf discovery."""
name: str = discovery_info.name
host: str = discovery_info.host
@ -132,7 +131,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle confirmation flow for discovered bond hub."""
errors = {}
if user_input is not None:
@ -173,7 +172,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initialized by the user."""
errors = {}
if user_input is not None:
@ -191,7 +190,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
)
class InputValidationError(exceptions.HomeAssistantError):
class InputValidationError(HomeAssistantError):
"""Error to indicate we cannot proceed due to invalid input."""
def __init__(self, base: str) -> None:

View File

@ -15,11 +15,10 @@ from boschshcpy.exceptions import (
)
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import zeroconf
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_TOKEN
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResult
from .const import (
CONF_HOSTNAME,
@ -87,20 +86,22 @@ def get_info_from_host(
return {"title": information.name, "unique_id": information.unique_id}
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class BoschSHCConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Bosch SHC."""
VERSION = 1
info: dict[str, str | None]
host: str
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
async def async_step_reauth(
self, entry_data: Mapping[str, Any]
) -> ConfigFlowResult:
"""Perform reauth upon an API authentication error."""
return await self.async_step_reauth_confirm()
async def async_step_reauth_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Dialog that informs the user that reauth is required."""
if user_input is None:
return self.async_show_form(
@ -113,7 +114,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:
@ -136,7 +137,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_credentials(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the credentials step."""
errors: dict[str, str] = {}
if user_input is not None:
@ -201,7 +202,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_zeroconf(
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle zeroconf discovery."""
if not discovery_info.name.startswith("Bosch SHC"):
return self.async_abort(reason="not_bosch_shc")
@ -222,7 +223,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_confirm_discovery(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle discovery confirm."""
errors: dict[str, str] = {}
if user_input is not None:

View File

@ -9,11 +9,9 @@ from aiohttp import CookieJar
from pybravia import BraviaAuthError, BraviaClient, BraviaError, BraviaNotSupported
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import ssdp
from homeassistant.config_entries import ConfigEntry
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_CLIENT_ID, CONF_HOST, CONF_MAC, CONF_NAME, CONF_PIN
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import instance_id
from homeassistant.helpers.aiohttp_client import async_create_clientsession
from homeassistant.util.network import is_host_valid
@ -29,7 +27,7 @@ from .const import (
)
class BraviaTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class BraviaTVConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Bravia TV integration."""
VERSION = 1
@ -69,7 +67,7 @@ class BraviaTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
await self.client.connect(pin=pin, clientid=client_id, nickname=nickname)
await self.client.set_wol_mode(True)
async def async_create_device(self) -> FlowResult:
async def async_create_device(self) -> ConfigFlowResult:
"""Create Bravia TV device from config."""
assert self.client
await self.async_connect_device()
@ -85,7 +83,7 @@ class BraviaTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
return self.async_create_entry(title=title, data=self.device_config)
async def async_reauth_device(self) -> FlowResult:
async def async_reauth_device(self) -> ConfigFlowResult:
"""Reauthorize Bravia TV device from config."""
assert self.entry
assert self.client
@ -97,7 +95,7 @@ class BraviaTVConfigFlow(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] = {}
@ -117,7 +115,7 @@ class BraviaTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_authorize(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle authorize step."""
self.create_client()
@ -138,7 +136,7 @@ class BraviaTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_pin(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle PIN authorize step."""
errors: dict[str, str] = {}
client_id, nickname = await self.gen_instance_ids()
@ -177,7 +175,7 @@ class BraviaTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_psk(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle PSK authorize step."""
errors: dict[str, str] = {}
@ -204,7 +202,9 @@ class BraviaTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
errors=errors,
)
async def async_step_ssdp(self, discovery_info: ssdp.SsdpServiceInfo) -> FlowResult:
async def async_step_ssdp(
self, discovery_info: ssdp.SsdpServiceInfo
) -> ConfigFlowResult:
"""Handle a discovered device."""
parsed_url = urlparse(discovery_info.ssdp_location)
host = parsed_url.hostname
@ -234,14 +234,16 @@ class BraviaTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Allow the user to confirm adding the device."""
if user_input is not None:
return await self.async_step_authorize()
return self.async_show_form(step_id="confirm")
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.entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
self.device_config = {**entry_data}

View File

@ -10,7 +10,6 @@ import voluptuous as vol
from homeassistant import config_entries
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.selector import (
TextSelector,
@ -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:
) -> config_entries.ConfigFlowResult:
"""Handle the initial step."""
errors: dict[str, str] = {}
if user_input is not None:

View File

@ -14,10 +14,15 @@ from broadlink.exceptions import (
)
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import dhcp
from homeassistant.config_entries import (
SOURCE_IMPORT,
SOURCE_REAUTH,
ConfigFlow,
ConfigFlowResult,
)
from homeassistant.const import CONF_HOST, CONF_MAC, CONF_NAME, CONF_TIMEOUT, CONF_TYPE
from homeassistant.data_entry_flow import AbortFlow, FlowResult
from homeassistant.data_entry_flow import AbortFlow
from homeassistant.helpers import config_validation as cv
from .const import DEFAULT_PORT, DEFAULT_TIMEOUT, DEVICE_TYPES, DOMAIN
@ -26,7 +31,7 @@ from .helpers import format_mac
_LOGGER = logging.getLogger(__name__)
class BroadlinkFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class BroadlinkFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a Broadlink config flow."""
VERSION = 1
@ -58,7 +63,9 @@ class BroadlinkFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
"host": device.host[0],
}
async def async_step_dhcp(self, discovery_info: dhcp.DhcpServiceInfo) -> FlowResult:
async def async_step_dhcp(
self, discovery_info: dhcp.DhcpServiceInfo
) -> ConfigFlowResult:
"""Handle dhcp discovery."""
host = discovery_info.ip
unique_id = discovery_info.macaddress.lower().replace(":", "")
@ -112,7 +119,7 @@ class BroadlinkFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
else:
device.timeout = timeout
if self.source != config_entries.SOURCE_REAUTH:
if self.source != SOURCE_REAUTH:
await self.async_set_device(device)
self._abort_if_unique_id_configured(
updates={CONF_HOST: device.host[0], CONF_TIMEOUT: timeout}
@ -131,7 +138,7 @@ class BroadlinkFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
_LOGGER.error("Failed to connect to the device at %s: %s", host, err_msg)
if self.source == config_entries.SOURCE_IMPORT:
if self.source == SOURCE_IMPORT:
return self.async_abort(reason=errors["base"])
data_schema = {
@ -175,7 +182,7 @@ class BroadlinkFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
else:
await self.async_set_unique_id(device.mac.hex())
if self.source == config_entries.SOURCE_IMPORT:
if self.source == SOURCE_IMPORT:
_LOGGER.warning(
(
"%s (%s at %s) is ready to be configured. Click "
@ -305,7 +312,9 @@ class BroadlinkFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
self._async_abort_entries_match({CONF_HOST: import_info[CONF_HOST]})
return await self.async_step_user(import_info)
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
async def async_step_reauth(
self, entry_data: Mapping[str, Any]
) -> ConfigFlowResult:
"""Reauthenticate to the device."""
device = blk.gendevice(
entry_data[CONF_TYPE],

View File

@ -6,10 +6,10 @@ from typing import Any
from brother import Brother, SnmpError, UnsupportedModelError
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_TYPE
from homeassistant.data_entry_flow import FlowResult
from homeassistant.exceptions import HomeAssistantError
from homeassistant.util.network import is_host_valid
from .const import DOMAIN, PRINTER_TYPES
@ -23,7 +23,7 @@ DATA_SCHEMA = vol.Schema(
)
class BrotherConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class BrotherConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Brother Printer."""
VERSION = 1
@ -35,7 +35,7 @@ class BrotherConfigFlow(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 = {}
@ -71,7 +71,7 @@ class BrotherConfigFlow(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
@ -107,7 +107,7 @@ class BrotherConfigFlow(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."""
if user_input is not None:
title = f"{self.brother.model} {self.brother.serial}"
@ -127,5 +127,5 @@ class BrotherConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
)
class InvalidHost(exceptions.HomeAssistantError):
class InvalidHost(HomeAssistantError):
"""Error to indicate that hostname/IP address is invalid."""

View File

@ -7,9 +7,8 @@ import uuid
from brottsplatskartan import AREAS
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_LATITUDE, CONF_LOCATION, CONF_LONGITUDE
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import selector
from .const import CONF_APP_ID, CONF_AREA, DEFAULT_NAME, DOMAIN
@ -29,14 +28,14 @@ DATA_SCHEMA = vol.Schema(
)
class BPKConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class BPKConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Brottsplatskartan integration."""
VERSION = 1
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the user step."""
errors: dict[str, str] = {}

View File

@ -10,9 +10,8 @@ from aiohttp.client_exceptions import ServerDisconnectedError
from brunt import BruntClientAsync
import voluptuous as vol
from homeassistant.config_entries import ConfigEntry, ConfigFlow
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.data_entry_flow import FlowResult
from .const import DOMAIN
@ -60,7 +59,7 @@ class BruntConfigFlow(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(step_id="user", data_schema=DATA_SCHEMA)
@ -78,7 +77,9 @@ class BruntConfigFlow(ConfigFlow, domain=DOMAIN):
data=user_input,
)
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
async def async_step_reauth(
self, entry_data: Mapping[str, Any]
) -> ConfigFlowResult:
"""Perform reauth upon an API authentication error."""
self._reauth_entry = self.hass.config_entries.async_get_entry(
self.context["entry_id"]
@ -87,7 +88,7 @@ class BruntConfigFlow(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._reauth_entry
username = self._reauth_entry.data[CONF_USERNAME]

View File

@ -6,10 +6,9 @@ from typing import Any
from bsblan import BSBLAN, BSBLANError
import voluptuous as vol
from homeassistant.config_entries import ConfigFlow
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT, CONF_USERNAME
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.device_registry import format_mac
@ -30,7 +29,7 @@ class BSBLANFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initiated by the user."""
if user_input is None:
return self._show_setup_form()
@ -49,7 +48,7 @@ class BSBLANFlowHandler(ConfigFlow, domain=DOMAIN):
return self._async_create_entry()
@callback
def _show_setup_form(self, errors: dict | None = None) -> FlowResult:
def _show_setup_form(self, errors: dict | None = None) -> ConfigFlowResult:
"""Show the setup form to the user."""
return self.async_show_form(
step_id="user",
@ -66,7 +65,7 @@ class BSBLANFlowHandler(ConfigFlow, domain=DOMAIN):
)
@callback
def _async_create_entry(self) -> FlowResult:
def _async_create_entry(self) -> ConfigFlowResult:
return self.async_create_entry(
title=format_mac(self.mac),
data={

View File

@ -14,9 +14,8 @@ from homeassistant.components.bluetooth import (
BluetoothServiceInfo,
async_discovered_service_info,
)
from homeassistant.config_entries import ConfigFlow
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_ADDRESS
from homeassistant.data_entry_flow import FlowResult
from .const import DOMAIN
@ -47,7 +46,7 @@ class BTHomeConfigFlow(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()
@ -67,7 +66,7 @@ class BTHomeConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_get_encryption_key(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Enter a bindkey for an encrypted BTHome device."""
assert self._discovery_info
assert self._discovered_device
@ -101,7 +100,7 @@ class BTHomeConfigFlow(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()
@ -114,7 +113,7 @@ class BTHomeConfigFlow(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]
@ -157,7 +156,9 @@ class BTHomeConfigFlow(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
@ -173,7 +174,9 @@ class BTHomeConfigFlow(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:
data["bindkey"] = bindkey

View File

@ -6,11 +6,9 @@ from typing import Any, cast
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigEntry
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_COUNTRY_CODE, CONF_LATITUDE, CONF_LONGITUDE
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import selector
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.schema_config_entry_flow import (
@ -73,7 +71,7 @@ OPTIONS_FLOW = {
}
class BuienradarFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class BuienradarFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for buienradar."""
VERSION = 1
@ -88,7 +86,7 @@ class BuienradarFlowHandler(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."""
if user_input is not None:
lat = user_input.get(CONF_LATITUDE)

View File

@ -9,9 +9,8 @@ from caldav.lib.error import AuthorizationError, DAVError
import requests
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_PASSWORD, CONF_URL, CONF_USERNAME, CONF_VERIFY_SSL
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import config_validation as cv
from .const import DOMAIN
@ -29,15 +28,15 @@ STEP_USER_DATA_SCHEMA = vol.Schema(
)
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class CalDavConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for caldav."""
VERSION = 1
_reauth_entry: config_entries.ConfigEntry | None = None
_reauth_entry: ConfigEntry | None = None
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the initial step."""
errors: dict[str, str] = {}
if user_input is not None:
@ -88,7 +87,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
return "unknown"
return 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"]
@ -97,7 +98,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_reauth_confirm(
self, user_input: dict[str, str] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Confirm reauth dialog."""
errors = {}
assert self._reauth_entry

View File

@ -8,10 +8,14 @@ from canary.api import Api
from requests.exceptions import ConnectTimeout, HTTPError
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_PASSWORD, CONF_TIMEOUT, CONF_USERNAME
from homeassistant.core import HomeAssistant, callback
from homeassistant.data_entry_flow import FlowResult
from .const import (
CONF_FFMPEG_ARGUMENTS,
@ -51,13 +55,13 @@ class CanaryConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_import(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initiated by configuration file."""
return await self.async_step_user(user_input)
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initiated by the user."""
if self._async_current_entries():
return self.async_abort(reason="single_instance_allowed")
@ -107,7 +111,7 @@ class CanaryOptionsFlowHandler(OptionsFlow):
async def async_step_init(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Manage Canary options."""
if user_input is not None:
return self.async_create_entry(title="", data=user_input)

View File

@ -5,11 +5,15 @@ from typing import Any
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import onboarding, zeroconf
from homeassistant.config_entries import (
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.const import CONF_UUID
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import config_validation as cv
from .const import CONF_IGNORE_CEC, CONF_KNOWN_HOSTS, DOMAIN
@ -19,7 +23,7 @@ KNOWN_HOSTS_SCHEMA = vol.Schema(vol.All(cv.ensure_list, [cv.string]))
WANTED_UUID_SCHEMA = vol.Schema(vol.All(cv.ensure_list, [cv.string]))
class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class FlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a config flow."""
VERSION = 1
@ -33,7 +37,7 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
@staticmethod
@callback
def async_get_options_flow(
config_entry: config_entries.ConfigEntry,
config_entry: ConfigEntry,
) -> CastOptionsFlowHandler:
"""Get the options flow for this handler."""
return CastOptionsFlowHandler(config_entry)
@ -47,7 +51,7 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_zeroconf(
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initialized by zeroconf discovery."""
if self._async_in_progress() or self._async_current_entries():
return self.async_abort(reason="single_instance_allowed")
@ -101,10 +105,10 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
}
class CastOptionsFlowHandler(config_entries.OptionsFlow):
class CastOptionsFlowHandler(OptionsFlow):
"""Handle Google Cast options."""
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
def __init__(self, config_entry: ConfigEntry) -> None:
"""Initialize Google Cast options flow."""
self.config_entry = config_entry
self.updated_config: dict[str, Any] = {}

View File

@ -7,9 +7,8 @@ from typing import Any
from ccm15 import CCM15Device
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_HOST, CONF_PORT
from homeassistant.data_entry_flow import FlowResult
import homeassistant.helpers.config_validation as cv
from .const import DEFAULT_TIMEOUT, DOMAIN
@ -24,14 +23,14 @@ STEP_USER_DATA_SCHEMA = vol.Schema(
)
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class CCM15ConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Midea ccm15 AC Controller."""
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,9 +7,8 @@ from typing import Any
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import SOURCE_IMPORT, ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_HOST, CONF_PORT
from homeassistant.data_entry_flow import FlowResult
from .const import DEFAULT_PORT, DOMAIN
from .errors import (
@ -23,7 +22,7 @@ from .helper import get_cert_expiry_timestamp
_LOGGER = logging.getLogger(__name__)
class CertexpiryConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class CertexpiryConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow."""
VERSION = 1
@ -57,7 +56,7 @@ class CertexpiryConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user(
self,
user_input: Mapping[str, Any] | None = None,
) -> FlowResult:
) -> ConfigFlowResult:
"""Step when user initializes a integration."""
self._errors = {}
if user_input is not None:
@ -73,7 +72,7 @@ class CertexpiryConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
title=title,
data={CONF_HOST: host, CONF_PORT: port},
)
if self.context["source"] == config_entries.SOURCE_IMPORT:
if self.context["source"] == SOURCE_IMPORT:
_LOGGER.error("Config import failed for %s", user_input[CONF_HOST])
return self.async_abort(reason="import_failed")
else:
@ -97,7 +96,7 @@ class CertexpiryConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_import(
self,
user_input: Mapping[str, Any] | None = None,
) -> FlowResult:
) -> ConfigFlowResult:
"""Import a config entry.
Only host was required in the yaml file all other fields are optional

View File

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

View File

@ -9,10 +9,9 @@ import pycfdns
import voluptuous as vol
from homeassistant.components import persistent_notification
from homeassistant.config_entries import ConfigEntry, ConfigFlow
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_API_TOKEN, CONF_ZONE
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResult
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.aiohttp_client import async_get_clientsession
@ -85,14 +84,16 @@ class CloudflareConfigFlow(ConfigFlow, domain=DOMAIN):
self.zones: list[pycfdns.ZoneModel] | None = None
self.records: list[pycfdns.RecordModel] | 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:
"""Handle initiation of re-authentication with Cloudflare."""
self.entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
return await self.async_step_reauth_confirm()
async def async_step_reauth_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle re-authentication with Cloudflare."""
errors: dict[str, str] = {}
@ -122,7 +123,7 @@ class CloudflareConfigFlow(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._async_current_entries():
return self.async_abort(reason="single_instance_allowed")
@ -145,7 +146,7 @@ class CloudflareConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_zone(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the picking the zone."""
errors: dict[str, str] = {}
@ -167,7 +168,7 @@ class CloudflareConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_records(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the picking the zone records."""
if user_input is not None:

View File

@ -12,15 +12,13 @@ from aioelectricitymaps import (
)
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigEntry
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.const import (
CONF_API_KEY,
CONF_COUNTRY_CODE,
CONF_LATITUDE,
CONF_LONGITUDE,
)
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.selector import (
@ -38,7 +36,7 @@ TYPE_SPECIFY_COORDINATES = "specify_coordinates"
TYPE_SPECIFY_COUNTRY = "specify_country_code"
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class ElectricityMapsConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Co2signal."""
VERSION = 1
@ -47,7 +45,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."""
data_schema = vol.Schema(
{
@ -86,7 +84,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_coordinates(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Validate coordinates."""
data_schema = vol.Schema(
{
@ -109,7 +107,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_country(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Validate country."""
data_schema = vol.Schema(
{
@ -125,7 +123,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
"country", data_schema, {**self._data, **user_input}
)
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
async def async_step_reauth(
self, entry_data: Mapping[str, Any]
) -> ConfigFlowResult:
"""Handle the reauth step."""
self._reauth_entry = self.hass.config_entries.async_get_entry(
self.context["entry_id"]
@ -140,7 +140,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def _validate_and_create(
self, step_id: str, data_schema: vol.Schema, data: Mapping[str, Any]
) -> FlowResult:
) -> ConfigFlowResult:
"""Validate data and show form if it is invalid."""
errors: dict[str, str] = {}

View File

@ -8,10 +8,15 @@ from coinbase.wallet.client import Client
from coinbase.wallet.error import AuthenticationError
import voluptuous as vol
from homeassistant import config_entries, core, exceptions
from homeassistant.config_entries import (
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.const import CONF_API_KEY, CONF_API_TOKEN
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import HomeAssistantError
import homeassistant.helpers.config_validation as cv
from . import get_accounts
@ -48,7 +53,7 @@ def get_user_from_client(api_key, api_token):
return user
async def validate_api(hass: core.HomeAssistant, data):
async def validate_api(hass: HomeAssistant, data):
"""Validate the credentials."""
try:
@ -72,9 +77,7 @@ async def validate_api(hass: core.HomeAssistant, data):
return {"title": user["name"]}
async def validate_options(
hass: core.HomeAssistant, config_entry: config_entries.ConfigEntry, options
):
async def validate_options(hass: HomeAssistant, config_entry: ConfigEntry, options):
"""Validate the requested resources are provided by API."""
client = hass.data[DOMAIN][config_entry.entry_id].client
@ -100,14 +103,14 @@ async def validate_options(
return True
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class CoinbaseConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Coinbase."""
VERSION = 1
async def async_step_user(
self, user_input: dict[str, str] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the initial step."""
errors: dict[str, str] = {}
if user_input is None:
@ -139,22 +142,22 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
@staticmethod
@callback
def async_get_options_flow(
config_entry: config_entries.ConfigEntry,
config_entry: ConfigEntry,
) -> OptionsFlowHandler:
"""Get the options flow for this handler."""
return OptionsFlowHandler(config_entry)
class OptionsFlowHandler(config_entries.OptionsFlow):
class OptionsFlowHandler(OptionsFlow):
"""Handle a option flow for Coinbase."""
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."""
errors = {}
@ -216,29 +219,29 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
)
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 InvalidSecret(exceptions.HomeAssistantError):
class InvalidSecret(HomeAssistantError):
"""Error to indicate auth failed due to invalid secret."""
class InvalidKey(exceptions.HomeAssistantError):
class InvalidKey(HomeAssistantError):
"""Error to indicate auth failed due to invalid key."""
class AlreadyConfigured(exceptions.HomeAssistantError):
class AlreadyConfigured(HomeAssistantError):
"""Error to indicate Coinbase API Key is already configured."""
class CurrencyUnavailable(exceptions.HomeAssistantError):
class CurrencyUnavailable(HomeAssistantError):
"""Error to indicate the requested currency resource is not provided by the API."""
class ExchangeRateUnavailable(exceptions.HomeAssistantError):
class ExchangeRateUnavailable(HomeAssistantError):
"""Error to indicate the requested exchange rate resource is not provided by the API."""

View File

@ -3,9 +3,9 @@ from __future__ import annotations
from typing import Any
from homeassistant.config_entries import ConfigFlow
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN
from homeassistant.data_entry_flow import FlowResult, FlowResultType
from homeassistant.data_entry_flow import FlowResultType
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
from .const import DEFAULT_NAME, DOMAIN
@ -18,7 +18,7 @@ class ColorExtractorConfigFlow(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")
@ -28,7 +28,7 @@ class ColorExtractorConfigFlow(ConfigFlow, domain=DOMAIN):
return self.async_show_form(step_id="user")
async def async_step_import(self, user_input: dict[str, Any]) -> FlowResult:
async def async_step_import(self, user_input: dict[str, Any]) -> ConfigFlowResult:
"""Handle import from configuration.yaml."""
result = await self.async_step_user(user_input)
if result["type"] == FlowResultType.CREATE_ENTRY:

View File

@ -13,10 +13,10 @@ from aiocomelit.api import ComelitCommonApi
from aiocomelit.const import BRIDGE
import voluptuous as vol
from homeassistant import core, exceptions
from homeassistant.config_entries import ConfigEntry, ConfigFlow
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_HOST, CONF_PIN, CONF_PORT, CONF_TYPE
from homeassistant.data_entry_flow import FlowResult
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
import homeassistant.helpers.config_validation as cv
from .const import _LOGGER, DEFAULT_PORT, DEVICE_TYPE_LIST, DOMAIN
@ -41,9 +41,7 @@ def user_form_schema(user_input: dict[str, Any] | None) -> vol.Schema:
STEP_REAUTH_DATA_SCHEMA = vol.Schema({vol.Required(CONF_PIN): cv.positive_int})
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."""
api: ComelitCommonApi
@ -76,7 +74,7 @@ class ComelitConfigFlow(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(
@ -103,7 +101,9 @@ class ComelitConfigFlow(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._reauth_entry = self.hass.config_entries.async_get_entry(
self.context["entry_id"]
@ -117,7 +117,7 @@ class ComelitConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_reauth_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle reauth confirm."""
assert self._reauth_entry
errors = {}
@ -163,9 +163,9 @@ class ComelitConfigFlow(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."""

View File

@ -9,7 +9,7 @@ from pyControl4.director import C4Director
from pyControl4.error_handling import NotFound, Unauthorized
import voluptuous as vol
from homeassistant import config_entries, exceptions
from homeassistant.config_entries import ConfigEntry, ConfigFlow, OptionsFlow
from homeassistant.const import (
CONF_HOST,
CONF_PASSWORD,
@ -17,6 +17,7 @@ from homeassistant.const import (
CONF_USERNAME,
)
from homeassistant.core import callback
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import aiohttp_client, config_validation as cv
from homeassistant.helpers.device_registry import format_mac
@ -86,7 +87,7 @@ class Control4Validator:
return False
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class Control4ConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Control4."""
VERSION = 1
@ -137,16 +138,16 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
@staticmethod
@callback
def async_get_options_flow(
config_entry: config_entries.ConfigEntry,
config_entry: ConfigEntry,
) -> OptionsFlowHandler:
"""Get the options flow for this handler."""
return OptionsFlowHandler(config_entry)
class OptionsFlowHandler(config_entries.OptionsFlow):
class OptionsFlowHandler(OptionsFlow):
"""Handle a option flow for Control4."""
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
def __init__(self, config_entry: ConfigEntry) -> None:
"""Initialize options flow."""
self.config_entry = config_entry
@ -168,9 +169,9 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
return self.async_show_form(step_id="init", data_schema=data_schema)
class CannotConnect(exceptions.HomeAssistantError):
class CannotConnect(HomeAssistantError):
"""Error to indicate we cannot connect."""
class InvalidAuth(exceptions.HomeAssistantError):
class InvalidAuth(HomeAssistantError):
"""Error to indicate there is invalid auth."""

View File

@ -7,10 +7,9 @@ from pycoolmasternet_async import CoolMasterNet
import voluptuous as vol
from homeassistant.components.climate import HVACMode
from homeassistant.config_entries import ConfigFlow
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_HOST, CONF_PORT
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from .const import CONF_SUPPORTED_MODES, CONF_SWING_SUPPORT, DEFAULT_PORT, DOMAIN
@ -46,7 +45,7 @@ class CoolmasterConfigFlow(ConfigFlow, domain=DOMAIN):
VERSION = 1
@callback
def _async_get_entry(self, data: dict[str, Any]) -> FlowResult:
def _async_get_entry(self, data: dict[str, Any]) -> ConfigFlowResult:
supported_modes = [
key for (key, value) in data.items() if key in AVAILABLE_MODES and value
]
@ -62,7 +61,7 @@ class CoolmasterConfigFlow(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 user_input is None:
return self.async_show_form(step_id="user", data_schema=DATA_SCHEMA)

View File

@ -5,8 +5,7 @@ from typing import Any
from cpuinfo import cpuinfo
from homeassistant.config_entries import ConfigFlow
from homeassistant.data_entry_flow import FlowResult
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from .const import DOMAIN
@ -20,7 +19,7 @@ class CPUSpeedFlowHandler(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."""
await self.async_set_unique_id(DOMAIN)
self._abort_if_unique_id_configured()

View File

@ -14,10 +14,15 @@ from serial.tools.list_ports_common import ListPortInfo
import voluptuous as vol
from homeassistant.components import usb
from homeassistant.config_entries import ConfigEntry, ConfigFlow, OptionsFlow
from homeassistant.config_entries import (
ConfigEntry,
ConfigEntryBaseFlow,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowHandler, FlowResult
from homeassistant.helpers import aiohttp_client
from .const import (
@ -37,13 +42,13 @@ CONFIG_FLOW = "config_flow"
OPTIONS_FLOW = "options_flow"
class BaseCrownstoneFlowHandler(FlowHandler):
class BaseCrownstoneFlowHandler(ConfigEntryBaseFlow):
"""Represent the base flow for Crownstone."""
cloud: CrownstoneCloud
def __init__(
self, flow_type: str, create_entry_cb: Callable[..., FlowResult]
self, flow_type: str, create_entry_cb: Callable[..., ConfigFlowResult]
) -> None:
"""Set up flow instance."""
self.flow_type = flow_type
@ -53,7 +58,7 @@ class BaseCrownstoneFlowHandler(FlowHandler):
async def async_step_usb_config(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Set up a Crownstone USB dongle."""
list_of_ports = await self.hass.async_add_executor_job(
serial.tools.list_ports.comports
@ -91,7 +96,7 @@ class BaseCrownstoneFlowHandler(FlowHandler):
async def async_step_usb_manual_config(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Manually enter Crownstone USB dongle path."""
if user_input is None:
return self.async_show_form(
@ -104,7 +109,7 @@ class BaseCrownstoneFlowHandler(FlowHandler):
async def async_step_usb_sphere_config(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Select a Crownstone sphere that the USB operates in."""
spheres = {sphere.name: sphere.cloud_id for sphere in self.cloud.cloud_data}
# no need to select if there's only 1 option
@ -146,7 +151,7 @@ class CrownstoneConfigFlowHandler(BaseCrownstoneFlowHandler, ConfigFlow, 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 None:
@ -189,7 +194,7 @@ class CrownstoneConfigFlowHandler(BaseCrownstoneFlowHandler, ConfigFlow, domain=
self.login_info = user_input
return await self.async_step_usb_config()
def async_create_new_entry(self) -> FlowResult:
def async_create_new_entry(self) -> ConfigFlowResult:
"""Create a new entry."""
return super().async_create_entry(
title=f"Account: {self.login_info[CONF_EMAIL]}",
@ -212,7 +217,7 @@ class CrownstoneOptionsFlowHandler(BaseCrownstoneFlowHandler, OptionsFlow):
async def async_step_init(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Manage Crownstone options."""
self.cloud: CrownstoneCloud = self.hass.data[DOMAIN][self.entry.entry_id].cloud
@ -250,7 +255,7 @@ class CrownstoneOptionsFlowHandler(BaseCrownstoneFlowHandler, OptionsFlow):
return self.async_show_form(step_id="init", data_schema=options_schema)
def async_create_new_entry(self) -> FlowResult:
def async_create_new_entry(self) -> ConfigFlowResult:
"""Create a new entry."""
# these attributes will only change when a usb was configured
if self.usb_path is not None and self.usb_sphere_id is not None:

View File

@ -11,10 +11,9 @@ from pydaikin.daikin_base import Appliance, DaikinException
from pydaikin.discovery import Discovery
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import zeroconf
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_API_KEY, CONF_HOST, CONF_PASSWORD, CONF_UUID
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import DOMAIN, KEY_MAC, TIMEOUT
@ -22,7 +21,7 @@ from .const import DOMAIN, KEY_MAC, TIMEOUT
_LOGGER = logging.getLogger(__name__)
class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class FlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a config flow."""
VERSION = 1
@ -49,7 +48,7 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
key: str | None = None,
uuid: str | None = None,
password: str | None = None,
) -> FlowResult:
) -> ConfigFlowResult:
"""Register new entry."""
if not self.unique_id:
await self.async_set_unique_id(mac)
@ -68,7 +67,7 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def _create_device(
self, host: str, key: str | None = None, password: str | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Create device."""
# BRP07Cxx devices needs uuid together with key
if key:
@ -122,7 +121,7 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""User initiated config flow."""
if user_input is None:
return self.async_show_form(step_id="user", data_schema=self.schema)
@ -141,7 +140,7 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_zeroconf(
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
) -> ConfigFlowResult:
"""Prepare configuration for a discovered Daikin device."""
_LOGGER.debug("Zeroconf user_input: %s", discovery_info)
devices = Discovery().poll(ip=discovery_info.host)

View File

@ -19,13 +19,17 @@ from pydeconz.utils import (
)
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import ssdp
from homeassistant.components.hassio import HassioServiceInfo
from homeassistant.config_entries import ConfigEntry, ConfigFlow, OptionsFlow
from homeassistant.config_entries import (
SOURCE_HASSIO,
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.const import CONF_API_KEY, CONF_HOST, CONF_PORT
from homeassistant.core import HomeAssistant, callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import aiohttp_client
from .const import (
@ -80,7 +84,7 @@ class DeconzFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a deCONZ config flow start.
Let user choose between discovered bridges and manual configuration.
@ -126,7 +130,7 @@ class DeconzFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_manual_input(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Manual configuration."""
if user_input:
self.host = user_input[CONF_HOST]
@ -145,7 +149,7 @@ class DeconzFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_link(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Attempt to link with the deCONZ bridge."""
errors: dict[str, str] = {}
@ -173,7 +177,7 @@ class DeconzFlowHandler(ConfigFlow, domain=DOMAIN):
return self.async_show_form(step_id="link", errors=errors)
async def _create_entry(self) -> FlowResult:
async def _create_entry(self) -> ConfigFlowResult:
"""Create entry for gateway."""
if not self.bridge_id:
session = aiohttp_client.async_get_clientsession(self.hass)
@ -205,7 +209,9 @@ class DeconzFlowHandler(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:
"""Trigger a reauthentication flow."""
self.context["title_placeholders"] = {CONF_HOST: entry_data[CONF_HOST]}
@ -214,7 +220,9 @@ class DeconzFlowHandler(ConfigFlow, domain=DOMAIN):
return await self.async_step_link()
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 deCONZ bridge."""
if LOGGER.isEnabledFor(logging.DEBUG):
LOGGER.debug("deCONZ SSDP discovery %s", pformat(discovery_info))
@ -223,7 +231,7 @@ class DeconzFlowHandler(ConfigFlow, domain=DOMAIN):
parsed_url = urlparse(discovery_info.ssdp_location)
entry = await self.async_set_unique_id(self.bridge_id)
if entry and entry.source == config_entries.SOURCE_HASSIO:
if entry and entry.source == SOURCE_HASSIO:
return self.async_abort(reason="already_configured")
self.host = cast(str, parsed_url.hostname)
@ -245,7 +253,9 @@ class DeconzFlowHandler(ConfigFlow, domain=DOMAIN):
return await self.async_step_link()
async def async_step_hassio(self, discovery_info: HassioServiceInfo) -> FlowResult:
async def async_step_hassio(
self, discovery_info: HassioServiceInfo
) -> ConfigFlowResult:
"""Prepare configuration for a Hass.io deCONZ bridge.
This flow is triggered by the discovery component.
@ -275,7 +285,7 @@ class DeconzFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_hassio_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Confirm a Hass.io discovery."""
if user_input is not None:
@ -299,13 +309,13 @@ class DeconzOptionsFlowHandler(OptionsFlow):
async def async_step_init(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Manage the deCONZ options."""
return await self.async_step_deconz_devices()
async def async_step_deconz_devices(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Manage the deconz devices options."""
if user_input is not None:
self.options.update(user_input)

View File

@ -8,7 +8,7 @@ from typing import Any
from deluge_client.client import DelugeRPCClient
import voluptuous as vol
from homeassistant.config_entries import SOURCE_REAUTH, ConfigFlow
from homeassistant.config_entries import SOURCE_REAUTH, ConfigFlow, ConfigFlowResult
from homeassistant.const import (
CONF_HOST,
CONF_PASSWORD,
@ -16,7 +16,6 @@ from homeassistant.const import (
CONF_SOURCE,
CONF_USERNAME,
)
from homeassistant.data_entry_flow import FlowResult
import homeassistant.helpers.config_validation as cv
from .const import (
@ -33,7 +32,7 @@ class DelugeFlowHandler(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 = {}
@ -75,7 +74,9 @@ class DelugeFlowHandler(ConfigFlow, domain=DOMAIN):
)
return self.async_show_form(step_id="user", data_schema=schema, errors=errors)
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
async def async_step_reauth(
self, entry_data: Mapping[str, Any]
) -> ConfigFlowResult:
"""Handle a reauthorization flow request."""
return await self.async_step_user()

View File

@ -5,9 +5,13 @@ from typing import Any
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
import homeassistant.helpers.config_validation as cv
from . import DOMAIN
@ -19,7 +23,7 @@ CONF_SELECT = "select"
CONF_MULTISELECT = "multi"
class DemoConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class DemoConfigFlow(ConfigFlow, domain=DOMAIN):
"""Demo configuration flow."""
VERSION = 1
@ -27,33 +31,33 @@ class DemoConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
@staticmethod
@callback
def async_get_options_flow(
config_entry: config_entries.ConfigEntry,
config_entry: ConfigEntry,
) -> OptionsFlowHandler:
"""Get the options flow for this handler."""
return OptionsFlowHandler(config_entry)
async def async_step_import(self, import_info: dict[str, Any]) -> FlowResult:
async def async_step_import(self, import_info: dict[str, Any]) -> ConfigFlowResult:
"""Set the config entry up from yaml."""
return self.async_create_entry(title="Demo", data=import_info)
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
self.options = dict(config_entry.options)
async def async_step_init(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Manage the options."""
return await self.async_step_options_1()
async def async_step_options_1(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Manage the options."""
if user_input is not None:
self.options.update(user_input)
@ -78,7 +82,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
async def async_step_options_2(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Manage the options 2."""
if user_input is not None:
self.options.update(user_input)
@ -109,6 +113,6 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
),
)
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

@ -9,11 +9,15 @@ import denonavr
from denonavr.exceptions import AvrNetworkError, AvrTimoutError
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_MODEL, CONF_TYPE
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.httpx_client import get_async_client
from .receiver import ConnectDenonAVR
@ -44,16 +48,16 @@ DEFAULT_USE_TELNET_NEW_INSTALL = True
CONFIG_SCHEMA = vol.Schema({vol.Optional(CONF_HOST): str})
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."""
if user_input is not None:
return self.async_create_entry(title="", data=user_input)
@ -92,7 +96,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
return self.async_show_form(step_id="init", data_schema=settings_schema)
class DenonAvrFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class DenonAvrFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a Denon AVR config flow."""
VERSION = 1
@ -111,14 +115,14 @@ class DenonAvrFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
@staticmethod
@callback
def async_get_options_flow(
config_entry: config_entries.ConfigEntry,
config_entry: ConfigEntry,
) -> OptionsFlowHandler:
"""Get the options flow."""
return OptionsFlowHandler(config_entry)
async def async_step_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:
@ -145,7 +149,7 @@ class DenonAvrFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_select(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle multiple receivers found."""
errors: dict[str, str] = {}
if user_input is not None:
@ -166,7 +170,7 @@ class DenonAvrFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Allow the user to confirm adding the device."""
if user_input is not None:
return await self.async_step_connect()
@ -176,7 +180,7 @@ class DenonAvrFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_connect(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Connect to the receiver."""
assert self.host
connect_denonavr = ConnectDenonAVR(
@ -230,7 +234,9 @@ class DenonAvrFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
options={CONF_USE_TELNET: DEFAULT_USE_TELNET_NEW_INSTALL},
)
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 Denon AVR.
This flow is triggered by the SSDP component. It will check if the

View File

@ -8,9 +8,8 @@ from devialet.devialet_api import DevialetApi
import voluptuous as vol
from homeassistant.components import zeroconf
from homeassistant.config_entries import ConfigFlow
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_HOST, CONF_NAME
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import DOMAIN
@ -31,7 +30,7 @@ class DevialetFlowHandler(ConfigFlow, domain=DOMAIN):
self._serial: str | None = None
self._errors: dict[str, str] = {}
async def async_validate_input(self) -> FlowResult | None:
async def async_validate_input(self) -> ConfigFlowResult | None:
"""Validate the input using the Devialet API."""
self._errors.clear()
@ -53,7 +52,7 @@ class DevialetFlowHandler(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 or zeroconf."""
if user_input is not None:
@ -70,7 +69,7 @@ class DevialetFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_zeroconf(
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initialized by zeroconf discovery."""
LOGGER.info("Devialet device found via ZEROCONF: %s", discovery_info)
@ -87,7 +86,7 @@ class DevialetFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle user-confirmation of discovered node."""
title = f"{self._name} ({self._model})"

View File

@ -6,19 +6,17 @@ from typing import Any
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import zeroconf
from homeassistant.config_entries import ConfigEntry
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from . import configure_mydevolo
from .const import CONF_MYDEVOLO, DEFAULT_MYDEVOLO, DOMAIN, SUPPORTED_MODEL_TYPES
from .exceptions import CredentialsInvalid, UuidChanged
class DevoloHomeControlFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class DevoloHomeControlFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a devolo HomeControl config flow."""
VERSION = 1
@ -34,7 +32,7 @@ class DevoloHomeControlFlowHandler(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.show_advanced_options:
self.data_schema[vol.Required(CONF_MYDEVOLO, default=self._url)] = str
@ -47,7 +45,7 @@ class DevoloHomeControlFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_zeroconf(
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle zeroconf discovery."""
# Check if it is a gateway
if discovery_info.properties.get("MT") in SUPPORTED_MODEL_TYPES:
@ -57,7 +55,7 @@ class DevoloHomeControlFlowHandler(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."""
if user_input is None:
return self._show_form(step_id="zeroconf_confirm")
@ -68,7 +66,9 @@ class DevoloHomeControlFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
step_id="zeroconf_confirm", errors={"base": "invalid_auth"}
)
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 reauthentication."""
self._reauth_entry = self.hass.config_entries.async_get_entry(
self.context["entry_id"]
@ -82,7 +82,7 @@ class DevoloHomeControlFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_reauth_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initiated by reauthentication."""
if user_input is None:
return self._show_form(step_id="reauth_confirm")
@ -97,7 +97,7 @@ class DevoloHomeControlFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
step_id="reauth_confirm", errors={"base": "reauth_failed"}
)
async def _connect_mydevolo(self, user_input: dict[str, Any]) -> FlowResult:
async def _connect_mydevolo(self, user_input: dict[str, Any]) -> ConfigFlowResult:
"""Connect to mydevolo."""
user_input[CONF_MYDEVOLO] = user_input.get(CONF_MYDEVOLO, self._url)
mydevolo = configure_mydevolo(conf=user_input)
@ -135,7 +135,7 @@ class DevoloHomeControlFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
@callback
def _show_form(
self, step_id: str, errors: dict[str, str] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Show the form to the user."""
return self.async_show_form(
step_id=step_id,

View File

@ -9,10 +9,10 @@ from devolo_plc_api.device import Device
from devolo_plc_api.exceptions.device import DeviceNotFound
import voluptuous as vol
from homeassistant import config_entries, core
from homeassistant.components import zeroconf
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_HOST, CONF_IP_ADDRESS, CONF_NAME, CONF_PASSWORD
from homeassistant.data_entry_flow import FlowResult
from homeassistant.core import HomeAssistant
from homeassistant.helpers.httpx_client import get_async_client
from .const import DOMAIN, PRODUCT, SERIAL_NUMBER, TITLE
@ -23,9 +23,7 @@ STEP_USER_DATA_SCHEMA = vol.Schema({vol.Required(CONF_IP_ADDRESS): str})
STEP_REAUTH_DATA_SCHEMA = vol.Schema({vol.Optional(CONF_PASSWORD): str})
async def validate_input(
hass: core.HomeAssistant, data: dict[str, Any]
) -> dict[str, str]:
async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> dict[str, str]:
"""Validate the user input allows us to connect.
Data has the keys from STEP_USER_DATA_SCHEMA with values provided by the user.
@ -44,14 +42,14 @@ async def validate_input(
}
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class DevoloHomeNetworkConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for devolo Home Network."""
VERSION = 1
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the initial step."""
errors: dict = {}
@ -79,7 +77,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_zeroconf(
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle zeroconf discovery."""
if discovery_info.properties["MT"] in ["2600", "2601"]:
return self.async_abort(reason="home_control")
@ -99,7 +97,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."""
title = self.context["title_placeholders"][CONF_NAME]
if user_input is not None:
@ -113,7 +111,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
description_placeholders={"host_name": title},
)
async def async_step_reauth(self, data: Mapping[str, Any]) -> FlowResult:
async def async_step_reauth(self, data: Mapping[str, Any]) -> ConfigFlowResult:
"""Handle reauthentication."""
self.context[CONF_HOST] = data[CONF_IP_ADDRESS]
self.context["title_placeholders"][PRODUCT] = self.hass.data[DOMAIN][
@ -123,7 +121,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_reauth_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initiated by reauthentication."""
if user_input is None:
return self.async_show_form(

View File

@ -4,7 +4,7 @@ from __future__ import annotations
from pydexcom import AccountError, Dexcom, SessionError
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigEntry, ConfigFlow, OptionsFlow
from homeassistant.const import CONF_PASSWORD, CONF_UNIT_OF_MEASUREMENT, CONF_USERNAME
from homeassistant.core import callback
@ -19,7 +19,7 @@ DATA_SCHEMA = vol.Schema(
)
class DexcomConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class DexcomConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Dexcom."""
VERSION = 1
@ -56,16 +56,16 @@ class DexcomConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
@staticmethod
@callback
def async_get_options_flow(
config_entry: config_entries.ConfigEntry,
config_entry: ConfigEntry,
) -> DexcomOptionsFlowHandler:
"""Get the options flow for this handler."""
return DexcomOptionsFlowHandler(config_entry)
class DexcomOptionsFlowHandler(config_entries.OptionsFlow):
class DexcomOptionsFlowHandler(OptionsFlow):
"""Handle a option flow for Dexcom."""
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

@ -9,10 +9,9 @@ from directv import DIRECTV, DIRECTVError
import voluptuous as vol
from homeassistant.components import ssdp
from homeassistant.config_entries import ConfigFlow
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_HOST, CONF_NAME
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import CONF_RECEIVER_ID, DOMAIN
@ -46,7 +45,7 @@ class DirecTVConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initiated by the user."""
if user_input is None:
return self._show_setup_form()
@ -66,7 +65,9 @@ class DirecTVConfigFlow(ConfigFlow, domain=DOMAIN):
return self.async_create_entry(title=user_input[CONF_HOST], data=user_input)
async def async_step_ssdp(self, discovery_info: ssdp.SsdpServiceInfo) -> FlowResult:
async def async_step_ssdp(
self, discovery_info: ssdp.SsdpServiceInfo
) -> ConfigFlowResult:
"""Handle SSDP discovery."""
host = urlparse(discovery_info.ssdp_location).hostname
receiver_id = None
@ -101,7 +102,7 @@ class DirecTVConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_ssdp_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a confirmation flow initiated by SSDP."""
if user_input is None:
return self.async_show_form(
@ -115,7 +116,7 @@ class DirecTVConfigFlow(ConfigFlow, domain=DOMAIN):
data=self.discovery_info,
)
def _show_setup_form(self, errors: dict | None = None) -> FlowResult:
def _show_setup_form(self, errors: dict | None = None) -> ConfigFlowResult:
"""Show the setup form to the user."""
return self.async_show_form(
step_id="user",

View File

@ -9,9 +9,8 @@ from aiohttp.client_exceptions import ClientConnectorError
import nextcord
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_API_TOKEN, CONF_NAME
from homeassistant.data_entry_flow import FlowResult
from .const import DOMAIN, URL_PLACEHOLDER
@ -20,16 +19,18 @@ _LOGGER = logging.getLogger(__name__)
CONFIG_SCHEMA = vol.Schema({vol.Required(CONF_API_TOKEN): str})
class DiscordFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class DiscordFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Discord."""
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
async def async_step_reauth(
self, entry_data: Mapping[str, Any]
) -> ConfigFlowResult:
"""Handle a reauthorization flow request."""
return await self.async_step_reauth_confirm()
async def async_step_reauth_confirm(
self, user_input: dict[str, str] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Confirm reauth dialog."""
errors = {}
@ -52,7 +53,7 @@ class DiscordFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, str] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initiated by the user."""
errors = {}

View File

@ -10,10 +10,8 @@ from pydiscovergy.authentication import BasicAuth
import pydiscovergy.error as discovergyError
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigEntry
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.httpx_client import get_async_client
from homeassistant.helpers.selector import (
TextSelector,
@ -48,7 +46,7 @@ CONFIG_SCHEMA = vol.Schema(
)
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class DiscovergyConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Discovergy."""
VERSION = 1
@ -57,7 +55,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(
@ -67,14 +65,16 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
return await self._validate_and_save(user_input)
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
async def async_step_reauth(
self, entry_data: Mapping[str, Any]
) -> ConfigFlowResult:
"""Handle the initial step."""
self._existing_entry = await self.async_set_unique_id(self.context["unique_id"])
return await self._validate_and_save(entry_data, step_id="reauth")
async def _validate_and_save(
self, user_input: Mapping[str, Any] | None = None, step_id: str = "user"
) -> FlowResult:
) -> ConfigFlowResult:
"""Validate user input and create config entry."""
errors = {}

View File

@ -7,24 +7,25 @@ from typing import Any
from pyW215.pyW215 import SmartPlug
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import dhcp
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME
from homeassistant.data_entry_flow import FlowResult
from .const import CONF_USE_LEGACY_PROTOCOL, DEFAULT_NAME, DEFAULT_USERNAME, DOMAIN
_LOGGER = logging.getLogger(__name__)
class DLinkFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class DLinkFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for D-Link Power Plug."""
def __init__(self) -> None:
"""Initialize a D-Link Power Plug flow."""
self.ip_address: str | None = None
async def async_step_dhcp(self, discovery_info: dhcp.DhcpServiceInfo) -> FlowResult:
async def async_step_dhcp(
self, discovery_info: dhcp.DhcpServiceInfo
) -> ConfigFlowResult:
"""Handle dhcp discovery."""
await self.async_set_unique_id(discovery_info.macaddress)
self._abort_if_unique_id_configured(updates={CONF_HOST: discovery_info.ip})
@ -41,7 +42,7 @@ class DLinkFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_confirm_discovery(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Allow the user to confirm adding the device."""
errors = {}
if user_input is not None:
@ -74,7 +75,7 @@ class DLinkFlowHandler(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 = {}
if user_input is not None:

View File

@ -15,11 +15,15 @@ from async_upnp_client.profiles.profile import find_device_of_type
from getmac import get_mac_address
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_DEVICE_ID, CONF_HOST, CONF_MAC, CONF_TYPE, CONF_URL
from homeassistant.core import HomeAssistant, callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.exceptions import IntegrationError
from homeassistant.helpers import config_validation as cv, device_registry as dr
@ -42,7 +46,7 @@ class ConnectError(IntegrationError):
"""Error occurred when trying to connect to a device."""
class DlnaDmrFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class DlnaDmrFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a DLNA DMR config flow.
The Unique Device Name (UDN) of the DMR device is used as the unique_id for
@ -65,12 +69,12 @@ class DlnaDmrFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
@staticmethod
@callback
def async_get_options_flow(
config_entry: config_entries.ConfigEntry,
) -> config_entries.OptionsFlow:
config_entry: ConfigEntry,
) -> OptionsFlow:
"""Define the config flow to handle options."""
return DlnaDmrOptionsFlowHandler(config_entry)
async def async_step_user(self, user_input: FlowInput = None) -> FlowResult:
async def async_step_user(self, user_input: FlowInput = None) -> ConfigFlowResult:
"""Handle a flow initialized by the user.
Let user choose from a list of found and unconfigured devices or to
@ -102,7 +106,7 @@ class DlnaDmrFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
)
return self.async_show_form(step_id="user", data_schema=data_schema)
async def async_step_manual(self, user_input: FlowInput = None) -> FlowResult:
async def async_step_manual(self, user_input: FlowInput = None) -> ConfigFlowResult:
"""Manual URL entry by the user."""
LOGGER.debug("async_step_manual: user_input: %s", user_input)
@ -124,7 +128,9 @@ class DlnaDmrFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
step_id="manual", data_schema=data_schema, 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 SSDP discovery."""
if LOGGER.isEnabledFor(logging.DEBUG):
LOGGER.debug("async_step_ssdp: discovery_info %s", pformat(discovery_info))
@ -151,7 +157,9 @@ class DlnaDmrFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
return await self.async_step_confirm()
async def async_step_ignore(self, user_input: Mapping[str, Any]) -> FlowResult:
async def async_step_ignore(
self, user_input: Mapping[str, Any]
) -> ConfigFlowResult:
"""Ignore this config flow, and add MAC address as secondary identifier.
Not all DMR devices correctly implement the spec, so their UDN may
@ -185,7 +193,9 @@ class DlnaDmrFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
},
)
async def async_step_unignore(self, user_input: Mapping[str, Any]) -> FlowResult:
async def async_step_unignore(
self, user_input: Mapping[str, Any]
) -> ConfigFlowResult:
"""Rediscover previously ignored devices by their unique_id."""
LOGGER.debug("async_step_unignore: user_input: %s", user_input)
self._udn = user_input["unique_id"]
@ -208,7 +218,9 @@ class DlnaDmrFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
return await self.async_step_confirm()
async def async_step_confirm(self, user_input: FlowInput = None) -> FlowResult:
async def async_step_confirm(
self, user_input: FlowInput = None
) -> ConfigFlowResult:
"""Allow the user to confirm adding the device."""
LOGGER.debug("async_step_confirm: %s", user_input)
@ -256,7 +268,7 @@ class DlnaDmrFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
if not self._mac and (host := urlparse(self._location).hostname):
self._mac = await _async_get_mac_address(self.hass, host)
def _create_entry(self) -> FlowResult:
def _create_entry(self) -> ConfigFlowResult:
"""Create a config entry, assuming all required information is now known."""
LOGGER.debug(
"_async_create_entry: location: %s, UDN: %s", self._location, self._udn
@ -333,19 +345,19 @@ class DlnaDmrFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
return discoveries
class DlnaDmrOptionsFlowHandler(config_entries.OptionsFlow):
class DlnaDmrOptionsFlowHandler(OptionsFlow):
"""Handle a DLNA DMR options flow.
Configures the single instance and updates the existing config entry.
"""
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
def __init__(self, config_entry: ConfigEntry) -> None:
"""Initialize."""
self.config_entry = config_entry
async def async_step_init(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Manage the options."""
errors: dict[str, str] = {}
# Don't modify existing (read-only) options -- copy and update instead

View File

@ -9,10 +9,10 @@ from urllib.parse import urlparse
from async_upnp_client.profiles.dlna import DmsDevice
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import ssdp
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_DEVICE_ID, CONF_HOST, CONF_URL
from homeassistant.data_entry_flow import AbortFlow, FlowResult
from homeassistant.data_entry_flow import AbortFlow
from .const import CONF_SOURCE_ID, CONFIG_VERSION, DEFAULT_NAME, DOMAIN
from .util import generate_source_id
@ -20,7 +20,7 @@ from .util import generate_source_id
LOGGER = logging.getLogger(__name__)
class DlnaDmsFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class DlnaDmsFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a DLNA DMS config flow.
The Unique Service Name (USN) of the DMS device is used as the unique_id for
@ -39,7 +39,7 @@ class DlnaDmsFlowHandler(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 by listing unconfigured devices."""
LOGGER.debug("async_step_user: user_input: %s", user_input)
@ -65,7 +65,9 @@ class DlnaDmsFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
data_schema = vol.Schema({vol.Optional(CONF_HOST): vol.In(discovery_choices)})
return self.async_show_form(step_id="user", 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 flow initialized by SSDP discovery."""
if LOGGER.isEnabledFor(logging.DEBUG):
LOGGER.debug("async_step_ssdp: discovery_info %s", pformat(discovery_info))
@ -101,7 +103,7 @@ class DlnaDmsFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Allow the user to confirm adding the device."""
if user_input is not None:
return self._create_entry()
@ -109,7 +111,7 @@ class DlnaDmsFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
self._set_confirm_only()
return self.async_show_form(step_id="confirm")
def _create_entry(self) -> FlowResult:
def _create_entry(self) -> ConfigFlowResult:
"""Create a config entry, assuming all required information is now known."""
LOGGER.debug(
"_create_entry: name: %s, location: %s, USN: %s",

View File

@ -9,10 +9,14 @@ import aiodns
from aiodns.error import DNSError
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import (
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.const import CONF_NAME
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
import homeassistant.helpers.config_validation as cv
from .const import (
@ -72,7 +76,7 @@ async def async_validate_hostname(
return result
class DnsIPConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
class DnsIPConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for dnsip integration."""
VERSION = 1
@ -80,14 +84,14 @@ class DnsIPConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
@staticmethod
@callback
def async_get_options_flow(
config_entry: config_entries.ConfigEntry,
config_entry: ConfigEntry,
) -> DnsIPOptionsFlowHandler:
"""Return Option handler."""
return DnsIPOptionsFlowHandler(config_entry)
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle the initial step."""
errors = {}
@ -141,16 +145,16 @@ class DnsIPConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
)
class DnsIPOptionsFlowHandler(config_entries.OptionsFlow):
class DnsIPOptionsFlowHandler(OptionsFlow):
"""Handle a option config flow for dnsip integration."""
def __init__(self, entry: config_entries.ConfigEntry) -> None:
def __init__(self, entry: ConfigEntry) -> None:
"""Initialize options flow."""
self.entry = 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:

Some files were not shown because too many files have changed in this diff Show More