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

View file

@ -9,11 +9,9 @@ from aiohttp import ClientError
from aiohttp.client_exceptions import ClientConnectorError from aiohttp.client_exceptions import ClientConnectorError
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.schema_config_entry_flow import ( 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.""" """Config flow for AccuWeather."""
VERSION = 1 VERSION = 1
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle a flow initialized by the user.""" """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 # 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. # 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 aiopulse
import voluptuous as vol 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.const import CONF_HOST, CONF_ID
from homeassistant.data_entry_flow import FlowResult
from .const import DOMAIN from .const import DOMAIN
class AcmedaFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): class AcmedaFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a Acmeda config flow.""" """Handle a Acmeda config flow."""
VERSION = 1 VERSION = 1
@ -26,7 +25,7 @@ class AcmedaFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle a flow initialized by the user.""" """Handle a flow initialized by the user."""
if ( if (
user_input is not None 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.""" """Create the Acmeda Hub entry."""
await self.async_set_unique_id(hub.id, raise_on_progress=False) 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}) 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 adax_local
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import ( from homeassistant.const import (
CONF_IP_ADDRESS, CONF_IP_ADDRESS,
CONF_PASSWORD, CONF_PASSWORD,
CONF_TOKEN, CONF_TOKEN,
CONF_UNIQUE_ID, CONF_UNIQUE_ID,
) )
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import ( from .const import (
@ -31,14 +30,14 @@ from .const import (
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class AdaxConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Adax.""" """Handle a config flow for Adax."""
VERSION = 2 VERSION = 2
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle the initial step.""" """Handle the initial step."""
data_schema = vol.Schema( data_schema = vol.Schema(
{ {
@ -63,7 +62,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_local( async def async_step_local(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle the local step.""" """Handle the local step."""
data_schema = vol.Schema( data_schema = vol.Schema(
{vol.Required(WIFI_SSID): str, vol.Required(WIFI_PSWD): str} {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( async def async_step_cloud(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle the cloud step.""" """Handle the cloud step."""
data_schema = vol.Schema( data_schema = vol.Schema(
{vol.Required(ACCOUNT_ID): int, vol.Required(CONF_PASSWORD): str} {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 import voluptuous as vol
from homeassistant.components.hassio import HassioServiceInfo from homeassistant.components.hassio import HassioServiceInfo
from homeassistant.config_entries import ConfigFlow from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import ( from homeassistant.const import (
CONF_HOST, CONF_HOST,
CONF_PASSWORD, CONF_PASSWORD,
@ -16,7 +16,6 @@ from homeassistant.const import (
CONF_USERNAME, CONF_USERNAME,
CONF_VERIFY_SSL, CONF_VERIFY_SSL,
) )
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import DOMAIN from .const import DOMAIN
@ -31,7 +30,7 @@ class AdGuardHomeFlowHandler(ConfigFlow, domain=DOMAIN):
async def _show_setup_form( async def _show_setup_form(
self, errors: dict[str, str] | None = None self, errors: dict[str, str] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Show the setup form to the user.""" """Show the setup form to the user."""
return self.async_show_form( return self.async_show_form(
step_id="user", step_id="user",
@ -50,7 +49,7 @@ class AdGuardHomeFlowHandler(ConfigFlow, domain=DOMAIN):
async def _show_hassio_form( async def _show_hassio_form(
self, errors: dict[str, str] | None = None self, errors: dict[str, str] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Show the Hass.io confirmation form to the user.""" """Show the Hass.io confirmation form to the user."""
assert self._hassio_discovery assert self._hassio_discovery
return self.async_show_form( return self.async_show_form(
@ -61,7 +60,7 @@ class AdGuardHomeFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle a flow initiated by the user.""" """Handle a flow initiated by the user."""
if user_input is None: if user_input is None:
return await self._show_setup_form(user_input) 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. """Prepare configuration for a Hass.io AdGuard Home add-on.
This flow is triggered by the discovery component. This flow is triggered by the discovery component.
@ -116,7 +117,7 @@ class AdGuardHomeFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_hassio_confirm( async def async_step_hassio_confirm(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Confirm Supervisor discovery.""" """Confirm Supervisor discovery."""
if user_input is None: if user_input is None:
return await self._show_hassio_form() return await self._show_hassio_form()

View file

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

View file

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

View file

@ -7,10 +7,9 @@ from typing import Any
from pyaftership import AfterShip, AfterShipException from pyaftership import AfterShip, AfterShipException
import voluptuous as vol 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.const import CONF_API_KEY, CONF_NAME
from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN 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.aiohttp_client import async_get_clientsession
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
@ -26,7 +25,7 @@ class AfterShipConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle the initial step.""" """Handle the initial step."""
errors: dict[str, str] = {} errors: dict[str, str] = {}
if user_input is not None: if user_input is not None:
@ -49,7 +48,7 @@ class AfterShipConfigFlow(ConfigFlow, domain=DOMAIN):
errors=errors, 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.""" """Import configuration from yaml."""
async_create_issue( async_create_issue(
self.hass, self.hass,

View file

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

View file

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

View file

@ -6,16 +6,15 @@ from pyairnow import WebServiceAPI
from pyairnow.errors import AirNowError, EmptyResponseError, InvalidKeyError from pyairnow.errors import AirNowError, EmptyResponseError, InvalidKeyError
import voluptuous as vol import voluptuous as vol
from homeassistant import core
from homeassistant.config_entries import ( from homeassistant.config_entries import (
ConfigEntry, ConfigEntry,
ConfigFlow, ConfigFlow,
ConfigFlowResult,
OptionsFlow, OptionsFlow,
OptionsFlowWithConfigEntry, OptionsFlowWithConfigEntry,
) )
from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE, CONF_RADIUS from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE, CONF_RADIUS
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant, callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.exceptions import HomeAssistantError from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
@ -62,7 +61,7 @@ class AirNowConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle the initial step.""" """Handle the initial step."""
errors = {} errors = {}
if user_input is not None: if user_input is not None:
@ -117,7 +116,7 @@ class AirNowConfigFlow(ConfigFlow, domain=DOMAIN):
) )
@staticmethod @staticmethod
@core.callback @callback
def async_get_options_flow( def async_get_options_flow(
config_entry: ConfigEntry, config_entry: ConfigEntry,
) -> OptionsFlow: ) -> OptionsFlow:
@ -130,7 +129,7 @@ class AirNowOptionsFlowHandler(OptionsFlowWithConfigEntry):
async def async_step_init( async def async_step_init(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Manage the options.""" """Manage the options."""
if user_input is not None: if user_input is not None:
return self.async_create_entry(data=user_input) 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 from aiohttp.client_exceptions import ClientConnectionError
import voluptuous as vol 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.const import CONF_IP_ADDRESS, CONF_PASSWORD
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import DOMAIN 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.""" """Handle a config flow for air-Q."""
VERSION = 1 VERSION = 1
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle the initial (authentication) configuration step.""" """Handle the initial (authentication) configuration step."""
if user_input is None: if user_input is None:
return self.async_show_form( return self.async_show_form(

View file

@ -7,9 +7,8 @@ from typing import Any
import airthings import airthings
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_ID from homeassistant.const import CONF_ID
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import CONF_SECRET, DOMAIN 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.""" """Handle a config flow for Airthings."""
VERSION = 1 VERSION = 1
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle the initial step.""" """Handle the initial step."""
if user_input is None: if user_input is None:
return self.async_show_form( return self.async_show_form(

View file

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

View file

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

View file

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

View file

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

View file

@ -13,10 +13,8 @@ from pyairvisual.node import (
) )
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_IP_ADDRESS, CONF_PASSWORD from homeassistant.const import CONF_IP_ADDRESS, CONF_PASSWORD
from homeassistant.data_entry_flow import FlowResult
from .const import DOMAIN, LOGGER from .const import DOMAIN, LOGGER
@ -72,7 +70,7 @@ async def async_validate_credentials(
return ValidationResult(errors=errors) return ValidationResult(errors=errors)
class AirVisualProFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): class AirVisualProFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle an AirVisual Pro config flow.""" """Handle an AirVisual Pro config flow."""
VERSION = 1 VERSION = 1
@ -81,11 +79,15 @@ class AirVisualProFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
"""Initialize.""" """Initialize."""
self._reauth_entry: ConfigEntry | None = None 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.""" """Import a config entry from configuration.yaml."""
return await self.async_step_user(import_config) 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.""" """Handle configuration by re-auth."""
self._reauth_entry = self.hass.config_entries.async_get_entry( self._reauth_entry = self.hass.config_entries.async_get_entry(
self.context["entry_id"] self.context["entry_id"]
@ -94,7 +96,7 @@ class AirVisualProFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_reauth_confirm( async def async_step_reauth_confirm(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle the re-auth step.""" """Handle the re-auth step."""
if user_input is None: if user_input is None:
return self.async_show_form( return self.async_show_form(
@ -124,7 +126,7 @@ class AirVisualProFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, user_input: dict[str, str] | None = None self, user_input: dict[str, str] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle the initial step.""" """Handle the initial step."""
if not user_input: if not user_input:
return self.async_show_form(step_id="user", data_schema=STEP_USER_SCHEMA) 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 from aioairzone.localapi import AirzoneLocalApi, ConnectionOptions
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import dhcp from homeassistant.components import dhcp
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_HOST, CONF_ID, CONF_PORT 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 import aiohttp_client
from homeassistant.helpers.device_registry import format_mac from homeassistant.helpers.device_registry import format_mac
@ -38,7 +38,7 @@ def short_mac(addr: str) -> str:
return addr.replace(":", "")[-4:].upper() return addr.replace(":", "")[-4:].upper()
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class AirZoneConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle config flow for an Airzone device.""" """Handle config flow for an Airzone device."""
_discovered_ip: str | None = None _discovered_ip: str | None = None
@ -46,7 +46,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle the initial step.""" """Handle the initial step."""
data_schema = CONFIG_SCHEMA data_schema = CONFIG_SCHEMA
errors = {} errors = {}
@ -91,7 +91,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
errors=errors, 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.""" """Handle DHCP discovery."""
self._discovered_ip = discovery_info.ip self._discovered_ip = discovery_info.ip
self._discovered_mac = discovery_info.macaddress self._discovered_mac = discovery_info.macaddress
@ -118,7 +120,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_discovered_connection( async def async_step_discovered_connection(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Confirm discovery.""" """Confirm discovery."""
assert self._discovered_ip is not None assert self._discovered_ip is not None
assert self._discovered_mac 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 from aioairzone_cloud.exceptions import AirzoneCloudError, LoginError
import voluptuous as vol 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.const import CONF_ID, CONF_PASSWORD, CONF_USERNAME
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import aiohttp_client from homeassistant.helpers import aiohttp_client
from homeassistant.helpers.selector import ( from homeassistant.helpers.selector import (
SelectOptionDict, SelectOptionDict,
@ -23,14 +22,14 @@ from homeassistant.helpers.selector import (
from .const import DOMAIN from .const import DOMAIN
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class AirZoneCloudConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle config flow for an Airzone Cloud device.""" """Handle config flow for an Airzone Cloud device."""
airzone: AirzoneCloudApi airzone: AirzoneCloudApi
async def async_step_inst_pick( async def async_step_inst_pick(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle the installation selection.""" """Handle the installation selection."""
errors = {} errors = {}
options: dict[str, str] = {} options: dict[str, str] = {}
@ -81,7 +80,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle the initial step.""" """Handle the initial step."""
errors = {} errors = {}

View file

@ -9,10 +9,9 @@ import AIOAladdinConnect.session_manager as Aladdin
from aiohttp.client_exceptions import ClientError from aiohttp.client_exceptions import ClientError
import voluptuous as vol 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.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResult
from homeassistant.exceptions import HomeAssistantError from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.aiohttp_client import async_get_clientsession 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 raise InvalidAuth from ex
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class AladdinConnectConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Aladdin Connect.""" """Handle a config flow for Aladdin Connect."""
VERSION = 1 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.""" """Handle re-authentication with Aladdin Connect."""
self.entry = self.hass.config_entries.async_get_entry(self.context["entry_id"]) 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( async def async_step_reauth_confirm(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Confirm re-authentication with Aladdin Connect.""" """Confirm re-authentication with Aladdin Connect."""
errors: dict[str, str] = {} errors: dict[str, str] = {}
@ -102,7 +103,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle the initial step.""" """Handle the initial step."""
if user_input is None: if user_input is None:
return self.async_show_form( return self.async_show_form(

View file

@ -9,14 +9,17 @@ from alarmdecoder.devices import SerialDevice, SocketDevice
from alarmdecoder.util import NoDeviceError from alarmdecoder.util import NoDeviceError
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components.binary_sensor import ( from homeassistant.components.binary_sensor import (
DEVICE_CLASSES_SCHEMA as BINARY_SENSOR_DEVICE_CLASSES_SCHEMA, 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.const import CONF_HOST, CONF_PORT, CONF_PROTOCOL
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from .const import ( from .const import (
CONF_ALT_NIGHT_MODE, CONF_ALT_NIGHT_MODE,
@ -52,7 +55,7 @@ EDIT_SETTINGS = "Arming Settings"
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
class AlarmDecoderFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): class AlarmDecoderFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a AlarmDecoder config flow.""" """Handle a AlarmDecoder config flow."""
VERSION = 1 VERSION = 1
@ -64,14 +67,14 @@ class AlarmDecoderFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
@staticmethod @staticmethod
@callback @callback
def async_get_options_flow( def async_get_options_flow(
config_entry: config_entries.ConfigEntry, config_entry: ConfigEntry,
) -> AlarmDecoderOptionsFlowHandler: ) -> AlarmDecoderOptionsFlowHandler:
"""Get the options flow for AlarmDecoder.""" """Get the options flow for AlarmDecoder."""
return AlarmDecoderOptionsFlowHandler(config_entry) return AlarmDecoderOptionsFlowHandler(config_entry)
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle a flow initialized by the user.""" """Handle a flow initialized by the user."""
if user_input is not None: if user_input is not None:
self.protocol = user_input[CONF_PROTOCOL] self.protocol = user_input[CONF_PROTOCOL]
@ -90,7 +93,7 @@ class AlarmDecoderFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_protocol( async def async_step_protocol(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle AlarmDecoder protocol setup.""" """Handle AlarmDecoder protocol setup."""
errors = {} errors = {}
if user_input is not None: 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.""" """Handle AlarmDecoder options."""
selected_zone: str | None = None 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.""" """Initialize AlarmDecoder options flow."""
self.arm_options = config_entry.options.get(OPTIONS_ARM, DEFAULT_ARM_OPTIONS) self.arm_options = config_entry.options.get(OPTIONS_ARM, DEFAULT_ARM_OPTIONS)
self.zone_options = config_entry.options.get( self.zone_options = config_entry.options.get(
@ -164,7 +167,7 @@ class AlarmDecoderOptionsFlowHandler(config_entries.OptionsFlow):
async def async_step_init( async def async_step_init(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Manage the options.""" """Manage the options."""
if user_input is not None: if user_input is not None:
if user_input[EDIT_KEY] == EDIT_SETTINGS: if user_input[EDIT_KEY] == EDIT_SETTINGS:
@ -185,7 +188,7 @@ class AlarmDecoderOptionsFlowHandler(config_entries.OptionsFlow):
async def async_step_arm_settings( async def async_step_arm_settings(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Arming options form.""" """Arming options form."""
if user_input is not None: if user_input is not None:
return self.async_create_entry( return self.async_create_entry(
@ -214,7 +217,7 @@ class AlarmDecoderOptionsFlowHandler(config_entries.OptionsFlow):
async def async_step_zone_select( async def async_step_zone_select(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Zone selection form.""" """Zone selection form."""
errors = _validate_zone_input(user_input) errors = _validate_zone_input(user_input)
@ -232,7 +235,7 @@ class AlarmDecoderOptionsFlowHandler(config_entries.OptionsFlow):
async def async_step_zone_details( async def async_step_zone_details(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Zone details form.""" """Zone details form."""
errors = _validate_zone_input(user_input) 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 from amberelectric.model.site import Site, SiteStatus
import voluptuous as vol 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.const import CONF_API_TOKEN
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.selector import ( from homeassistant.helpers.selector import (
SelectOptionDict, SelectOptionDict,
SelectSelector, SelectSelector,
@ -43,7 +42,7 @@ def filter_sites(sites: list[Site]) -> list[Site]:
return filtered return filtered
class AmberElectricConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class AmberElectricConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow.""" """Handle a config flow."""
VERSION = 1 VERSION = 1
@ -73,7 +72,7 @@ class AmberElectricConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, user_input: dict[str, str] | None = None self, user_input: dict[str, str] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Step when user initializes a integration.""" """Step when user initializes a integration."""
self._errors = {} self._errors = {}
self._sites = None self._sites = None
@ -107,7 +106,7 @@ class AmberElectricConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_site( async def async_step_site(
self, user_input: dict[str, str] | None = None self, user_input: dict[str, str] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Step to select site.""" """Step to select site."""
self._errors = {} self._errors = {}

View file

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

View file

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

View file

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

View file

@ -7,10 +7,9 @@ from pydroid_ipcam import PyDroidIPCam
from pydroid_ipcam.exceptions import PyDroidIPCamException, Unauthorized from pydroid_ipcam.exceptions import PyDroidIPCamException, Unauthorized
import voluptuous as vol 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.const import CONF_HOST, CONF_PASSWORD, CONF_PORT, CONF_USERNAME
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import config_validation as cv from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.aiohttp_client import async_get_clientsession 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 return errors
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class AndroidIPWebcamConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Android IP Webcam.""" """Handle a config flow for Android IP Webcam."""
VERSION = 1 VERSION = 1
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle the initial step.""" """Handle the initial step."""
if user_input is None: if user_input is None:
return self.async_show_form( return self.async_show_form(

View file

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

View file

@ -16,11 +16,11 @@ from homeassistant.components import zeroconf
from homeassistant.config_entries import ( from homeassistant.config_entries import (
ConfigEntry, ConfigEntry,
ConfigFlow, ConfigFlow,
ConfigFlowResult,
OptionsFlowWithConfigEntry, OptionsFlowWithConfigEntry,
) )
from homeassistant.const import CONF_HOST, CONF_MAC, CONF_NAME from homeassistant.const import CONF_HOST, CONF_MAC, CONF_NAME
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.device_registry import format_mac from homeassistant.helpers.device_registry import format_mac
from .const import CONF_ENABLE_IME, DOMAIN from .const import CONF_ENABLE_IME, DOMAIN
@ -54,7 +54,7 @@ class AndroidTVRemoteConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle the initial step.""" """Handle the initial step."""
errors: dict[str, str] = {} errors: dict[str, str] = {}
if user_input is not None: if user_input is not None:
@ -78,7 +78,7 @@ class AndroidTVRemoteConfigFlow(ConfigFlow, domain=DOMAIN):
errors=errors, 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.""" """Start pairing with the Android TV. Navigate to the pair flow to enter the PIN shown on screen."""
assert self.host assert self.host
self.api = create_api(self.hass, self.host, enable_ime=False) 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( async def async_step_pair(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle the pair step.""" """Handle the pair step."""
errors: dict[str, str] = {} errors: dict[str, str] = {}
if user_input is not None: if user_input is not None:
@ -136,7 +136,7 @@ class AndroidTVRemoteConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_zeroconf( async def async_step_zeroconf(
self, discovery_info: zeroconf.ZeroconfServiceInfo self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle zeroconf discovery.""" """Handle zeroconf discovery."""
self.host = discovery_info.host self.host = discovery_info.host
self.name = discovery_info.name.removesuffix("._androidtvremote2._tcp.local.") self.name = discovery_info.name.removesuffix("._androidtvremote2._tcp.local.")
@ -152,7 +152,7 @@ class AndroidTVRemoteConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_zeroconf_confirm( async def async_step_zeroconf_confirm(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle a flow initiated by zeroconf.""" """Handle a flow initiated by zeroconf."""
if user_input is not None: if user_input is not None:
try: try:
@ -166,7 +166,9 @@ class AndroidTVRemoteConfigFlow(ConfigFlow, domain=DOMAIN):
description_placeholders={CONF_NAME: self.name}, 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.""" """Handle configuration by re-auth."""
self.host = entry_data[CONF_HOST] self.host = entry_data[CONF_HOST]
self.name = entry_data[CONF_NAME] self.name = entry_data[CONF_NAME]
@ -178,7 +180,7 @@ class AndroidTVRemoteConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_reauth_confirm( async def async_step_reauth_confirm(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Dialog that informs the user that reauth is required.""" """Dialog that informs the user that reauth is required."""
errors: dict[str, str] = {} errors: dict[str, str] = {}
if user_input is not None: if user_input is not None:
@ -207,7 +209,7 @@ class AndroidTVRemoteOptionsFlowHandler(OptionsFlowWithConfigEntry):
async def async_step_init( async def async_step_init(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Manage the options.""" """Manage the options."""
if user_input is not None: if user_input is not None:
return self.async_create_entry(title="", data=user_input) 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 from anova_wifi import AnovaApi, InvalidLogin, NoDevicesFound
import voluptuous as vol 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.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 homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import DOMAIN from .const import DOMAIN
@ -20,7 +19,7 @@ class AnovaConfligFlow(ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, user_input: dict[str, str] | None = None self, user_input: dict[str, str] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle a flow initiated by the user.""" """Handle a flow initiated by the user."""
errors: dict[str, str] = {} errors: dict[str, str] = {}
if user_input is not None: if user_input is not None:

View file

@ -9,9 +9,8 @@ from anthemav.connection import Connection
from anthemav.device_error import DeviceError from anthemav.device_error import DeviceError
import voluptuous as vol 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.const import CONF_HOST, CONF_MAC, CONF_MODEL, CONF_PORT
from homeassistant.data_entry_flow import FlowResult
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.device_registry import format_mac from homeassistant.helpers.device_registry import format_mac
@ -44,7 +43,7 @@ class AnthemAVConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle the initial step.""" """Handle the initial step."""
if user_input is None: if user_input is None:
return self.async_show_form( return self.async_show_form(

View file

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

View file

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

View file

@ -10,7 +10,6 @@ import voluptuous as vol
from homeassistant import config_entries from homeassistant import config_entries
from homeassistant.const import CONF_HOST, CONF_PORT from homeassistant.const import CONF_HOST, CONF_PORT
from homeassistant.data_entry_flow import FlowResult
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.device_registry import format_mac from homeassistant.helpers.device_registry import format_mac
@ -34,7 +33,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> config_entries.ConfigFlowResult:
"""Handle the initial step.""" """Handle the initial step."""
if user_input is None: if user_input is None:

View file

@ -7,13 +7,13 @@ from typing import Any
from aranet4.client import Aranet4Advertisement, Version as AranetVersion from aranet4.client import Aranet4Advertisement, Version as AranetVersion
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components.bluetooth import ( from homeassistant.components.bluetooth import (
BluetoothServiceInfoBleak, BluetoothServiceInfoBleak,
async_discovered_service_info, async_discovered_service_info,
) )
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_ADDRESS 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 from .const import DOMAIN
@ -22,7 +22,7 @@ _LOGGER = logging.getLogger(__name__)
MIN_VERSION = AranetVersion(1, 2, 0) MIN_VERSION = AranetVersion(1, 2, 0)
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class AranetConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Aranet.""" """Handle a config flow for Aranet."""
VERSION = 1 VERSION = 1
@ -45,7 +45,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_bluetooth( async def async_step_bluetooth(
self, discovery_info: BluetoothServiceInfoBleak self, discovery_info: BluetoothServiceInfoBleak
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle the Bluetooth discovery step.""" """Handle the Bluetooth discovery step."""
await self.async_set_unique_id(discovery_info.address) await self.async_set_unique_id(discovery_info.address)
self._abort_if_unique_id_configured() self._abort_if_unique_id_configured()
@ -58,7 +58,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_bluetooth_confirm( async def async_step_bluetooth_confirm(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Confirm discovery.""" """Confirm discovery."""
assert self._discovered_device is not None assert self._discovered_device is not None
adv = self._discovered_device adv = self._discovered_device
@ -77,7 +77,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle the user step to pick discovered device.""" """Handle the user step to pick discovered device."""
if user_input is not None: if user_input is not None:
address = user_input[CONF_ADDRESS] 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 from arcam.fmj.utils import get_uniqueid_from_host, get_uniqueid_from_udn
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import ssdp from homeassistant.components import ssdp
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_HOST, CONF_PORT from homeassistant.const import CONF_HOST, CONF_PORT
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import DEFAULT_NAME, DEFAULT_PORT, DOMAIN, DOMAIN_DATA_ENTRIES 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.""" """Retrieve client associated with a config entry."""
client: Client = hass.data[DOMAIN_DATA_ENTRIES][entry.entry_id] client: Client = hass.data[DOMAIN_DATA_ENTRIES][entry.entry_id]
return client return client
class ArcamFmjFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): class ArcamFmjFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle config flow.""" """Handle config flow."""
VERSION = 1 VERSION = 1
@ -35,7 +34,7 @@ class ArcamFmjFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
await self.async_set_unique_id(uuid) await self.async_set_unique_id(uuid)
self._abort_if_unique_id_configured({CONF_HOST: host, CONF_PORT: port}) 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) client = Client(host, port)
try: try:
await client.start() await client.start()
@ -51,7 +50,7 @@ class ArcamFmjFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle a discovered device.""" """Handle a discovered device."""
errors: dict[str, str] = {} errors: dict[str, str] = {}
@ -79,7 +78,7 @@ class ArcamFmjFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_confirm( async def async_step_confirm(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle user-confirmation of discovered node.""" """Handle user-confirmation of discovered node."""
context = self.context context = self.context
placeholders = { placeholders = {
@ -96,7 +95,9 @@ class ArcamFmjFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
step_id="confirm", description_placeholders=placeholders 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.""" """Handle a discovered device."""
host = str(urlparse(discovery_info.ssdp_location).hostname) host = str(urlparse(discovery_info.ssdp_location).hostname)
port = DEFAULT_PORT port = DEFAULT_PORT

View file

@ -7,14 +7,13 @@ from typing import Any
from aioaseko import APIUnavailable, InvalidAuthCredentials, MobileAccount, WebAccount from aioaseko import APIUnavailable, InvalidAuthCredentials, MobileAccount, WebAccount
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import ( from homeassistant.const import (
CONF_ACCESS_TOKEN, CONF_ACCESS_TOKEN,
CONF_EMAIL, CONF_EMAIL,
CONF_PASSWORD, CONF_PASSWORD,
CONF_UNIQUE_ID, CONF_UNIQUE_ID,
) )
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import DOMAIN from .const import DOMAIN
@ -22,7 +21,7 @@ from .const import DOMAIN
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class AsekoConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Aseko Pool Live.""" """Handle a config flow for Aseko Pool Live."""
VERSION = 1 VERSION = 1
@ -45,7 +44,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle the initial step.""" """Handle the initial step."""
errors = {} errors = {}
if user_input is not None: if user_input is not None:

View file

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

View file

@ -4,9 +4,8 @@ from typing import Any
import pyatag import pyatag
import voluptuous as vol 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.const import CONF_HOST, CONF_PORT
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
from . import DOMAIN 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.""" """Config flow for Atag."""
VERSION = 1 VERSION = 1
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle a flow initialized by the user.""" """Handle a flow initialized by the user."""
if not user_input: 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) 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.""" """Show the form to the user."""
return self.async_show_form( return self.async_show_form(
step_id="user", step_id="user",

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -3,18 +3,19 @@
from collections.abc import Mapping from collections.abc import Mapping
from typing import Any from typing import Any
from homeassistant import config_entries from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.data_entry_flow import FlowResult
from .const import DOMAIN from .const import DOMAIN
class AWSFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): class AWSFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a config flow.""" """Handle a config flow."""
VERSION = 1 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.""" """Import a config entry."""
if self._async_current_entries(): if self._async_current_entries():
return self.async_abort(reason="single_instance_allowed") return self.async_abort(reason="single_instance_allowed")

View file

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

View file

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

View file

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

View file

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

View file

@ -8,11 +8,10 @@ from pybalboa import SpaClient
from pybalboa.exceptions import SpaConnectionError from pybalboa.exceptions import SpaConnectionError
import voluptuous as vol import voluptuous as vol
from homeassistant import exceptions from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.config_entries import ConfigEntry, ConfigFlow
from homeassistant.const import CONF_HOST from homeassistant.const import CONF_HOST
from homeassistant.core import callback 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.device_registry import format_mac
from homeassistant.helpers.schema_config_entry_flow import ( from homeassistant.helpers.schema_config_entry_flow import (
SchemaFlowFormStep, SchemaFlowFormStep,
@ -65,7 +64,7 @@ class BalboaSpaClientFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle a flow initialized by the user.""" """Handle a flow initialized by the user."""
errors = {} errors = {}
if user_input is not None: 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.""" """Error to indicate we cannot connect."""

View file

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

View file

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

View file

@ -9,10 +9,9 @@ from blinkpy.auth import Auth, LoginError, TokenRefreshFailed
from blinkpy.blinkpy import Blink, BlinkSetupError from blinkpy.blinkpy import Blink, BlinkSetupError
import voluptuous as vol 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.const import CONF_PASSWORD, CONF_PIN, CONF_USERNAME
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.exceptions import HomeAssistantError from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
@ -51,7 +50,7 @@ class BlinkConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle a flow initiated by the user.""" """Handle a flow initiated by the user."""
errors = {} errors = {}
if user_input is not None: if user_input is not None:
@ -86,7 +85,7 @@ class BlinkConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_2fa( async def async_step_2fa(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle 2FA step.""" """Handle 2FA step."""
errors = {} errors = {}
if user_input is not None: if user_input is not None:
@ -113,12 +112,14 @@ class BlinkConfigFlow(ConfigFlow, domain=DOMAIN):
errors=errors, 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.""" """Perform reauth upon migration of old entries."""
return await self.async_step_user(dict(entry_data)) return await self.async_step_user(dict(entry_data))
@callback @callback
def _async_finish_flow(self) -> FlowResult: def _async_finish_flow(self) -> ConfigFlowResult:
"""Finish with setup.""" """Finish with setup."""
assert self.auth assert self.auth
return self.async_create_entry(title=DOMAIN, data=self.auth.login_attributes) 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 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.const import CONF_API_TOKEN
from homeassistant.data_entry_flow import FlowResult
from .const import DOMAIN, LOGGER from .const import DOMAIN, LOGGER
DATA_SCHEMA = vol.Schema({vol.Required(CONF_API_TOKEN): str}) 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.""" """Handle the config flow for Blue Current."""
VERSION = 1 VERSION = 1
_reauth_entry: config_entries.ConfigEntry | None = None _reauth_entry: ConfigEntry | None = None
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle the initial step.""" """Handle the initial step."""
errors = {} errors = {}
if user_input is not None: 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 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.""" """Handle a reauthorization flow request."""
self._reauth_entry = self.hass.config_entries.async_get_entry( self._reauth_entry = self.hass.config_entries.async_get_entry(
self.context["entry_id"] self.context["entry_id"]

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -6,10 +6,10 @@ from typing import Any
from brother import Brother, SnmpError, UnsupportedModelError from brother import Brother, SnmpError, UnsupportedModelError
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries, exceptions
from homeassistant.components import zeroconf from homeassistant.components import zeroconf
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_HOST, CONF_TYPE 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 homeassistant.util.network import is_host_valid
from .const import DOMAIN, PRINTER_TYPES 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.""" """Handle a config flow for Brother Printer."""
VERSION = 1 VERSION = 1
@ -35,7 +35,7 @@ class BrotherConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle the initial step.""" """Handle the initial step."""
errors = {} errors = {}
@ -71,7 +71,7 @@ class BrotherConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_zeroconf( async def async_step_zeroconf(
self, discovery_info: zeroconf.ZeroconfServiceInfo self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle zeroconf discovery.""" """Handle zeroconf discovery."""
self.host = discovery_info.host self.host = discovery_info.host
@ -107,7 +107,7 @@ class BrotherConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_zeroconf_confirm( async def async_step_zeroconf_confirm(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle a flow initiated by zeroconf.""" """Handle a flow initiated by zeroconf."""
if user_input is not None: if user_input is not None:
title = f"{self.brother.model} {self.brother.serial}" 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.""" """Error to indicate that hostname/IP address is invalid."""

View file

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

View file

@ -10,9 +10,8 @@ from aiohttp.client_exceptions import ServerDisconnectedError
from brunt import BruntClientAsync from brunt import BruntClientAsync
import voluptuous as vol 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.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.data_entry_flow import FlowResult
from .const import DOMAIN from .const import DOMAIN
@ -60,7 +59,7 @@ class BruntConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle the initial step.""" """Handle the initial step."""
if user_input is None: if user_input is None:
return self.async_show_form(step_id="user", data_schema=DATA_SCHEMA) return self.async_show_form(step_id="user", data_schema=DATA_SCHEMA)
@ -78,7 +77,9 @@ class BruntConfigFlow(ConfigFlow, domain=DOMAIN):
data=user_input, 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.""" """Perform reauth upon an API authentication error."""
self._reauth_entry = self.hass.config_entries.async_get_entry( self._reauth_entry = self.hass.config_entries.async_get_entry(
self.context["entry_id"] self.context["entry_id"]
@ -87,7 +88,7 @@ class BruntConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_reauth_confirm( async def async_step_reauth_confirm(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Dialog that informs the user that reauth is required.""" """Dialog that informs the user that reauth is required."""
assert self._reauth_entry assert self._reauth_entry
username = self._reauth_entry.data[CONF_USERNAME] username = self._reauth_entry.data[CONF_USERNAME]

View file

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

View file

@ -14,9 +14,8 @@ from homeassistant.components.bluetooth import (
BluetoothServiceInfo, BluetoothServiceInfo,
async_discovered_service_info, 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.const import CONF_ADDRESS
from homeassistant.data_entry_flow import FlowResult
from .const import DOMAIN from .const import DOMAIN
@ -47,7 +46,7 @@ class BTHomeConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_bluetooth( async def async_step_bluetooth(
self, discovery_info: BluetoothServiceInfo self, discovery_info: BluetoothServiceInfo
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle the bluetooth discovery step.""" """Handle the bluetooth discovery step."""
await self.async_set_unique_id(discovery_info.address) await self.async_set_unique_id(discovery_info.address)
self._abort_if_unique_id_configured() self._abort_if_unique_id_configured()
@ -67,7 +66,7 @@ class BTHomeConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_get_encryption_key( async def async_step_get_encryption_key(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Enter a bindkey for an encrypted BTHome device.""" """Enter a bindkey for an encrypted BTHome device."""
assert self._discovery_info assert self._discovery_info
assert self._discovered_device assert self._discovered_device
@ -101,7 +100,7 @@ class BTHomeConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_bluetooth_confirm( async def async_step_bluetooth_confirm(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Confirm discovery.""" """Confirm discovery."""
if user_input is not None or not onboarding.async_is_onboarded(self.hass): if user_input is not None or not onboarding.async_is_onboarded(self.hass):
return self._async_get_or_create_entry() return self._async_get_or_create_entry()
@ -114,7 +113,7 @@ class BTHomeConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle the user step to pick discovered device.""" """Handle the user step to pick discovered device."""
if user_input is not None: if user_input is not None:
address = user_input[CONF_ADDRESS] 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)}), 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.""" """Handle a flow initialized by a reauth event."""
entry = self.hass.config_entries.async_get_entry(self.context["entry_id"]) entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
assert entry is not None assert entry is not None
@ -173,7 +174,9 @@ class BTHomeConfigFlow(ConfigFlow, domain=DOMAIN):
# Otherwise there wasn't actually encryption so abort # Otherwise there wasn't actually encryption so abort
return self.async_abort(reason="reauth_successful") 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] = {} data: dict[str, Any] = {}
if bindkey: if bindkey:
data["bindkey"] = bindkey data["bindkey"] = bindkey

View file

@ -6,11 +6,9 @@ from typing import Any, cast
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_COUNTRY_CODE, CONF_LATITUDE, CONF_LONGITUDE from homeassistant.const import CONF_COUNTRY_CODE, CONF_LATITUDE, CONF_LONGITUDE
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import selector from homeassistant.helpers import selector
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.schema_config_entry_flow import ( 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.""" """Handle a config flow for buienradar."""
VERSION = 1 VERSION = 1
@ -88,7 +86,7 @@ class BuienradarFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle a flow initialized by the user.""" """Handle a flow initialized by the user."""
if user_input is not None: if user_input is not None:
lat = user_input.get(CONF_LATITUDE) lat = user_input.get(CONF_LATITUDE)

View file

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

View file

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

View file

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

View file

@ -7,9 +7,8 @@ from typing import Any
from ccm15 import CCM15Device from ccm15 import CCM15Device
import voluptuous as vol 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.const import CONF_HOST, CONF_PORT
from homeassistant.data_entry_flow import FlowResult
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from .const import DEFAULT_TIMEOUT, DOMAIN 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.""" """Handle a config flow for Midea ccm15 AC Controller."""
VERSION = 1 VERSION = 1
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle the initial step.""" """Handle the initial step."""
errors: dict[str, str] = {} errors: dict[str, str] = {}
if user_input is not None: if user_input is not None:

View file

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

View file

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

View file

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

View file

@ -8,10 +8,15 @@ from coinbase.wallet.client import Client
from coinbase.wallet.error import AuthenticationError from coinbase.wallet.error import AuthenticationError
import voluptuous as vol 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.const import CONF_API_KEY, CONF_API_TOKEN
from homeassistant.core import callback from homeassistant.core import HomeAssistant, callback
from homeassistant.data_entry_flow import FlowResult from homeassistant.exceptions import HomeAssistantError
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from . import get_accounts from . import get_accounts
@ -48,7 +53,7 @@ def get_user_from_client(api_key, api_token):
return user return user
async def validate_api(hass: core.HomeAssistant, data): async def validate_api(hass: HomeAssistant, data):
"""Validate the credentials.""" """Validate the credentials."""
try: try:
@ -72,9 +77,7 @@ async def validate_api(hass: core.HomeAssistant, data):
return {"title": user["name"]} return {"title": user["name"]}
async def validate_options( async def validate_options(hass: HomeAssistant, config_entry: ConfigEntry, options):
hass: core.HomeAssistant, config_entry: config_entries.ConfigEntry, options
):
"""Validate the requested resources are provided by API.""" """Validate the requested resources are provided by API."""
client = hass.data[DOMAIN][config_entry.entry_id].client client = hass.data[DOMAIN][config_entry.entry_id].client
@ -100,14 +103,14 @@ async def validate_options(
return True return True
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class CoinbaseConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Coinbase.""" """Handle a config flow for Coinbase."""
VERSION = 1 VERSION = 1
async def async_step_user( async def async_step_user(
self, user_input: dict[str, str] | None = None self, user_input: dict[str, str] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle the initial step.""" """Handle the initial step."""
errors: dict[str, str] = {} errors: dict[str, str] = {}
if user_input is None: if user_input is None:
@ -139,22 +142,22 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
@staticmethod @staticmethod
@callback @callback
def async_get_options_flow( def async_get_options_flow(
config_entry: config_entries.ConfigEntry, config_entry: ConfigEntry,
) -> OptionsFlowHandler: ) -> OptionsFlowHandler:
"""Get the options flow for this handler.""" """Get the options flow for this handler."""
return OptionsFlowHandler(config_entry) return OptionsFlowHandler(config_entry)
class OptionsFlowHandler(config_entries.OptionsFlow): class OptionsFlowHandler(OptionsFlow):
"""Handle a option flow for Coinbase.""" """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.""" """Initialize options flow."""
self.config_entry = config_entry self.config_entry = config_entry
async def async_step_init( async def async_step_init(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Manage the options.""" """Manage the options."""
errors = {} errors = {}
@ -216,29 +219,29 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
) )
class CannotConnect(exceptions.HomeAssistantError): class CannotConnect(HomeAssistantError):
"""Error to indicate we cannot connect.""" """Error to indicate we cannot connect."""
class InvalidAuth(exceptions.HomeAssistantError): class InvalidAuth(HomeAssistantError):
"""Error to indicate there is invalid auth.""" """Error to indicate there is invalid auth."""
class InvalidSecret(exceptions.HomeAssistantError): class InvalidSecret(HomeAssistantError):
"""Error to indicate auth failed due to invalid secret.""" """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.""" """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.""" """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.""" """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.""" """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 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.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 homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
from .const import DEFAULT_NAME, DOMAIN from .const import DEFAULT_NAME, DOMAIN
@ -18,7 +18,7 @@ class ColorExtractorConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle a flow initialized by the user.""" """Handle a flow initialized by the user."""
if self._async_current_entries(): if self._async_current_entries():
return self.async_abort(reason="single_instance_allowed") 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") 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.""" """Handle import from configuration.yaml."""
result = await self.async_step_user(user_input) result = await self.async_step_user(user_input)
if result["type"] == FlowResultType.CREATE_ENTRY: if result["type"] == FlowResultType.CREATE_ENTRY:

View file

@ -13,10 +13,10 @@ from aiocomelit.api import ComelitCommonApi
from aiocomelit.const import BRIDGE from aiocomelit.const import BRIDGE
import voluptuous as vol import voluptuous as vol
from homeassistant import core, exceptions from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.config_entries import ConfigEntry, ConfigFlow
from homeassistant.const import CONF_HOST, CONF_PIN, CONF_PORT, CONF_TYPE 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 import homeassistant.helpers.config_validation as cv
from .const import _LOGGER, DEFAULT_PORT, DEVICE_TYPE_LIST, DOMAIN 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}) STEP_REAUTH_DATA_SCHEMA = vol.Schema({vol.Required(CONF_PIN): cv.positive_int})
async def validate_input( async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> dict[str, str]:
hass: core.HomeAssistant, data: dict[str, Any]
) -> dict[str, str]:
"""Validate the user input allows us to connect.""" """Validate the user input allows us to connect."""
api: ComelitCommonApi api: ComelitCommonApi
@ -76,7 +74,7 @@ class ComelitConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle the initial step.""" """Handle the initial step."""
if user_input is None: if user_input is None:
return self.async_show_form( 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 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.""" """Handle reauth flow."""
self._reauth_entry = self.hass.config_entries.async_get_entry( self._reauth_entry = self.hass.config_entries.async_get_entry(
self.context["entry_id"] self.context["entry_id"]
@ -117,7 +117,7 @@ class ComelitConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_reauth_confirm( async def async_step_reauth_confirm(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle reauth confirm.""" """Handle reauth confirm."""
assert self._reauth_entry assert self._reauth_entry
errors = {} errors = {}
@ -163,9 +163,9 @@ class ComelitConfigFlow(ConfigFlow, domain=DOMAIN):
) )
class CannotConnect(exceptions.HomeAssistantError): class CannotConnect(HomeAssistantError):
"""Error to indicate we cannot connect.""" """Error to indicate we cannot connect."""
class InvalidAuth(exceptions.HomeAssistantError): class InvalidAuth(HomeAssistantError):
"""Error to indicate there is invalid auth.""" """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 from pyControl4.error_handling import NotFound, Unauthorized
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries, exceptions from homeassistant.config_entries import ConfigEntry, ConfigFlow, OptionsFlow
from homeassistant.const import ( from homeassistant.const import (
CONF_HOST, CONF_HOST,
CONF_PASSWORD, CONF_PASSWORD,
@ -17,6 +17,7 @@ from homeassistant.const import (
CONF_USERNAME, CONF_USERNAME,
) )
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import aiohttp_client, config_validation as cv from homeassistant.helpers import aiohttp_client, config_validation as cv
from homeassistant.helpers.device_registry import format_mac from homeassistant.helpers.device_registry import format_mac
@ -86,7 +87,7 @@ class Control4Validator:
return False return False
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class Control4ConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Control4.""" """Handle a config flow for Control4."""
VERSION = 1 VERSION = 1
@ -137,16 +138,16 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
@staticmethod @staticmethod
@callback @callback
def async_get_options_flow( def async_get_options_flow(
config_entry: config_entries.ConfigEntry, config_entry: ConfigEntry,
) -> OptionsFlowHandler: ) -> OptionsFlowHandler:
"""Get the options flow for this handler.""" """Get the options flow for this handler."""
return OptionsFlowHandler(config_entry) return OptionsFlowHandler(config_entry)
class OptionsFlowHandler(config_entries.OptionsFlow): class OptionsFlowHandler(OptionsFlow):
"""Handle a option flow for Control4.""" """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.""" """Initialize options flow."""
self.config_entry = config_entry 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) 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.""" """Error to indicate we cannot connect."""
class InvalidAuth(exceptions.HomeAssistantError): class InvalidAuth(HomeAssistantError):
"""Error to indicate there is invalid auth.""" """Error to indicate there is invalid auth."""

View file

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

View file

@ -14,10 +14,15 @@ from serial.tools.list_ports_common import ListPortInfo
import voluptuous as vol import voluptuous as vol
from homeassistant.components import usb 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.const import CONF_EMAIL, CONF_PASSWORD
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowHandler, FlowResult
from homeassistant.helpers import aiohttp_client from homeassistant.helpers import aiohttp_client
from .const import ( from .const import (
@ -37,13 +42,13 @@ CONFIG_FLOW = "config_flow"
OPTIONS_FLOW = "options_flow" OPTIONS_FLOW = "options_flow"
class BaseCrownstoneFlowHandler(FlowHandler): class BaseCrownstoneFlowHandler(ConfigEntryBaseFlow):
"""Represent the base flow for Crownstone.""" """Represent the base flow for Crownstone."""
cloud: CrownstoneCloud cloud: CrownstoneCloud
def __init__( def __init__(
self, flow_type: str, create_entry_cb: Callable[..., FlowResult] self, flow_type: str, create_entry_cb: Callable[..., ConfigFlowResult]
) -> None: ) -> None:
"""Set up flow instance.""" """Set up flow instance."""
self.flow_type = flow_type self.flow_type = flow_type
@ -53,7 +58,7 @@ class BaseCrownstoneFlowHandler(FlowHandler):
async def async_step_usb_config( async def async_step_usb_config(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Set up a Crownstone USB dongle.""" """Set up a Crownstone USB dongle."""
list_of_ports = await self.hass.async_add_executor_job( list_of_ports = await self.hass.async_add_executor_job(
serial.tools.list_ports.comports serial.tools.list_ports.comports
@ -91,7 +96,7 @@ class BaseCrownstoneFlowHandler(FlowHandler):
async def async_step_usb_manual_config( async def async_step_usb_manual_config(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Manually enter Crownstone USB dongle path.""" """Manually enter Crownstone USB dongle path."""
if user_input is None: if user_input is None:
return self.async_show_form( return self.async_show_form(
@ -104,7 +109,7 @@ class BaseCrownstoneFlowHandler(FlowHandler):
async def async_step_usb_sphere_config( async def async_step_usb_sphere_config(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Select a Crownstone sphere that the USB operates in.""" """Select a Crownstone sphere that the USB operates in."""
spheres = {sphere.name: sphere.cloud_id for sphere in self.cloud.cloud_data} spheres = {sphere.name: sphere.cloud_id for sphere in self.cloud.cloud_data}
# no need to select if there's only 1 option # no need to select if there's only 1 option
@ -146,7 +151,7 @@ class CrownstoneConfigFlowHandler(BaseCrownstoneFlowHandler, ConfigFlow, domain=
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle the initial step.""" """Handle the initial step."""
errors: dict[str, str] = {} errors: dict[str, str] = {}
if user_input is None: if user_input is None:
@ -189,7 +194,7 @@ class CrownstoneConfigFlowHandler(BaseCrownstoneFlowHandler, ConfigFlow, domain=
self.login_info = user_input self.login_info = user_input
return await self.async_step_usb_config() 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.""" """Create a new entry."""
return super().async_create_entry( return super().async_create_entry(
title=f"Account: {self.login_info[CONF_EMAIL]}", title=f"Account: {self.login_info[CONF_EMAIL]}",
@ -212,7 +217,7 @@ class CrownstoneOptionsFlowHandler(BaseCrownstoneFlowHandler, OptionsFlow):
async def async_step_init( async def async_step_init(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Manage Crownstone options.""" """Manage Crownstone options."""
self.cloud: CrownstoneCloud = self.hass.data[DOMAIN][self.entry.entry_id].cloud 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) 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.""" """Create a new entry."""
# these attributes will only change when a usb was configured # 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: 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 from pydaikin.discovery import Discovery
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import zeroconf 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.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 homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import DOMAIN, KEY_MAC, TIMEOUT from .const import DOMAIN, KEY_MAC, TIMEOUT
@ -22,7 +21,7 @@ from .const import DOMAIN, KEY_MAC, TIMEOUT
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN): class FlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a config flow.""" """Handle a config flow."""
VERSION = 1 VERSION = 1
@ -49,7 +48,7 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
key: str | None = None, key: str | None = None,
uuid: str | None = None, uuid: str | None = None,
password: str | None = None, password: str | None = None,
) -> FlowResult: ) -> ConfigFlowResult:
"""Register new entry.""" """Register new entry."""
if not self.unique_id: if not self.unique_id:
await self.async_set_unique_id(mac) await self.async_set_unique_id(mac)
@ -68,7 +67,7 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def _create_device( async def _create_device(
self, host: str, key: str | None = None, password: str | None = None self, host: str, key: str | None = None, password: str | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Create device.""" """Create device."""
# BRP07Cxx devices needs uuid together with key # BRP07Cxx devices needs uuid together with key
if key: if key:
@ -122,7 +121,7 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""User initiated config flow.""" """User initiated config flow."""
if user_input is None: if user_input is None:
return self.async_show_form(step_id="user", data_schema=self.schema) 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( async def async_step_zeroconf(
self, discovery_info: zeroconf.ZeroconfServiceInfo self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult: ) -> ConfigFlowResult:
"""Prepare configuration for a discovered Daikin device.""" """Prepare configuration for a discovered Daikin device."""
_LOGGER.debug("Zeroconf user_input: %s", discovery_info) _LOGGER.debug("Zeroconf user_input: %s", discovery_info)
devices = Discovery().poll(ip=discovery_info.host) devices = Discovery().poll(ip=discovery_info.host)

View file

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

View file

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

View file

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

View file

@ -9,11 +9,15 @@ import denonavr
from denonavr.exceptions import AvrNetworkError, AvrTimoutError from denonavr.exceptions import AvrNetworkError, AvrTimoutError
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import ssdp 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.const import CONF_HOST, CONF_MODEL, CONF_TYPE
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.httpx_client import get_async_client from homeassistant.helpers.httpx_client import get_async_client
from .receiver import ConnectDenonAVR from .receiver import ConnectDenonAVR
@ -44,16 +48,16 @@ DEFAULT_USE_TELNET_NEW_INSTALL = True
CONFIG_SCHEMA = vol.Schema({vol.Optional(CONF_HOST): str}) CONFIG_SCHEMA = vol.Schema({vol.Optional(CONF_HOST): str})
class OptionsFlowHandler(config_entries.OptionsFlow): class OptionsFlowHandler(OptionsFlow):
"""Options for the component.""" """Options for the component."""
def __init__(self, config_entry: config_entries.ConfigEntry) -> None: def __init__(self, config_entry: ConfigEntry) -> None:
"""Init object.""" """Init object."""
self.config_entry = config_entry self.config_entry = config_entry
async def async_step_init( async def async_step_init(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Manage the options.""" """Manage the options."""
if user_input is not None: if user_input is not None:
return self.async_create_entry(title="", data=user_input) 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) 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.""" """Handle a Denon AVR config flow."""
VERSION = 1 VERSION = 1
@ -111,14 +115,14 @@ class DenonAvrFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
@staticmethod @staticmethod
@callback @callback
def async_get_options_flow( def async_get_options_flow(
config_entry: config_entries.ConfigEntry, config_entry: ConfigEntry,
) -> OptionsFlowHandler: ) -> OptionsFlowHandler:
"""Get the options flow.""" """Get the options flow."""
return OptionsFlowHandler(config_entry) return OptionsFlowHandler(config_entry)
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle a flow initialized by the user.""" """Handle a flow initialized by the user."""
errors = {} errors = {}
if user_input is not None: if user_input is not None:
@ -145,7 +149,7 @@ class DenonAvrFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_select( async def async_step_select(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle multiple receivers found.""" """Handle multiple receivers found."""
errors: dict[str, str] = {} errors: dict[str, str] = {}
if user_input is not None: if user_input is not None:
@ -166,7 +170,7 @@ class DenonAvrFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_confirm( async def async_step_confirm(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Allow the user to confirm adding the device.""" """Allow the user to confirm adding the device."""
if user_input is not None: if user_input is not None:
return await self.async_step_connect() return await self.async_step_connect()
@ -176,7 +180,7 @@ class DenonAvrFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_connect( async def async_step_connect(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Connect to the receiver.""" """Connect to the receiver."""
assert self.host assert self.host
connect_denonavr = ConnectDenonAVR( connect_denonavr = ConnectDenonAVR(
@ -230,7 +234,9 @@ class DenonAvrFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
options={CONF_USE_TELNET: DEFAULT_USE_TELNET_NEW_INSTALL}, 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. """Handle a discovered Denon AVR.
This flow is triggered by the SSDP component. It will check if the 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 import voluptuous as vol
from homeassistant.components import zeroconf 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.const import CONF_HOST, CONF_NAME
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import DOMAIN from .const import DOMAIN
@ -31,7 +30,7 @@ class DevialetFlowHandler(ConfigFlow, domain=DOMAIN):
self._serial: str | None = None self._serial: str | None = None
self._errors: dict[str, str] = {} 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.""" """Validate the input using the Devialet API."""
self._errors.clear() self._errors.clear()
@ -53,7 +52,7 @@ class DevialetFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle a flow initialized by the user or zeroconf.""" """Handle a flow initialized by the user or zeroconf."""
if user_input is not None: if user_input is not None:
@ -70,7 +69,7 @@ class DevialetFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_zeroconf( async def async_step_zeroconf(
self, discovery_info: zeroconf.ZeroconfServiceInfo self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle a flow initialized by zeroconf discovery.""" """Handle a flow initialized by zeroconf discovery."""
LOGGER.info("Devialet device found via ZEROCONF: %s", discovery_info) LOGGER.info("Devialet device found via ZEROCONF: %s", discovery_info)
@ -87,7 +86,7 @@ class DevialetFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_confirm( async def async_step_confirm(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle user-confirmation of discovered node.""" """Handle user-confirmation of discovered node."""
title = f"{self._name} ({self._model})" title = f"{self._name} ({self._model})"

View file

@ -6,19 +6,17 @@ from typing import Any
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import zeroconf 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.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from . import configure_mydevolo from . import configure_mydevolo
from .const import CONF_MYDEVOLO, DEFAULT_MYDEVOLO, DOMAIN, SUPPORTED_MODEL_TYPES from .const import CONF_MYDEVOLO, DEFAULT_MYDEVOLO, DOMAIN, SUPPORTED_MODEL_TYPES
from .exceptions import CredentialsInvalid, UuidChanged from .exceptions import CredentialsInvalid, UuidChanged
class DevoloHomeControlFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): class DevoloHomeControlFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a devolo HomeControl config flow.""" """Handle a devolo HomeControl config flow."""
VERSION = 1 VERSION = 1
@ -34,7 +32,7 @@ class DevoloHomeControlFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle a flow initiated by the user.""" """Handle a flow initiated by the user."""
if self.show_advanced_options: if self.show_advanced_options:
self.data_schema[vol.Required(CONF_MYDEVOLO, default=self._url)] = str 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( async def async_step_zeroconf(
self, discovery_info: zeroconf.ZeroconfServiceInfo self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle zeroconf discovery.""" """Handle zeroconf discovery."""
# Check if it is a gateway # Check if it is a gateway
if discovery_info.properties.get("MT") in SUPPORTED_MODEL_TYPES: 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( async def async_step_zeroconf_confirm(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle a flow initiated by zeroconf.""" """Handle a flow initiated by zeroconf."""
if user_input is None: if user_input is None:
return self._show_form(step_id="zeroconf_confirm") 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"} 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.""" """Handle reauthentication."""
self._reauth_entry = self.hass.config_entries.async_get_entry( self._reauth_entry = self.hass.config_entries.async_get_entry(
self.context["entry_id"] self.context["entry_id"]
@ -82,7 +82,7 @@ class DevoloHomeControlFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_reauth_confirm( async def async_step_reauth_confirm(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle a flow initiated by reauthentication.""" """Handle a flow initiated by reauthentication."""
if user_input is None: if user_input is None:
return self._show_form(step_id="reauth_confirm") 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"} 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.""" """Connect to mydevolo."""
user_input[CONF_MYDEVOLO] = user_input.get(CONF_MYDEVOLO, self._url) user_input[CONF_MYDEVOLO] = user_input.get(CONF_MYDEVOLO, self._url)
mydevolo = configure_mydevolo(conf=user_input) mydevolo = configure_mydevolo(conf=user_input)
@ -135,7 +135,7 @@ class DevoloHomeControlFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
@callback @callback
def _show_form( def _show_form(
self, step_id: str, errors: dict[str, str] | None = None self, step_id: str, errors: dict[str, str] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Show the form to the user.""" """Show the form to the user."""
return self.async_show_form( return self.async_show_form(
step_id=step_id, 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 from devolo_plc_api.exceptions.device import DeviceNotFound
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries, core
from homeassistant.components import zeroconf 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.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 homeassistant.helpers.httpx_client import get_async_client
from .const import DOMAIN, PRODUCT, SERIAL_NUMBER, TITLE 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}) STEP_REAUTH_DATA_SCHEMA = vol.Schema({vol.Optional(CONF_PASSWORD): str})
async def validate_input( async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> dict[str, str]:
hass: core.HomeAssistant, data: dict[str, Any]
) -> dict[str, str]:
"""Validate the user input allows us to connect. """Validate the user input allows us to connect.
Data has the keys from STEP_USER_DATA_SCHEMA with values provided by the user. 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.""" """Handle a config flow for devolo Home Network."""
VERSION = 1 VERSION = 1
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle the initial step.""" """Handle the initial step."""
errors: dict = {} errors: dict = {}
@ -79,7 +77,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_zeroconf( async def async_step_zeroconf(
self, discovery_info: zeroconf.ZeroconfServiceInfo self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle zeroconf discovery.""" """Handle zeroconf discovery."""
if discovery_info.properties["MT"] in ["2600", "2601"]: if discovery_info.properties["MT"] in ["2600", "2601"]:
return self.async_abort(reason="home_control") return self.async_abort(reason="home_control")
@ -99,7 +97,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_zeroconf_confirm( async def async_step_zeroconf_confirm(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle a flow initiated by zeroconf.""" """Handle a flow initiated by zeroconf."""
title = self.context["title_placeholders"][CONF_NAME] title = self.context["title_placeholders"][CONF_NAME]
if user_input is not None: if user_input is not None:
@ -113,7 +111,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
description_placeholders={"host_name": title}, 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.""" """Handle reauthentication."""
self.context[CONF_HOST] = data[CONF_IP_ADDRESS] self.context[CONF_HOST] = data[CONF_IP_ADDRESS]
self.context["title_placeholders"][PRODUCT] = self.hass.data[DOMAIN][ 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( async def async_step_reauth_confirm(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle a flow initiated by reauthentication.""" """Handle a flow initiated by reauthentication."""
if user_input is None: if user_input is None:
return self.async_show_form( return self.async_show_form(

View file

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

View file

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

View file

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

View file

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

View file

@ -7,24 +7,25 @@ from typing import Any
from pyW215.pyW215 import SmartPlug from pyW215.pyW215 import SmartPlug
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import dhcp from homeassistant.components import dhcp
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME 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 from .const import CONF_USE_LEGACY_PROTOCOL, DEFAULT_NAME, DEFAULT_USERNAME, DOMAIN
_LOGGER = logging.getLogger(__name__) _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.""" """Handle a config flow for D-Link Power Plug."""
def __init__(self) -> None: def __init__(self) -> None:
"""Initialize a D-Link Power Plug flow.""" """Initialize a D-Link Power Plug flow."""
self.ip_address: str | None = None 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.""" """Handle dhcp discovery."""
await self.async_set_unique_id(discovery_info.macaddress) await self.async_set_unique_id(discovery_info.macaddress)
self._abort_if_unique_id_configured(updates={CONF_HOST: discovery_info.ip}) 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( async def async_step_confirm_discovery(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Allow the user to confirm adding the device.""" """Allow the user to confirm adding the device."""
errors = {} errors = {}
if user_input is not None: if user_input is not None:
@ -74,7 +75,7 @@ class DLinkFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle a flow initiated by the user.""" """Handle a flow initiated by the user."""
errors = {} errors = {}
if user_input is not None: 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 from getmac import get_mac_address
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import ssdp 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.const import CONF_DEVICE_ID, CONF_HOST, CONF_MAC, CONF_TYPE, CONF_URL
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.exceptions import IntegrationError from homeassistant.exceptions import IntegrationError
from homeassistant.helpers import config_validation as cv, device_registry as dr 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.""" """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. """Handle a DLNA DMR config flow.
The Unique Device Name (UDN) of the DMR device is used as the unique_id for 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 @staticmethod
@callback @callback
def async_get_options_flow( def async_get_options_flow(
config_entry: config_entries.ConfigEntry, config_entry: ConfigEntry,
) -> config_entries.OptionsFlow: ) -> OptionsFlow:
"""Define the config flow to handle options.""" """Define the config flow to handle options."""
return DlnaDmrOptionsFlowHandler(config_entry) 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. """Handle a flow initialized by the user.
Let user choose from a list of found and unconfigured devices or to 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) 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.""" """Manual URL entry by the user."""
LOGGER.debug("async_step_manual: user_input: %s", user_input) 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 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.""" """Handle a flow initialized by SSDP discovery."""
if LOGGER.isEnabledFor(logging.DEBUG): if LOGGER.isEnabledFor(logging.DEBUG):
LOGGER.debug("async_step_ssdp: discovery_info %s", pformat(discovery_info)) 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() 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. """Ignore this config flow, and add MAC address as secondary identifier.
Not all DMR devices correctly implement the spec, so their UDN may 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.""" """Rediscover previously ignored devices by their unique_id."""
LOGGER.debug("async_step_unignore: user_input: %s", user_input) LOGGER.debug("async_step_unignore: user_input: %s", user_input)
self._udn = user_input["unique_id"] self._udn = user_input["unique_id"]
@ -208,7 +218,9 @@ class DlnaDmrFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
return await self.async_step_confirm() 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.""" """Allow the user to confirm adding the device."""
LOGGER.debug("async_step_confirm: %s", user_input) 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): if not self._mac and (host := urlparse(self._location).hostname):
self._mac = await _async_get_mac_address(self.hass, host) 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.""" """Create a config entry, assuming all required information is now known."""
LOGGER.debug( LOGGER.debug(
"_async_create_entry: location: %s, UDN: %s", self._location, self._udn "_async_create_entry: location: %s, UDN: %s", self._location, self._udn
@ -333,19 +345,19 @@ class DlnaDmrFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
return discoveries return discoveries
class DlnaDmrOptionsFlowHandler(config_entries.OptionsFlow): class DlnaDmrOptionsFlowHandler(OptionsFlow):
"""Handle a DLNA DMR options flow. """Handle a DLNA DMR options flow.
Configures the single instance and updates the existing config entry. 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.""" """Initialize."""
self.config_entry = config_entry self.config_entry = config_entry
async def async_step_init( async def async_step_init(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Manage the options.""" """Manage the options."""
errors: dict[str, str] = {} errors: dict[str, str] = {}
# Don't modify existing (read-only) options -- copy and update instead # 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 from async_upnp_client.profiles.dlna import DmsDevice
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import ssdp 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.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 .const import CONF_SOURCE_ID, CONFIG_VERSION, DEFAULT_NAME, DOMAIN
from .util import generate_source_id from .util import generate_source_id
@ -20,7 +20,7 @@ from .util import generate_source_id
LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__)
class DlnaDmsFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): class DlnaDmsFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a DLNA DMS config flow. """Handle a DLNA DMS config flow.
The Unique Service Name (USN) of the DMS device is used as the unique_id for 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( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle a flow initialized by the user by listing unconfigured devices.""" """Handle a flow initialized by the user by listing unconfigured devices."""
LOGGER.debug("async_step_user: user_input: %s", user_input) 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)}) data_schema = vol.Schema({vol.Optional(CONF_HOST): vol.In(discovery_choices)})
return self.async_show_form(step_id="user", data_schema=data_schema) 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.""" """Handle a flow initialized by SSDP discovery."""
if LOGGER.isEnabledFor(logging.DEBUG): if LOGGER.isEnabledFor(logging.DEBUG):
LOGGER.debug("async_step_ssdp: discovery_info %s", pformat(discovery_info)) 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( async def async_step_confirm(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Allow the user to confirm adding the device.""" """Allow the user to confirm adding the device."""
if user_input is not None: if user_input is not None:
return self._create_entry() return self._create_entry()
@ -109,7 +111,7 @@ class DlnaDmsFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
self._set_confirm_only() self._set_confirm_only()
return self.async_show_form(step_id="confirm") 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.""" """Create a config entry, assuming all required information is now known."""
LOGGER.debug( LOGGER.debug(
"_create_entry: name: %s, location: %s, USN: %s", "_create_entry: name: %s, location: %s, USN: %s",

View file

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

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