Migrate integrations n-r to generic flowhandler (#111864)

This commit is contained in:
Erik Montnemery 2024-02-29 20:09:01 +01:00 committed by GitHub
parent 52e7912caf
commit e0c1feb22c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
113 changed files with 890 additions and 746 deletions

View file

@ -17,11 +17,10 @@ from nettigo_air_monitor 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 ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME
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 homeassistant.helpers.device_registry import format_mac from homeassistant.helpers.device_registry import format_mac
@ -70,7 +69,7 @@ async def async_check_credentials(
await nam.async_check_credentials() await nam.async_check_credentials()
class NAMFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): class NAMFlowHandler(ConfigFlow, domain=DOMAIN):
"""Config flow for Nettigo Air Monitor.""" """Config flow for Nettigo Air Monitor."""
VERSION = 1 VERSION = 1
@ -78,12 +77,12 @@ class NAMFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
def __init__(self) -> None: def __init__(self) -> None:
"""Initialize flow.""" """Initialize flow."""
self.host: str self.host: str
self.entry: config_entries.ConfigEntry self.entry: ConfigEntry
self._config: NamConfig self._config: NamConfig
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: dict[str, str] = {} errors: dict[str, str] = {}
@ -119,7 +118,7 @@ class NAMFlowHandler(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] = {}
@ -145,7 +144,7 @@ class NAMFlowHandler(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
self.context["title_placeholders"] = {"host": self.host} self.context["title_placeholders"] = {"host": self.host}
@ -167,7 +166,7 @@ class NAMFlowHandler(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] = {}
@ -188,7 +187,9 @@ class NAMFlowHandler(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 configuration by re-auth.""" """Handle configuration by re-auth."""
if entry := self.hass.config_entries.async_get_entry(self.context["entry_id"]): if entry := self.hass.config_entries.async_get_entry(self.context["entry_id"]):
self.entry = entry self.entry = entry
@ -198,7 +199,7 @@ class NAMFlowHandler(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:
"""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] = {}

View file

@ -9,10 +9,9 @@ from typing import Any, Final, cast
from aionanoleaf import InvalidToken, Nanoleaf, Unauthorized, Unavailable from aionanoleaf import InvalidToken, Nanoleaf, Unauthorized, Unavailable
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import ssdp, zeroconf from homeassistant.components import ssdp, zeroconf
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_HOST, CONF_TOKEN from homeassistant.const import CONF_HOST, CONF_TOKEN
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.json import save_json from homeassistant.helpers.json import save_json
from homeassistant.util.json import JsonObjectType, JsonValueType, load_json_object from homeassistant.util.json import JsonObjectType, JsonValueType, load_json_object
@ -31,10 +30,10 @@ USER_SCHEMA: Final = vol.Schema(
) )
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class NanoleafConfigFlow(ConfigFlow, domain=DOMAIN):
"""Nanoleaf config flow.""" """Nanoleaf config flow."""
reauth_entry: config_entries.ConfigEntry | None = None reauth_entry: ConfigEntry | None = None
nanoleaf: Nanoleaf nanoleaf: Nanoleaf
@ -46,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 Nanoleaf flow initiated by the user.""" """Handle Nanoleaf flow initiated by the user."""
if user_input is None: if user_input is None:
return self.async_show_form( return self.async_show_form(
@ -77,10 +76,12 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
) )
return await self.async_step_link() return await self.async_step_link()
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 Nanoleaf reauth flow if token is invalid.""" """Handle Nanoleaf reauth flow if token is invalid."""
self.reauth_entry = cast( self.reauth_entry = cast(
config_entries.ConfigEntry, ConfigEntry,
self.hass.config_entries.async_get_entry(self.context["entry_id"]), self.hass.config_entries.async_get_entry(self.context["entry_id"]),
) )
self.nanoleaf = Nanoleaf( self.nanoleaf = Nanoleaf(
@ -91,21 +92,21 @@ 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 Nanoleaf Zeroconf discovery.""" """Handle Nanoleaf Zeroconf discovery."""
_LOGGER.debug("Zeroconf discovered: %s", discovery_info) _LOGGER.debug("Zeroconf discovered: %s", discovery_info)
return await self._async_homekit_zeroconf_discovery_handler(discovery_info) return await self._async_homekit_zeroconf_discovery_handler(discovery_info)
async def async_step_homekit( async def async_step_homekit(
self, discovery_info: zeroconf.ZeroconfServiceInfo self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle Nanoleaf Homekit discovery.""" """Handle Nanoleaf Homekit discovery."""
_LOGGER.debug("Homekit discovered: %s", discovery_info) _LOGGER.debug("Homekit discovered: %s", discovery_info)
return await self._async_homekit_zeroconf_discovery_handler(discovery_info) return await self._async_homekit_zeroconf_discovery_handler(discovery_info)
async def _async_homekit_zeroconf_discovery_handler( async def _async_homekit_zeroconf_discovery_handler(
self, discovery_info: zeroconf.ZeroconfServiceInfo self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle Nanoleaf Homekit and Zeroconf discovery.""" """Handle Nanoleaf Homekit and Zeroconf discovery."""
return await self._async_discovery_handler( return await self._async_discovery_handler(
discovery_info.host, discovery_info.host,
@ -113,7 +114,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
discovery_info.properties[zeroconf.ATTR_PROPERTIES_ID], discovery_info.properties[zeroconf.ATTR_PROPERTIES_ID],
) )
async def async_step_ssdp(self, discovery_info: ssdp.SsdpServiceInfo) -> FlowResult: async def async_step_ssdp(
self, discovery_info: ssdp.SsdpServiceInfo
) -> ConfigFlowResult:
"""Handle Nanoleaf SSDP discovery.""" """Handle Nanoleaf SSDP discovery."""
_LOGGER.debug("SSDP discovered: %s", discovery_info) _LOGGER.debug("SSDP discovered: %s", discovery_info)
return await self._async_discovery_handler( return await self._async_discovery_handler(
@ -124,7 +127,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def _async_discovery_handler( async def _async_discovery_handler(
self, host: str, name: str, device_id: str self, host: str, name: str, device_id: str
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle Nanoleaf discovery.""" """Handle Nanoleaf discovery."""
# The name is unique and printed on the device and cannot be changed. # The name is unique and printed on the device and cannot be changed.
await self.async_set_unique_id(name) await self.async_set_unique_id(name)
@ -156,7 +159,7 @@ class ConfigFlow(config_entries.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:
"""Handle Nanoleaf link step.""" """Handle Nanoleaf link step."""
if user_input is None: if user_input is None:
return self.async_show_form(step_id="link") return self.async_show_form(step_id="link")
@ -188,7 +191,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_setup_finish( async def async_setup_finish(
self, discovery_integration_import: bool = False self, discovery_integration_import: bool = False
) -> FlowResult: ) -> ConfigFlowResult:
"""Finish Nanoleaf config flow.""" """Finish Nanoleaf config flow."""
try: try:
await self.nanoleaf.get_info() await self.nanoleaf.get_info()

View file

@ -5,8 +5,7 @@ from collections.abc import Mapping
import logging import logging
from typing import Any from typing import Any
from homeassistant.config_entries import SOURCE_REAUTH from homeassistant.config_entries import SOURCE_REAUTH, ConfigFlowResult
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import config_entry_oauth2_flow from homeassistant.helpers import config_entry_oauth2_flow
from .const import NEATO_DOMAIN from .const import NEATO_DOMAIN
@ -26,7 +25,7 @@ class OAuth2FlowHandler(
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:
"""Create an entry for the flow.""" """Create an entry for the flow."""
current_entries = self._async_current_entries() current_entries = self._async_current_entries()
if self.source != SOURCE_REAUTH and current_entries: if self.source != SOURCE_REAUTH and current_entries:
@ -35,19 +34,21 @@ class OAuth2FlowHandler(
return await super().async_step_user(user_input=user_input) return await super().async_step_user(user_input=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 migration of old entries.""" """Perform reauth upon migration of old entries."""
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 upon migration of old entries.""" """Confirm reauth upon migration of old entries."""
if user_input is None: if user_input is None:
return self.async_show_form(step_id="reauth_confirm") return self.async_show_form(step_id="reauth_confirm")
return await self.async_step_user() return await self.async_step_user()
async def async_oauth_create_entry(self, data: dict[str, Any]) -> FlowResult: async def async_oauth_create_entry(self, data: dict[str, Any]) -> ConfigFlowResult:
"""Create an entry for the flow. Update an entry if one already exist.""" """Create an entry for the flow. Update an entry if one already exist."""
current_entries = self._async_current_entries() current_entries = self._async_current_entries()
if self.source == SOURCE_REAUTH and current_entries: if self.source == SOURCE_REAUTH and current_entries:

View file

@ -22,8 +22,7 @@ from google_nest_sdm.exceptions import (
from google_nest_sdm.structure import InfoTrait, Structure from google_nest_sdm.structure import InfoTrait, Structure
import voluptuous as vol import voluptuous as vol
from homeassistant.config_entries import SOURCE_REAUTH, ConfigEntry from homeassistant.config_entries import SOURCE_REAUTH, ConfigEntry, ConfigFlowResult
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import config_entry_oauth2_flow from homeassistant.helpers import config_entry_oauth2_flow
from homeassistant.util import get_random_string from homeassistant.util import get_random_string
@ -133,7 +132,7 @@ class NestFlowHandler(
authorize_url = OAUTH2_AUTHORIZE.format(project_id=project_id) authorize_url = OAUTH2_AUTHORIZE.format(project_id=project_id)
return f"{authorize_url}{query}" return f"{authorize_url}{query}"
async def async_oauth_create_entry(self, data: dict[str, Any]) -> FlowResult: async def async_oauth_create_entry(self, data: dict[str, Any]) -> ConfigFlowResult:
"""Complete OAuth setup and finish pubsub or finish.""" """Complete OAuth setup and finish pubsub or finish."""
_LOGGER.debug("Finishing post-oauth configuration") _LOGGER.debug("Finishing post-oauth configuration")
self._data.update(data) self._data.update(data)
@ -142,7 +141,9 @@ class NestFlowHandler(
return await self.async_step_finish() return await self.async_step_finish()
return await self.async_step_pubsub() return await self.async_step_pubsub()
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._data.update(entry_data) self._data.update(entry_data)
@ -150,7 +151,7 @@ class NestFlowHandler(
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."""
if user_input is None: if user_input is None:
return self.async_show_form(step_id="reauth_confirm") return self.async_show_form(step_id="reauth_confirm")
@ -158,7 +159,7 @@ class NestFlowHandler(
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."""
self._data[DATA_SDM] = {} self._data[DATA_SDM] = {}
if self.source == SOURCE_REAUTH: if self.source == SOURCE_REAUTH:
@ -169,7 +170,7 @@ class NestFlowHandler(
async def async_step_create_cloud_project( async def async_step_create_cloud_project(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle initial step in app credentails flow.""" """Handle initial step in app credentails flow."""
implementations = await config_entry_oauth2_flow.async_get_implementations( implementations = await config_entry_oauth2_flow.async_get_implementations(
self.hass, self.DOMAIN self.hass, self.DOMAIN
@ -196,7 +197,7 @@ class NestFlowHandler(
async def async_step_cloud_project( async def async_step_cloud_project(
self, user_input: dict | None = None self, user_input: dict | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle cloud project in user input.""" """Handle cloud project in user input."""
if user_input is not None: if user_input is not None:
self._data.update(user_input) self._data.update(user_input)
@ -216,7 +217,7 @@ class NestFlowHandler(
async def async_step_device_project( async def async_step_device_project(
self, user_input: dict | None = None self, user_input: dict | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Collect device access project from user input.""" """Collect device access project from user input."""
errors = {} errors = {}
if user_input is not None: if user_input is not None:
@ -249,7 +250,7 @@ class NestFlowHandler(
async def async_step_pubsub( async def async_step_pubsub(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Configure and create Pub/Sub subscriber.""" """Configure and create Pub/Sub subscriber."""
data = { data = {
**self._data, **self._data,
@ -313,7 +314,9 @@ class NestFlowHandler(
errors=errors, errors=errors,
) )
async def async_step_finish(self, data: dict[str, Any] | None = None) -> FlowResult: async def async_step_finish(
self, data: dict[str, Any] | None = None
) -> ConfigFlowResult:
"""Create an entry for the SDM flow.""" """Create an entry for the SDM flow."""
_LOGGER.debug("Creating/updating configuration entry") _LOGGER.debug("Creating/updating configuration entry")
# Update existing config entry when in the reauth flow. # Update existing config entry when in the reauth flow.

View file

@ -8,10 +8,14 @@ import uuid
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries from homeassistant.config_entries import (
SOURCE_REAUTH,
ConfigEntry,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.const import CONF_SHOW_ON_MAP, CONF_UUID from homeassistant.const import CONF_SHOW_ON_MAP, CONF_UUID
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import config_entry_oauth2_flow, config_validation as cv from homeassistant.helpers import config_entry_oauth2_flow, config_validation as cv
from .api import get_api_scopes from .api import get_api_scopes
@ -40,8 +44,8 @@ class NetatmoFlowHandler(
@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:
"""Get the options flow for this handler.""" """Get the options flow for this handler."""
return NetatmoOptionsFlowHandler(config_entry) return NetatmoOptionsFlowHandler(config_entry)
@ -56,32 +60,31 @@ class NetatmoFlowHandler(
scopes = get_api_scopes(self.flow_impl.domain) scopes = get_api_scopes(self.flow_impl.domain)
return {"scope": " ".join(scopes)} return {"scope": " ".join(scopes)}
async def async_step_user(self, user_input: dict | None = None) -> FlowResult: async def async_step_user(self, user_input: dict | None = None) -> ConfigFlowResult:
"""Handle a flow start.""" """Handle a flow start."""
await self.async_set_unique_id(DOMAIN) await self.async_set_unique_id(DOMAIN)
if ( if self.source != SOURCE_REAUTH and self._async_current_entries():
self.source != config_entries.SOURCE_REAUTH
and self._async_current_entries()
):
return self.async_abort(reason="single_instance_allowed") return self.async_abort(reason="single_instance_allowed")
return await super().async_step_user(user_input) return await super().async_step_user(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."""
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 | None = None self, user_input: dict | 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(step_id="reauth_confirm") return self.async_show_form(step_id="reauth_confirm")
return await self.async_step_user() return await self.async_step_user()
async def async_oauth_create_entry(self, data: dict) -> FlowResult: async def async_oauth_create_entry(self, data: dict) -> ConfigFlowResult:
"""Create an oauth config entry or update existing entry for reauth.""" """Create an oauth config entry or update existing entry for reauth."""
existing_entry = await self.async_set_unique_id(DOMAIN) existing_entry = await self.async_set_unique_id(DOMAIN)
if existing_entry: if existing_entry:
@ -92,22 +95,22 @@ class NetatmoFlowHandler(
return await super().async_oauth_create_entry(data) return await super().async_oauth_create_entry(data)
class NetatmoOptionsFlowHandler(config_entries.OptionsFlow): class NetatmoOptionsFlowHandler(OptionsFlow):
"""Handle Netatmo options.""" """Handle Netatmo options."""
def __init__(self, config_entry: config_entries.ConfigEntry) -> None: def __init__(self, config_entry: ConfigEntry) -> None:
"""Initialize Netatmo options flow.""" """Initialize Netatmo options flow."""
self.config_entry = config_entry self.config_entry = config_entry
self.options = dict(config_entry.options) self.options = dict(config_entry.options)
self.options.setdefault(CONF_WEATHER_AREAS, {}) self.options.setdefault(CONF_WEATHER_AREAS, {})
async def async_step_init(self, user_input: dict | None = None) -> FlowResult: async def async_step_init(self, user_input: dict | None = None) -> ConfigFlowResult:
"""Manage the Netatmo options.""" """Manage the Netatmo options."""
return await self.async_step_public_weather_areas() return await self.async_step_public_weather_areas()
async def async_step_public_weather_areas( async def async_step_public_weather_areas(
self, user_input: dict | None = None self, user_input: dict | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Manage configuration of Netatmo public weather areas.""" """Manage configuration of Netatmo public weather areas."""
errors: dict = {} errors: dict = {}
@ -142,7 +145,7 @@ class NetatmoOptionsFlowHandler(config_entries.OptionsFlow):
errors=errors, errors=errors,
) )
async def async_step_public_weather(self, user_input: dict) -> FlowResult: async def async_step_public_weather(self, user_input: dict) -> ConfigFlowResult:
"""Manage configuration of Netatmo public weather sensors.""" """Manage configuration of Netatmo public weather sensors."""
if user_input is not None and CONF_NEW_AREA not in user_input: if user_input is not None and CONF_NEW_AREA not in user_input:
self.options[CONF_WEATHER_AREAS][ self.options[CONF_WEATHER_AREAS][
@ -203,7 +206,7 @@ class NetatmoOptionsFlowHandler(config_entries.OptionsFlow):
return self.async_show_form(step_id="public_weather", data_schema=data_schema) return self.async_show_form(step_id="public_weather", data_schema=data_schema)
def _create_options_entry(self) -> FlowResult: def _create_options_entry(self) -> ConfigFlowResult:
"""Update config entry options.""" """Update config entry options."""
return self.async_create_entry( return self.async_create_entry(
title="Netatmo Public Weather", data=self.options title="Netatmo Public Weather", data=self.options

View file

@ -8,8 +8,13 @@ from urllib.parse import urlparse
from pynetgear import DEFAULT_HOST, DEFAULT_PORT, DEFAULT_USER from pynetgear import DEFAULT_HOST, DEFAULT_PORT, DEFAULT_USER
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 ( from homeassistant.const import (
CONF_HOST, CONF_HOST,
CONF_PASSWORD, CONF_PASSWORD,
@ -18,7 +23,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.util.network import is_ipv4_address from homeassistant.util.network import is_ipv4_address
from .const import ( from .const import (
@ -55,10 +59,10 @@ def _ordered_shared_schema(schema_input):
} }
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
@ -81,7 +85,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 NetgearFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): class NetgearFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a config flow.""" """Handle a config flow."""
VERSION = 1 VERSION = 1
@ -99,7 +103,7 @@ class NetgearFlowHandler(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)
@ -121,7 +125,9 @@ class NetgearFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
description_placeholders=self.placeholders, description_placeholders=self.placeholders,
) )
async def async_step_ssdp(self, discovery_info: ssdp.SsdpServiceInfo) -> FlowResult: async def async_step_ssdp(
self, discovery_info: ssdp.SsdpServiceInfo
) -> ConfigFlowResult:
"""Initialize flow from ssdp.""" """Initialize flow from ssdp."""
updated_data: dict[str, str | int | bool] = {} updated_data: dict[str, str | int | bool] = {}

View file

@ -8,18 +8,18 @@ from eternalegypt import Error, Modem
from eternalegypt.eternalegypt import Information from eternalegypt.eternalegypt import Information
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries, exceptions from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_HOST, CONF_PASSWORD from homeassistant.const import CONF_HOST, CONF_PASSWORD
from homeassistant.data_entry_flow import FlowResult from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.aiohttp_client import async_create_clientsession from homeassistant.helpers.aiohttp_client import async_create_clientsession
from .const import DEFAULT_HOST, DOMAIN, LOGGER, MANUFACTURER from .const import DEFAULT_HOST, DOMAIN, LOGGER, MANUFACTURER
class NetgearLTEFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): class NetgearLTEFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Netgear LTE.""" """Handle a config flow for Netgear LTE."""
async def async_step_import(self, config: dict[str, Any]) -> FlowResult: async def async_step_import(self, config: dict[str, Any]) -> ConfigFlowResult:
"""Import a configuration from config.yaml.""" """Import a configuration from config.yaml."""
host = config[CONF_HOST] host = config[CONF_HOST]
password = config[CONF_PASSWORD] password = config[CONF_PASSWORD]
@ -37,7 +37,7 @@ class NetgearLTEFlowHandler(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 = {}
@ -94,7 +94,7 @@ class NetgearLTEFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
return info return info
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

@ -6,8 +6,10 @@ from nexia.const import BRAND_ASAIR, BRAND_NEXIA, BRAND_TRANE
from nexia.home import NexiaHome from nexia.home import NexiaHome
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries, core, exceptions from homeassistant.config_entries import ConfigFlow
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import HomeAssistant
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 ( from .const import (
@ -36,7 +38,7 @@ DATA_SCHEMA = vol.Schema(
) )
async def validate_input(hass: core.HomeAssistant, data): async def validate_input(hass: HomeAssistant, data):
"""Validate the user input allows us to connect. """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.
@ -73,7 +75,7 @@ async def validate_input(hass: core.HomeAssistant, data):
return info return info
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class NexiaConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Nexia.""" """Handle a config flow for Nexia."""
VERSION = 1 VERSION = 1
@ -102,9 +104,9 @@ class ConfigFlow(config_entries.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

@ -5,9 +5,8 @@ import logging
from py_nextbus import NextBusClient from py_nextbus import NextBusClient
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_NAME, CONF_STOP from homeassistant.const import CONF_NAME, CONF_STOP
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.selector import ( from homeassistant.helpers.selector import (
SelectOptionDict, SelectOptionDict,
SelectSelector, SelectSelector,
@ -89,7 +88,7 @@ def _unique_id_from_data(data: dict[str, str]) -> str:
return f"{data[CONF_AGENCY]}_{data[CONF_ROUTE]}_{data[CONF_STOP]}" return f"{data[CONF_AGENCY]}_{data[CONF_ROUTE]}_{data[CONF_STOP]}"
class NextBusFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): class NextBusFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle Nextbus configuration.""" """Handle Nextbus configuration."""
VERSION = 1 VERSION = 1
@ -104,7 +103,7 @@ class NextBusFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
self._client = NextBusClient(output_format="json") self._client = NextBusClient(output_format="json")
_LOGGER.info("Init new config flow") _LOGGER.info("Init new config flow")
async def async_step_import(self, config_input: dict[str, str]) -> FlowResult: async def async_step_import(self, config_input: dict[str, str]) -> ConfigFlowResult:
"""Handle import of config.""" """Handle import of config."""
agency_tag = config_input[CONF_AGENCY] agency_tag = config_input[CONF_AGENCY]
route_tag = config_input[CONF_ROUTE] route_tag = config_input[CONF_ROUTE]
@ -141,14 +140,14 @@ class NextBusFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, self,
user_input: dict[str, str] | None = None, user_input: dict[str, str] | None = None,
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle a flow initiated by the user.""" """Handle a flow initiated by the user."""
return await self.async_step_agency(user_input) return await self.async_step_agency(user_input)
async def async_step_agency( async def async_step_agency(
self, self,
user_input: dict[str, str] | None = None, user_input: dict[str, str] | None = None,
) -> FlowResult: ) -> ConfigFlowResult:
"""Select agency.""" """Select agency."""
if user_input is not None: if user_input is not None:
self.data[CONF_AGENCY] = user_input[CONF_AGENCY] self.data[CONF_AGENCY] = user_input[CONF_AGENCY]
@ -173,7 +172,7 @@ class NextBusFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_route( async def async_step_route(
self, self,
user_input: dict[str, str] | None = None, user_input: dict[str, str] | None = None,
) -> FlowResult: ) -> ConfigFlowResult:
"""Select route.""" """Select route."""
if user_input is not None: if user_input is not None:
self.data[CONF_ROUTE] = user_input[CONF_ROUTE] self.data[CONF_ROUTE] = user_input[CONF_ROUTE]
@ -198,7 +197,7 @@ class NextBusFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_stop( async def async_step_stop(
self, self,
user_input: dict[str, str] | None = None, user_input: dict[str, str] | None = None,
) -> FlowResult: ) -> ConfigFlowResult:
"""Select stop.""" """Select stop."""
if user_input is not None: if user_input is not None:

View file

@ -12,9 +12,8 @@ from nextcloudmonitor import (
) )
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_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 .const import DEFAULT_VERIFY_SSL, DOMAIN from .const import DEFAULT_VERIFY_SSL, DOMAIN
@ -52,7 +51,7 @@ class NextcloudConfigFlow(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 = {}
@ -75,14 +74,16 @@ class NextcloudConfigFlow(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 flow upon an API authentication error.""" """Handle flow upon an API authentication error."""
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 reauthorization flow.""" """Handle reauthorization flow."""
errors = {} errors = {}
assert self._entry is not None assert self._entry is not None

View file

@ -8,15 +8,14 @@ from aiohttp.client_exceptions import ClientConnectorError
from nextdns import ApiError, InvalidApiKeyError, NextDns from nextdns import ApiError, InvalidApiKeyError, NextDns
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_PROFILE_NAME from homeassistant.const import CONF_API_KEY, CONF_PROFILE_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 CONF_PROFILE_ID, DOMAIN from .const import CONF_PROFILE_ID, DOMAIN
class NextDnsFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): class NextDnsFlowHandler(ConfigFlow, domain=DOMAIN):
"""Config flow for NextDNS.""" """Config flow for NextDNS."""
VERSION = 1 VERSION = 1
@ -28,7 +27,7 @@ class NextDnsFlowHandler(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: dict[str, str] = {} errors: dict[str, str] = {}
@ -58,7 +57,7 @@ class NextDnsFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_profiles( async def async_step_profiles(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle the profiles step.""" """Handle the profiles step."""
errors: dict[str, str] = {} errors: dict[str, str] = {}

View file

@ -7,21 +7,20 @@ from typing import Any
from notifications_android_tv.notifications import ConnectError, Notifications from notifications_android_tv.notifications import ConnectError, Notifications
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_NAME from homeassistant.const import CONF_HOST, CONF_NAME
from homeassistant.data_entry_flow import FlowResult
from .const import DEFAULT_NAME, DOMAIN from .const import DEFAULT_NAME, DOMAIN
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
class NFAndroidTVFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): class NFAndroidTVFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for NFAndroidTV.""" """Handle a config flow for NFAndroidTV."""
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 = {}

View file

@ -17,10 +17,9 @@ from nibe.heatpump import HeatPump, Model
import voluptuous as vol import voluptuous as vol
import yarl import yarl
from homeassistant import config_entries from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_IP_ADDRESS, CONF_MODEL from homeassistant.const import CONF_IP_ADDRESS, CONF_MODEL
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import selector from homeassistant.helpers import selector
from .const import ( from .const import (
@ -166,20 +165,20 @@ async def validate_modbus_input(
} }
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class NibeHeatPumpConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Nibe Heat Pump.""" """Handle a config flow for Nibe Heat Pump."""
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."""
return self.async_show_menu(step_id="user", menu_options=["modbus", "nibegw"]) return self.async_show_menu(step_id="user", menu_options=["modbus", "nibegw"])
async def async_step_modbus( async def async_step_modbus(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle the modbus step.""" """Handle the modbus step."""
if user_input is None: if user_input is None:
return self.async_show_form( return self.async_show_form(
@ -205,7 +204,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_nibegw( async def async_step_nibegw(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle the nibegw step.""" """Handle the nibegw step."""
if user_input is None: if user_input is None:
return self.async_show_form( return self.async_show_form(

View file

@ -6,9 +6,9 @@ from aiohttp import ClientError, ClientResponseError
from py_nightscout import Api as NightscoutAPI from py_nightscout import Api as NightscoutAPI
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries, exceptions from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_API_KEY, CONF_URL from homeassistant.const import CONF_API_KEY, CONF_URL
from homeassistant.data_entry_flow import FlowResult from homeassistant.exceptions import HomeAssistantError
from .const import DOMAIN from .const import DOMAIN
from .utils import hash_from_url from .utils import hash_from_url
@ -36,14 +36,14 @@ async def _validate_input(data: dict[str, Any]) -> dict[str, str]:
return {"title": status.name} return {"title": status.name}
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class NightscoutConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Nightscout.""" """Handle a config flow for Nightscout."""
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] = {}
@ -66,7 +66,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

@ -6,9 +6,13 @@ from typing import Any
from pynina import ApiError, Nina from pynina import ApiError, Nina
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
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.entity_registry import ( from homeassistant.helpers.entity_registry import (
@ -81,7 +85,7 @@ def prepare_user_input(
return user_input return user_input
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class NinaConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for NINA.""" """Handle a config flow for NINA."""
VERSION: int = 1 VERSION: int = 1
@ -96,9 +100,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
self.regions[name] = {} self.regions[name] = {}
async def async_step_user( async def async_step_user(
self: ConfigFlow, self,
user_input: dict[str, Any] | None = None, user_input: dict[str, Any] | None = None,
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle the initial step.""" """Handle the initial step."""
errors: dict[str, Any] = {} errors: dict[str, Any] = {}
@ -158,16 +162,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 nut.""" """Handle a option flow for nut."""
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.data = dict(self.config_entry.data) self.data = dict(self.config_entry.data)

View file

@ -6,7 +6,6 @@ from typing import Any
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import network from homeassistant.components import network
from homeassistant.components.device_tracker import ( from homeassistant.components.device_tracker import (
CONF_CONSIDER_HOME, CONF_CONSIDER_HOME,
@ -14,10 +13,14 @@ from homeassistant.components.device_tracker import (
DEFAULT_CONSIDER_HOME, DEFAULT_CONSIDER_HOME,
) )
from homeassistant.components.network import MDNS_TARGET_IP from homeassistant.components.network import MDNS_TARGET_IP
from homeassistant.config_entries import ConfigEntry, OptionsFlow from homeassistant.config_entries import (
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.const import CONF_EXCLUDE, CONF_HOSTS from homeassistant.const import CONF_EXCLUDE, CONF_HOSTS
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, 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 (
@ -133,16 +136,16 @@ async def _async_build_schema_with_user_input(
return vol.Schema(schema) return vol.Schema(schema)
class OptionsFlowHandler(config_entries.OptionsFlow): class OptionsFlowHandler(OptionsFlow):
"""Handle a option flow for homekit.""" """Handle a option flow for homekit."""
def __init__(self, config_entry: config_entries.ConfigEntry) -> None: def __init__(self, config_entry: ConfigEntry) -> None:
"""Initialize options flow.""" """Initialize options flow."""
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:
"""Handle options flow.""" """Handle options flow."""
errors = {} errors = {}
if user_input is not None: if user_input is not None:
@ -163,7 +166,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
) )
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class NmapTrackerConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Nmap Tracker.""" """Handle a config flow for Nmap Tracker."""
VERSION = 1 VERSION = 1
@ -174,7 +177,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

@ -7,10 +7,14 @@ from typing import Any
from pynobo import nobo from pynobo import nobo
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_IP_ADDRESS from homeassistant.const import CONF_IP_ADDRESS
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.exceptions import HomeAssistantError from homeassistant.exceptions import HomeAssistantError
from .const import ( from .const import (
@ -26,7 +30,7 @@ DATA_NOBO_HUB_IMPL = "nobo_hub_flow_implementation"
DEVICE_INPUT = "device_input" DEVICE_INPUT = "device_input"
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class NoboHubConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Nobø Ecohub.""" """Handle a config flow for Nobø Ecohub."""
VERSION = 1 VERSION = 1
@ -38,7 +42,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 self._discovered_hubs is None: if self._discovered_hubs is None:
self._discovered_hubs = dict(await nobo.async_discover_hubs()) self._discovered_hubs = dict(await nobo.async_discover_hubs())
@ -67,7 +71,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_selected( async def async_step_selected(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle configuration of a selected discovered device.""" """Handle configuration of a selected discovered device."""
errors = {} errors = {}
if user_input is not None: if user_input is not None:
@ -97,7 +101,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_manual( async def async_step_manual(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle configuration of an undiscovered device.""" """Handle configuration of an undiscovered device."""
errors = {} errors = {}
if user_input is not None: if user_input is not None:
@ -124,7 +128,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def _create_configuration( async def _create_configuration(
self, serial: str, ip_address: str, auto_discovered: bool self, serial: str, ip_address: str, auto_discovered: bool
) -> FlowResult: ) -> ConfigFlowResult:
await self.async_set_unique_id(serial) await self.async_set_unique_id(serial)
self._abort_if_unique_id_configured() self._abort_if_unique_id_configured()
name = await self._test_connection(serial, ip_address) name = await self._test_connection(serial, ip_address)
@ -164,8 +168,8 @@ 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,
) -> config_entries.OptionsFlow: ) -> OptionsFlow:
"""Get the options flow for this handler.""" """Get the options flow for this handler."""
return OptionsFlowHandler(config_entry) return OptionsFlowHandler(config_entry)
@ -179,14 +183,14 @@ class NoboHubConnectError(HomeAssistantError):
self.msg = msg self.msg = msg
class OptionsFlowHandler(config_entries.OptionsFlow): class OptionsFlowHandler(OptionsFlow):
"""Handles options flow for the component.""" """Handles options flow for the component."""
def __init__(self, config_entry: config_entries.ConfigEntry) -> None: def __init__(self, config_entry: ConfigEntry) -> None:
"""Initialize the options flow.""" """Initialize the options flow."""
self.config_entry = config_entry self.config_entry = config_entry
async def async_step_init(self, user_input=None) -> FlowResult: async def async_step_init(self, user_input=None) -> ConfigFlowResult:
"""Manage the options.""" """Manage the options."""
if user_input is not None: if user_input is not None:

View file

@ -8,11 +8,9 @@ from typing import Any
from aionotion.errors import InvalidCredentialsError, NotionError from aionotion.errors import InvalidCredentialsError, NotionError
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_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 .const import CONF_REFRESH_TOKEN, CONF_USER_UUID, DOMAIN, LOGGER from .const import CONF_REFRESH_TOKEN, CONF_USER_UUID, DOMAIN, LOGGER
from .util import async_get_client_with_credentials from .util import async_get_client_with_credentials
@ -64,7 +62,7 @@ async def async_validate_credentials(
) )
class NotionFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): class NotionFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a Notion config flow.""" """Handle a Notion config flow."""
VERSION = 1 VERSION = 1
@ -73,7 +71,9 @@ class NotionFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
"""Initialize.""" """Initialize."""
self._reauth_entry: ConfigEntry | None = None self._reauth_entry: ConfigEntry | None = None
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: async def async_step_reauth(
self, entry_data: Mapping[str, Any]
) -> ConfigFlowResult:
"""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"]
@ -82,7 +82,7 @@ class NotionFlowHandler(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 re-auth completion.""" """Handle re-auth completion."""
assert self._reauth_entry assert self._reauth_entry
@ -121,7 +121,7 @@ class NotionFlowHandler(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(step_id="user", data_schema=AUTH_SCHEMA) return self.async_show_form(step_id="user", data_schema=AUTH_SCHEMA)

View file

@ -6,8 +6,10 @@ import nuheat
import requests.exceptions import requests.exceptions
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries, core, exceptions from homeassistant.config_entries import ConfigFlow
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
from .const import CONF_SERIAL_NUMBER, DOMAIN from .const import CONF_SERIAL_NUMBER, DOMAIN
@ -22,7 +24,7 @@ DATA_SCHEMA = vol.Schema(
) )
async def validate_input(hass: core.HomeAssistant, data): async def validate_input(hass: HomeAssistant, data):
"""Validate the user input allows us to connect. """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,7 +58,7 @@ async def validate_input(hass: core.HomeAssistant, data):
return {"title": thermostat.room, "serial_number": thermostat.serial_number} return {"title": thermostat.room, "serial_number": thermostat.serial_number}
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class NuHeatConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for NuHeat.""" """Handle a config flow for NuHeat."""
VERSION = 1 VERSION = 1
@ -87,13 +89,13 @@ class ConfigFlow(config_entries.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."""
class InvalidThermostat(exceptions.HomeAssistantError): class InvalidThermostat(HomeAssistantError):
"""Error to indicate there is invalid thermostat.""" """Error to indicate there is invalid thermostat."""

View file

@ -8,10 +8,9 @@ from pynuki.bridge import InvalidCredentialsException
from requests.exceptions import RequestException from requests.exceptions import RequestException
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_PORT, CONF_TOKEN from homeassistant.const import CONF_HOST, CONF_PORT, CONF_TOKEN
from homeassistant.data_entry_flow import FlowResult
from .const import CONF_ENCRYPT_TOKEN, DEFAULT_PORT, DEFAULT_TIMEOUT, DOMAIN from .const import CONF_ENCRYPT_TOKEN, DEFAULT_PORT, DEFAULT_TIMEOUT, DOMAIN
from .helpers import CannotConnect, InvalidAuth, parse_id from .helpers import CannotConnect, InvalidAuth, parse_id
@ -59,7 +58,7 @@ async def validate_input(hass, data):
return info return info
class NukiConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class NukiConfigFlow(ConfigFlow, domain=DOMAIN):
"""Nuki config flow.""" """Nuki config flow."""
def __init__(self): def __init__(self):
@ -71,7 +70,9 @@ class NukiConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
"""Handle a flow initiated by the user.""" """Handle a flow initiated by the user."""
return await self.async_step_validate(user_input) return await self.async_step_validate(user_input)
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 Nuki bridge.""" """Prepare configuration for a DHCP discovered Nuki bridge."""
await self.async_set_unique_id(discovery_info.hostname[12:].upper()) await self.async_set_unique_id(discovery_info.hostname[12:].upper())
@ -87,7 +88,9 @@ class NukiConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
return await self.async_step_validate() return await self.async_step_validate()
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._data = entry_data self._data = entry_data

View file

@ -7,9 +7,13 @@ from typing import Any
import voluptuous as vol import voluptuous as vol
from homeassistant import exceptions
from homeassistant.components import zeroconf from homeassistant.components import zeroconf
from homeassistant.config_entries import ConfigEntry, ConfigFlow, OptionsFlow from homeassistant.config_entries import (
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.const import ( from homeassistant.const import (
CONF_ALIAS, CONF_ALIAS,
CONF_BASE, CONF_BASE,
@ -20,7 +24,7 @@ from homeassistant.const import (
CONF_USERNAME, 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 . import PyNUTData from . import PyNUTData
from .const import DEFAULT_HOST, DEFAULT_PORT, DEFAULT_SCAN_INTERVAL, DOMAIN from .const import DEFAULT_HOST, DEFAULT_PORT, DEFAULT_SCAN_INTERVAL, DOMAIN
@ -94,7 +98,7 @@ class NutConfigFlow(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 nut device.""" """Prepare configuration for a discovered nut device."""
self.discovery_info = discovery_info self.discovery_info = discovery_info
await self._async_handle_discovery_without_unique_id() await self._async_handle_discovery_without_unique_id()
@ -106,7 +110,7 @@ class NutConfigFlow(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 input.""" """Handle the user input."""
errors: dict[str, str] = {} errors: dict[str, str] = {}
if user_input is not None: if user_input is not None:
@ -136,7 +140,7 @@ class NutConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_ups( async def async_step_ups(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle the picking the ups.""" """Handle the picking the ups."""
errors: dict[str, str] = {} errors: dict[str, str] = {}
@ -194,7 +198,7 @@ class OptionsFlowHandler(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:
"""Handle options flow.""" """Handle options flow."""
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)
@ -212,5 +216,5 @@ class OptionsFlowHandler(OptionsFlow):
return self.async_show_form(step_id="init", data_schema=vol.Schema(base_schema)) return self.async_show_form(step_id="init", data_schema=vol.Schema(base_schema))
class CannotConnect(exceptions.HomeAssistantError): class CannotConnect(HomeAssistantError):
"""Error to indicate we cannot connect.""" """Error to indicate we cannot connect."""

View file

@ -8,9 +8,10 @@ import aiohttp
from pynws import SimpleNWS from pynws import SimpleNWS
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries, core, exceptions from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE
from homeassistant.data_entry_flow import FlowResult from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import config_validation as cv from 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
@ -20,9 +21,7 @@ from .const import CONF_STATION, DOMAIN
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
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.
@ -45,14 +44,14 @@ async def validate_input(
return {"title": nws.station} return {"title": nws.station}
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class NWSConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for National Weather Service (NWS).""" """Handle a config flow for National Weather Service (NWS)."""
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:
@ -88,5 +87,5 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
) )
class CannotConnect(exceptions.HomeAssistantError): class CannotConnect(HomeAssistantError):
"""Error to indicate we cannot connect.""" """Error to indicate we cannot connect."""

View file

@ -6,7 +6,7 @@ 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 ( from homeassistant.const import (
CONF_HOST, CONF_HOST,
CONF_NAME, CONF_NAME,
@ -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 .const import DEFAULT_NAME, DEFAULT_PORT, DEFAULT_SSL, DEFAULT_VERIFY_SSL, DOMAIN from .const import DEFAULT_NAME, DEFAULT_PORT, DEFAULT_SSL, DEFAULT_VERIFY_SSL, DOMAIN
from .coordinator import NZBGetAPI, NZBGetAPIException from .coordinator import NZBGetAPI, NZBGetAPIException
@ -48,7 +47,7 @@ class NZBGetConfigFlow(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")

View file

@ -9,10 +9,9 @@ from pyobihai import PyObihai
import voluptuous as vol import voluptuous as vol
from homeassistant.components import dhcp from homeassistant.components import dhcp
from homeassistant.config_entries import ConfigFlow from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.device_registry import format_mac from homeassistant.helpers.device_registry import format_mac
from .connectivity import validate_auth from .connectivity import validate_auth
@ -59,7 +58,7 @@ class ObihaiFlowHandler(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: dict[str, str] = {} errors: dict[str, str] = {}
@ -94,7 +93,9 @@ class ObihaiFlowHandler(ConfigFlow, domain=DOMAIN):
data_schema=self.add_suggested_values_to_schema(data_schema, user_input), data_schema=self.add_suggested_values_to_schema(data_schema, user_input),
) )
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 Obihai.""" """Prepare configuration for a DHCP discovered Obihai."""
self._dhcp_discovery_info = discovery_info self._dhcp_discovery_info = discovery_info
@ -102,7 +103,7 @@ class ObihaiFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_dhcp_confirm( async def async_step_dhcp_confirm(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Attempt to confirm.""" """Attempt to confirm."""
assert self._dhcp_discovery_info assert self._dhcp_discovery_info
await self.async_set_unique_id(format_mac(self._dhcp_discovery_info.macaddress)) await self.async_set_unique_id(format_mac(self._dhcp_discovery_info.macaddress))

View file

@ -11,8 +11,8 @@ from pyoctoprintapi import ApiError, OctoprintClient, OctoprintException
import voluptuous as vol import voluptuous as vol
from yarl import URL from yarl import URL
from homeassistant import config_entries, data_entry_flow, exceptions
from homeassistant.components import ssdp, zeroconf from homeassistant.components import ssdp, zeroconf
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import ( from homeassistant.const import (
CONF_API_KEY, CONF_API_KEY,
CONF_HOST, CONF_HOST,
@ -22,7 +22,8 @@ from homeassistant.const import (
CONF_USERNAME, CONF_USERNAME,
CONF_VERIFY_SSL, CONF_VERIFY_SSL,
) )
from homeassistant.data_entry_flow import FlowResult from homeassistant.data_entry_flow import AbortFlow
from homeassistant.exceptions import HomeAssistantError
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.util.ssl import get_default_context, get_default_no_verify_context from homeassistant.util.ssl import get_default_context, get_default_no_verify_context
@ -47,7 +48,7 @@ def _schema_with_defaults(
) )
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class OctoPrintConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for OctoPrint.""" """Handle a config flow for OctoPrint."""
VERSION = 1 VERSION = 1
@ -76,7 +77,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
errors = {} errors = {}
try: try:
return await self._finish_config(user_input) return await self._finish_config(user_input)
except data_entry_flow.AbortFlow as err: except AbortFlow as err:
raise err from None raise err from None
except CannotConnect: except CannotConnect:
errors["base"] = "cannot_connect" errors["base"] = "cannot_connect"
@ -160,7 +161,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
) -> data_entry_flow.FlowResult: ) -> ConfigFlowResult:
"""Handle discovery flow.""" """Handle discovery flow."""
uuid = discovery_info.properties["uuid"] uuid = discovery_info.properties["uuid"]
await self.async_set_unique_id(uuid) await self.async_set_unique_id(uuid)
@ -186,7 +187,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_ssdp( async def async_step_ssdp(
self, discovery_info: ssdp.SsdpServiceInfo self, discovery_info: ssdp.SsdpServiceInfo
) -> data_entry_flow.FlowResult: ) -> ConfigFlowResult:
"""Handle ssdp discovery flow.""" """Handle ssdp discovery flow."""
uuid = discovery_info.upnp["UDN"][5:] uuid = discovery_info.upnp["UDN"][5:]
await self.async_set_unique_id(uuid) await self.async_set_unique_id(uuid)
@ -209,7 +210,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
return await self.async_step_user() return await self.async_step_user()
async def async_step_reauth(self, config: Mapping[str, Any]) -> FlowResult: async def async_step_reauth(self, config: Mapping[str, Any]) -> ConfigFlowResult:
"""Handle reauthorization request from Octoprint.""" """Handle reauthorization request from Octoprint."""
self._reauth_data = dict(config) self._reauth_data = dict(config)
@ -223,7 +224,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 reauthorization flow.""" """Handle reauthorization flow."""
assert self._reauth_data is not None assert self._reauth_data is not None
@ -279,5 +280,5 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
session.detach() session.detach()
class CannotConnect(exceptions.HomeAssistantError): class CannotConnect(HomeAssistantError):
"""Error to indicate we cannot connect.""" """Error to indicate we cannot connect."""

View file

@ -6,7 +6,7 @@ import logging
from omnilogic import LoginException, OmniLogic, OmniLogicException from omnilogic import LoginException, OmniLogic, OmniLogicException
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_USERNAME from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.helpers import aiohttp_client from homeassistant.helpers import aiohttp_client
@ -16,7 +16,7 @@ from .const import CONF_SCAN_INTERVAL, DEFAULT_PH_OFFSET, DEFAULT_SCAN_INTERVAL,
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class OmniLogicConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Omnilogic.""" """Handle a config flow for Omnilogic."""
VERSION = 1 VERSION = 1
@ -24,7 +24,7 @@ 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)
@ -72,10 +72,10 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
) )
class OptionsFlowHandler(config_entries.OptionsFlow): class OptionsFlowHandler(OptionsFlow):
"""Handle Omnilogic client options.""" """Handle Omnilogic client 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

View file

@ -7,9 +7,8 @@ from typing import Any
from aiooncue import LoginFailedException, Oncue from aiooncue import LoginFailedException, Oncue
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 CONNECTION_EXCEPTIONS, DOMAIN from .const import CONNECTION_EXCEPTIONS, DOMAIN
@ -17,14 +16,14 @@ from .const import CONNECTION_EXCEPTIONS, DOMAIN
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class OncueConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Oncue.""" """Handle a config flow for Oncue."""
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 = {} errors = {}

View file

@ -8,11 +8,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_HOST, CONF_PORT from homeassistant.const import 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 config_validation as cv, device_registry as dr from homeassistant.helpers import config_validation as cv, device_registry as dr
from homeassistant.helpers.device_registry import DeviceEntry from homeassistant.helpers.device_registry import DeviceEntry
@ -65,7 +65,7 @@ class OneWireFlowHandler(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 1-Wire config flow start. """Handle 1-Wire config flow start.
Let user manually input configuration. Let user manually input configuration.
@ -124,7 +124,7 @@ class OnewireOptionsFlowHandler(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."""
device_registry = dr.async_get(self.hass) device_registry = dr.async_get(self.hass)
self.configurable_devices = { self.configurable_devices = {
@ -142,7 +142,7 @@ class OnewireOptionsFlowHandler(OptionsFlowWithConfigEntry):
async def async_step_device_selection( async def async_step_device_selection(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Select what devices to configure.""" """Select what devices to configure."""
errors = {} errors = {}
if user_input is not None: if user_input is not None:
@ -187,7 +187,7 @@ class OnewireOptionsFlowHandler(OptionsFlowWithConfigEntry):
async def async_step_configure_device( async def async_step_configure_device(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Config precision option for device.""" """Config precision option for device."""
if user_input is not None: if user_input is not None:
self._update_device_options(user_input) self._update_device_options(user_input)

View file

@ -14,7 +14,6 @@ from wsdiscovery.scope import Scope
from wsdiscovery.service import Service from wsdiscovery.service import Service
from zeep.exceptions import Fault from zeep.exceptions import Fault
from homeassistant import config_entries
from homeassistant.components import dhcp from homeassistant.components import dhcp
from homeassistant.components.ffmpeg import CONF_EXTRA_ARGUMENTS from homeassistant.components.ffmpeg import CONF_EXTRA_ARGUMENTS
from homeassistant.components.stream import ( from homeassistant.components.stream import (
@ -22,6 +21,13 @@ from homeassistant.components.stream import (
CONF_USE_WALLCLOCK_AS_TIMESTAMPS, CONF_USE_WALLCLOCK_AS_TIMESTAMPS,
RTSP_TRANSPORTS, RTSP_TRANSPORTS,
) )
from homeassistant.config_entries import (
ConfigEntry,
ConfigEntryState,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.const import ( from homeassistant.const import (
CONF_HOST, CONF_HOST,
CONF_NAME, CONF_NAME,
@ -30,7 +36,7 @@ from homeassistant.const import (
CONF_USERNAME, CONF_USERNAME,
) )
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.helpers import device_registry as dr from homeassistant.helpers import device_registry as dr
from .const import ( from .const import (
@ -91,16 +97,16 @@ async def async_discovery(hass: HomeAssistant) -> list[dict[str, Any]]:
return devices return devices
class OnvifFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): class OnvifFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a ONVIF config flow.""" """Handle a ONVIF config flow."""
VERSION = 1 VERSION = 1
_reauth_entry: config_entries.ConfigEntry _reauth_entry: ConfigEntry
@staticmethod @staticmethod
@callback @callback
def async_get_options_flow( def async_get_options_flow(
config_entry: config_entries.ConfigEntry, config_entry: ConfigEntry,
) -> OnvifOptionsFlowHandler: ) -> OnvifOptionsFlowHandler:
"""Get the options flow for this handler.""" """Get the options flow for this handler."""
return OnvifOptionsFlowHandler(config_entry) return OnvifOptionsFlowHandler(config_entry)
@ -123,7 +129,9 @@ class OnvifFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
data_schema=vol.Schema({vol.Required("auto", default=True): bool}), data_schema=vol.Schema({vol.Required("auto", default=True): bool}),
) )
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 of an existing config entry.""" """Handle re-authentication of an existing config entry."""
reauth_entry = self.hass.config_entries.async_get_entry( reauth_entry = self.hass.config_entries.async_get_entry(
self.context["entry_id"] self.context["entry_id"]
@ -134,7 +142,7 @@ class OnvifFlowHandler(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 reauth.""" """Confirm reauth."""
entry = self._reauth_entry entry = self._reauth_entry
errors: dict[str, str] | None = {} errors: dict[str, str] | None = {}
@ -161,7 +169,9 @@ class OnvifFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
description_placeholders=description_placeholders, description_placeholders=description_placeholders,
) )
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."""
hass = self.hass hass = self.hass
mac = discovery_info.macaddress mac = discovery_info.macaddress
@ -176,7 +186,7 @@ class OnvifFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
if ( if (
not (entry := hass.config_entries.async_get_entry(entry_id)) not (entry := hass.config_entries.async_get_entry(entry_id))
or entry.domain != DOMAIN or entry.domain != DOMAIN
or entry.state is config_entries.ConfigEntryState.LOADED or entry.state is ConfigEntryState.LOADED
): ):
continue continue
if hass.config_entries.async_update_entry( if hass.config_entries.async_update_entry(
@ -235,7 +245,7 @@ class OnvifFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_configure( async def async_step_configure(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Device configuration.""" """Device configuration."""
errors: dict[str, str] = {} errors: dict[str, str] = {}
description_placeholders: dict[str, str] = {} description_placeholders: dict[str, str] = {}
@ -374,10 +384,10 @@ class OnvifFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
await device.close() await device.close()
class OnvifOptionsFlowHandler(config_entries.OptionsFlow): class OnvifOptionsFlowHandler(OptionsFlow):
"""Handle ONVIF options.""" """Handle ONVIF options."""
def __init__(self, config_entry: config_entries.ConfigEntry) -> None: def __init__(self, config_entry: ConfigEntry) -> None:
"""Initialize ONVIF options flow.""" """Initialize ONVIF options flow."""
self.config_entry = config_entry self.config_entry = config_entry
self.options = dict(config_entry.options) self.options = dict(config_entry.options)

View file

@ -6,9 +6,8 @@ from typing import Any
import voluptuous as vol import voluptuous as vol
from homeassistant.components.zone import DOMAIN as ZONE_DOMAIN from homeassistant.components.zone import DOMAIN as ZONE_DOMAIN
from homeassistant.config_entries import ConfigFlow from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_ZONE from homeassistant.const import CONF_ZONE
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.selector import EntitySelector, EntitySelectorConfig from homeassistant.helpers.selector import EntitySelector, EntitySelectorConfig
from .const import DOMAIN from .const import DOMAIN
@ -21,7 +20,7 @@ class OpenMeteoFlowHandler(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:
await self.async_set_unique_id(user_input[CONF_ZONE]) await self.async_set_unique_id(user_input[CONF_ZONE])

View file

@ -9,10 +9,14 @@ from typing import Any
import openai import openai
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_API_KEY from homeassistant.const import CONF_API_KEY
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.selector import ( from homeassistant.helpers.selector import (
NumberSelector, NumberSelector,
NumberSelectorConfig, NumberSelectorConfig,
@ -61,14 +65,14 @@ async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> None:
await hass.async_add_executor_job(client.with_options(timeout=10.0).models.list) await hass.async_add_executor_job(client.with_options(timeout=10.0).models.list)
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class OpenAIConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for OpenAI Conversation.""" """Handle a config flow for OpenAI Conversation."""
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(
@ -95,22 +99,22 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
@staticmethod @staticmethod
def async_get_options_flow( def async_get_options_flow(
config_entry: config_entries.ConfigEntry, config_entry: ConfigEntry,
) -> config_entries.OptionsFlow: ) -> OptionsFlow:
"""Create the options flow.""" """Create the options flow."""
return OptionsFlow(config_entry) return OpenAIOptionsFlow(config_entry)
class OptionsFlow(config_entries.OptionsFlow): class OpenAIOptionsFlow(OptionsFlow):
"""OpenAI config flow options handler.""" """OpenAI config flow options handler."""
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."""
if user_input is not None: if user_input is not None:
return self.async_create_entry(title="OpenAI Conversation", data=user_input) return self.async_create_entry(title="OpenAI Conversation", data=user_input)

View file

@ -12,10 +12,10 @@ from aioopenexchangerates 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_KEY, CONF_BASE from homeassistant.const import CONF_API_KEY, CONF_BASE
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import AbortFlow, FlowResult from homeassistant.data_entry_flow import AbortFlow
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import CLIENT_TIMEOUT, DEFAULT_BASE, DOMAIN, LOGGER from .const import CLIENT_TIMEOUT, DEFAULT_BASE, DOMAIN, LOGGER
@ -45,7 +45,7 @@ async def validate_input(hass: HomeAssistant, data: dict[str, str]) -> dict[str,
return {"title": data[CONF_BASE]} return {"title": data[CONF_BASE]}
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class OpenExchangeRatesConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Open Exchange Rates.""" """Handle a config flow for Open Exchange Rates."""
VERSION = 1 VERSION = 1
@ -53,11 +53,11 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
def __init__(self) -> None: def __init__(self) -> None:
"""Initialize the config flow.""" """Initialize the config flow."""
self.currencies: dict[str, str] = {} self.currencies: dict[str, str] = {}
self._reauth_entry: config_entries.ConfigEntry | None = None self._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."""
currencies = await self.async_get_currencies() currencies = await self.async_get_currencies()
@ -110,7 +110,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.""" """Handle reauth."""
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

@ -8,10 +8,9 @@ import aiohttp
import opengarage import opengarage
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, CONF_VERIFY_SSL from homeassistant.const import CONF_HOST, CONF_PORT, CONF_VERIFY_SSL
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
from homeassistant.helpers.device_registry import format_mac from homeassistant.helpers.device_registry import format_mac
@ -53,14 +52,14 @@ async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> dict[str,
return {"title": status.get("name"), "unique_id": format_mac(status["mac"])} return {"title": status.get("name"), "unique_id": format_mac(status["mac"])}
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class OpenGarageConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for OpenGarage.""" """Handle a config flow for OpenGarage."""
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

@ -8,9 +8,8 @@ from homeassistant.components.ssdp import (
ATTR_UPNP_UDN, ATTR_UPNP_UDN,
SsdpServiceInfo, SsdpServiceInfo,
) )
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 .const import DOMAIN from .const import DOMAIN
@ -25,7 +24,9 @@ def _is_complete_discovery(discovery_info: SsdpServiceInfo) -> bool:
class OpenhomeConfigFlow(ConfigFlow, domain=DOMAIN): class OpenhomeConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle an Openhome config flow.""" """Handle an Openhome config flow."""
async def async_step_ssdp(self, discovery_info: SsdpServiceInfo) -> FlowResult: async def async_step_ssdp(
self, discovery_info: SsdpServiceInfo
) -> ConfigFlowResult:
"""Handle a flow initialized by discovery.""" """Handle a flow initialized by discovery."""
_LOGGER.debug("async_step_ssdp: started") _LOGGER.debug("async_step_ssdp: started")
@ -51,7 +52,7 @@ class OpenhomeConfigFlow(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."""
if user_input is not None: if user_input is not None:

View file

@ -11,6 +11,7 @@ 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 ( from homeassistant.const import (
@ -22,7 +23,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.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
@ -48,7 +48,7 @@ class OpenSkyConfigFlowHandler(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:
"""Initialize user input.""" """Initialize user input."""
if user_input is not None: if user_input is not None:
return self.async_create_entry( return self.async_create_entry(
@ -87,7 +87,7 @@ class OpenSkyOptionsFlowHandler(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:
"""Initialize form.""" """Initialize form."""
errors: dict[str, str] = {} errors: dict[str, str] = {}
if user_input is not None: if user_input is not None:

View file

@ -8,7 +8,7 @@ from pyotgw import vars as gw_vars
from serial import SerialException from serial import SerialException
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 ( from homeassistant.const import (
CONF_DEVICE, CONF_DEVICE,
CONF_ID, CONF_ID,
@ -30,7 +30,7 @@ from .const import (
) )
class OpenThermGwConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class OpenThermGwConfigFlow(ConfigFlow, domain=DOMAIN):
"""OpenTherm Gateway Config Flow.""" """OpenTherm Gateway Config Flow."""
VERSION = 1 VERSION = 1
@ -38,7 +38,7 @@ class OpenThermGwConfigFlow(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,
) -> OpenThermGwOptionsFlow: ) -> OpenThermGwOptionsFlow:
"""Get the options flow for this handler.""" """Get the options flow for this handler."""
return OpenThermGwOptionsFlow(config_entry) return OpenThermGwOptionsFlow(config_entry)
@ -116,10 +116,10 @@ class OpenThermGwConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
) )
class OpenThermGwOptionsFlow(config_entries.OptionsFlow): class OpenThermGwOptionsFlow(OptionsFlow):
"""Handle opentherm_gw options.""" """Handle opentherm_gw options."""
def __init__(self, config_entry: config_entries.ConfigEntry) -> None: def __init__(self, config_entry: ConfigEntry) -> None:
"""Initialize the options flow.""" """Initialize the options flow."""
self.config_entry = config_entry self.config_entry = config_entry

View file

@ -9,8 +9,7 @@ from pyopenuv import Client
from pyopenuv.errors import OpenUvError from pyopenuv.errors import OpenUvError
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_ELEVATION, CONF_ELEVATION,
@ -18,7 +17,6 @@ from homeassistant.const import (
CONF_LONGITUDE, 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,
@ -70,7 +68,7 @@ class OpenUvData:
return f"{self.latitude}, {self.longitude}" return f"{self.latitude}, {self.longitude}"
class OpenUvFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): class OpenUvFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle an OpenUV config flow.""" """Handle an OpenUV config flow."""
VERSION = 2 VERSION = 2
@ -99,7 +97,7 @@ class OpenUvFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def _async_verify( async def _async_verify(
self, data: OpenUvData, error_step_id: str, error_schema: vol.Schema self, data: OpenUvData, error_step_id: str, error_schema: vol.Schema
) -> FlowResult: ) -> ConfigFlowResult:
"""Verify the credentials and create/re-auth the entry.""" """Verify the credentials and create/re-auth the entry."""
websession = aiohttp_client.async_get_clientsession(self.hass) websession = aiohttp_client.async_get_clientsession(self.hass)
client = Client(data.api_key, 0, 0, session=websession) client = Client(data.api_key, 0, 0, session=websession)
@ -138,14 +136,16 @@ class OpenUvFlowHandler(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_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_data = entry_data self._reauth_data = entry_data
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-auth completion.""" """Handle re-auth completion."""
if not user_input: if not user_input:
return self.async_show_form( return self.async_show_form(
@ -168,7 +168,7 @@ class OpenUvFlowHandler(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 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

@ -5,7 +5,7 @@ from pyowm import OWM
from pyowm.commons.exceptions import APIRequestError, UnauthorizedError from pyowm.commons.exceptions import APIRequestError, UnauthorizedError
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 ( from homeassistant.const import (
CONF_API_KEY, CONF_API_KEY,
CONF_LANGUAGE, CONF_LANGUAGE,
@ -28,7 +28,7 @@ from .const import (
) )
class OpenWeatherMapConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class OpenWeatherMapConfigFlow(ConfigFlow, domain=DOMAIN):
"""Config flow for OpenWeatherMap.""" """Config flow for OpenWeatherMap."""
VERSION = CONFIG_FLOW_VERSION VERSION = CONFIG_FLOW_VERSION
@ -36,7 +36,7 @@ class OpenWeatherMapConfigFlow(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,
) -> OpenWeatherMapOptionsFlow: ) -> OpenWeatherMapOptionsFlow:
"""Get the options flow for this handler.""" """Get the options flow for this handler."""
return OpenWeatherMapOptionsFlow(config_entry) return OpenWeatherMapOptionsFlow(config_entry)
@ -90,10 +90,10 @@ class OpenWeatherMapConfigFlow(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)
class OpenWeatherMapOptionsFlow(config_entries.OptionsFlow): class OpenWeatherMapOptionsFlow(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

View file

@ -15,10 +15,9 @@ from opower 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_PASSWORD, CONF_USERNAME from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
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_create_clientsession from homeassistant.helpers.aiohttp_client import async_create_clientsession
from .const import CONF_TOTP_SECRET, CONF_UTILITY, DOMAIN from .const import CONF_TOTP_SECRET, CONF_UTILITY, DOMAIN
@ -55,19 +54,19 @@ async def _validate_login(
return errors return errors
class OpowerConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class OpowerConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Opower.""" """Handle a config flow for Opower."""
VERSION = 1 VERSION = 1
def __init__(self) -> None: def __init__(self) -> None:
"""Initialize a new OpowerConfigFlow.""" """Initialize a new OpowerConfigFlow."""
self.reauth_entry: config_entries.ConfigEntry | None = None self.reauth_entry: ConfigEntry | None = None
self.utility_info: dict[str, Any] | None = None self.utility_info: dict[str, Any] | 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:
@ -91,7 +90,7 @@ class OpowerConfigFlow(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 MFA step.""" """Handle MFA step."""
assert self.utility_info is not None assert self.utility_info is not None
errors: dict[str, str] = {} errors: dict[str, str] = {}
@ -120,14 +119,16 @@ class OpowerConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
) )
@callback @callback
def _async_create_opower_entry(self, data: dict[str, Any]) -> FlowResult: def _async_create_opower_entry(self, data: dict[str, Any]) -> ConfigFlowResult:
"""Create the config entry.""" """Create the config entry."""
return self.async_create_entry( return self.async_create_entry(
title=f"{data[CONF_UTILITY]} ({data[CONF_USERNAME]})", title=f"{data[CONF_UTILITY]} ({data[CONF_USERNAME]})",
data=data, data=data,
) )
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"]
@ -136,7 +137,7 @@ class OpowerConfigFlow(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:
"""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
errors: dict[str, str] = {} errors: dict[str, str] = {}

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

@ -6,10 +6,13 @@ from typing import Any
from apyosoenergyapi import OSOEnergy from apyosoenergyapi import OSOEnergy
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries from homeassistant.config_entries import (
from homeassistant.config_entries import ConfigEntry SOURCE_REAUTH,
ConfigEntry,
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 DOMAIN from .const import DOMAIN
@ -18,7 +21,7 @@ _LOGGER = logging.getLogger(__name__)
_SCHEMA_STEP_USER = vol.Schema({vol.Required(CONF_API_KEY): str}) _SCHEMA_STEP_USER = vol.Schema({vol.Required(CONF_API_KEY): str})
class OSOEnergyFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): class OSOEnergyFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a OSO Energy config flow.""" """Handle a OSO Energy config flow."""
VERSION = 1 VERSION = 1
@ -27,7 +30,7 @@ class OSOEnergyFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
"""Initialize.""" """Initialize."""
self.entry: ConfigEntry | None = None self.entry: ConfigEntry | None = None
async def async_step_user(self, user_input=None) -> FlowResult: async def async_step_user(self, user_input=None) -> ConfigFlowResult:
"""Handle a flow initialized by the user.""" """Handle a flow initialized by the user."""
errors = {} errors = {}
@ -36,10 +39,7 @@ class OSOEnergyFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
if user_email := await self.get_user_email(user_input[CONF_API_KEY]): if user_email := await self.get_user_email(user_input[CONF_API_KEY]):
await self.async_set_unique_id(user_email) await self.async_set_unique_id(user_email)
if ( if self.context["source"] == SOURCE_REAUTH and self.entry:
self.context["source"] == config_entries.SOURCE_REAUTH
and self.entry
):
self.hass.config_entries.async_update_entry( self.hass.config_entries.async_update_entry(
self.entry, title=user_email, data=user_input self.entry, title=user_email, data=user_input
) )
@ -67,7 +67,9 @@ class OSOEnergyFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
_LOGGER.exception("Unknown error occurred") _LOGGER.exception("Unknown error occurred")
return None return None
async def async_step_reauth(self, user_input: Mapping[str, Any]) -> FlowResult: async def async_step_reauth(
self, user_input: Mapping[str, Any]
) -> ConfigFlowResult:
"""Re Authenticate a user.""" """Re Authenticate a user."""
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"])
data = {CONF_API_KEY: user_input[CONF_API_KEY]} data = {CONF_API_KEY: user_input[CONF_API_KEY]}

View file

@ -19,10 +19,9 @@ from homeassistant.components.hassio import (
) )
from homeassistant.components.homeassistant_yellow import hardware as yellow_hardware from homeassistant.components.homeassistant_yellow import hardware as yellow_hardware
from homeassistant.components.thread import async_get_preferred_dataset from homeassistant.components.thread import async_get_preferred_dataset
from homeassistant.config_entries import SOURCE_HASSIO, ConfigFlow from homeassistant.config_entries import SOURCE_HASSIO, ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_URL from homeassistant.const import CONF_URL
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
@ -100,7 +99,7 @@ class OTBRConfigFlow(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:
"""Set up by user.""" """Set up by 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")
@ -129,7 +128,9 @@ class OTBRConfigFlow(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_hassio(self, discovery_info: HassioServiceInfo) -> FlowResult: async def async_step_hassio(
self, discovery_info: HassioServiceInfo
) -> ConfigFlowResult:
"""Handle hassio discovery.""" """Handle hassio discovery."""
config = discovery_info.config config = discovery_info.config
url = f"http://{config['host']}:{config['port']}" url = f"http://{config['host']}:{config['port']}"

View file

@ -9,9 +9,8 @@ from ourgroceries import OurGroceries
from ourgroceries.exceptions import InvalidLoginException from ourgroceries.exceptions import InvalidLoginException
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 DOMAIN from .const import DOMAIN
@ -25,14 +24,14 @@ STEP_USER_DATA_SCHEMA = vol.Schema(
) )
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class OurGroceriesConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for OurGroceries.""" """Handle a config flow for OurGroceries."""
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

@ -22,9 +22,8 @@ from pyoverkiz.obfuscate import obfuscate_id
from pyoverkiz.utils import generate_local_server, is_overkiz_gateway from pyoverkiz.utils import generate_local_server, is_overkiz_gateway
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import dhcp, zeroconf from homeassistant.components import dhcp, zeroconf
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.const import ( from homeassistant.const import (
CONF_HOST, CONF_HOST,
CONF_PASSWORD, CONF_PASSWORD,
@ -32,7 +31,6 @@ from homeassistant.const import (
CONF_USERNAME, CONF_USERNAME,
CONF_VERIFY_SSL, CONF_VERIFY_SSL,
) )
from homeassistant.data_entry_flow import FlowResult
from homeassistant.exceptions import HomeAssistantError from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.aiohttp_client import async_create_clientsession from homeassistant.helpers.aiohttp_client import async_create_clientsession
@ -43,7 +41,7 @@ class DeveloperModeDisabled(HomeAssistantError):
"""Error to indicate Somfy Developer Mode is disabled.""" """Error to indicate Somfy Developer Mode is disabled."""
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class OverkizConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Overkiz (by Somfy).""" """Handle a config flow for Overkiz (by Somfy)."""
VERSION = 1 VERSION = 1
@ -84,7 +82,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 via config flow.""" """Handle the initial step via config flow."""
if user_input: if user_input:
self._server = user_input[CONF_HUB] self._server = user_input[CONF_HUB]
@ -109,7 +107,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_local_or_cloud( async def async_step_local_or_cloud(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Users can choose between local API or cloud API via config flow.""" """Users can choose between local API or cloud API via config flow."""
if user_input: if user_input:
self._api_type = user_input[CONF_API_TYPE] self._api_type = user_input[CONF_API_TYPE]
@ -135,7 +133,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 authentication step via config flow.""" """Handle the cloud authentication step via config flow."""
errors: dict[str, str] = {} errors: dict[str, str] = {}
description_placeholders = {} description_placeholders = {}
@ -217,7 +215,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 authentication step via config flow.""" """Handle the local authentication step via config flow."""
errors = {} errors = {}
description_placeholders = {} description_placeholders = {}
@ -300,7 +298,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."""
hostname = discovery_info.hostname hostname = discovery_info.hostname
gateway_id = hostname[8:22] gateway_id = hostname[8:22]
@ -311,7 +311,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."""
properties = discovery_info.properties properties = discovery_info.properties
gateway_id = properties["gateway_pin"] gateway_id = properties["gateway_pin"]
@ -333,7 +333,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
return await self._process_discovery(gateway_id) return await self._process_discovery(gateway_id)
async def _process_discovery(self, gateway_id: str) -> FlowResult: async def _process_discovery(self, gateway_id: str) -> ConfigFlowResult:
"""Handle discovery of a gateway.""" """Handle discovery of a gateway."""
await self.async_set_unique_id(gateway_id) await self.async_set_unique_id(gateway_id)
self._abort_if_unique_id_configured() self._abort_if_unique_id_configured()
@ -341,7 +341,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
return await self.async_step_user() return await self.async_step_user()
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: async def async_step_reauth(
self, entry_data: Mapping[str, Any]
) -> ConfigFlowResult:
"""Handle reauth.""" """Handle reauth."""
self._reauth_entry = cast( self._reauth_entry = cast(
ConfigEntry, ConfigEntry,

View file

@ -8,9 +8,8 @@ import aiohttp
from ovoenergy.ovoenergy import OVOEnergy from ovoenergy.ovoenergy import OVOEnergy
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_USERNAME from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.data_entry_flow import FlowResult
from .const import CONF_ACCOUNT, DOMAIN from .const import CONF_ACCOUNT, DOMAIN
@ -37,7 +36,7 @@ class OVOEnergyFlowHandler(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:
"""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:
@ -73,7 +72,7 @@ class OVOEnergyFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_reauth( async def async_step_reauth(
self, self,
user_input: Mapping[str, Any], user_input: Mapping[str, Any],
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle configuration by re-auth.""" """Handle configuration by re-auth."""
errors = {} errors = {}

View file

@ -1,8 +1,8 @@
"""Config flow for OwnTracks.""" """Config flow for OwnTracks."""
import secrets import secrets
from homeassistant import config_entries
from homeassistant.components import cloud, webhook from homeassistant.components import cloud, webhook
from homeassistant.config_entries import ConfigFlow
from homeassistant.const import CONF_WEBHOOK_ID from homeassistant.const import CONF_WEBHOOK_ID
from .const import DOMAIN from .const import DOMAIN
@ -12,7 +12,7 @@ CONF_SECRET = "secret"
CONF_CLOUDHOOK = "cloudhook" CONF_CLOUDHOOK = "cloudhook"
class OwnTracksFlow(config_entries.ConfigFlow, domain=DOMAIN): class OwnTracksFlow(ConfigFlow, domain=DOMAIN):
"""Set up OwnTracks.""" """Set up OwnTracks."""
VERSION = 1 VERSION = 1

View file

@ -6,9 +6,8 @@ from typing import Any
from p1monitor import P1Monitor, P1MonitorError from p1monitor import P1Monitor, P1MonitorError
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 from homeassistant.const import CONF_HOST
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 TextSelector from homeassistant.helpers.selector import TextSelector
@ -22,7 +21,7 @@ class P1MonitorFlowHandler(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 = {}

View file

@ -6,7 +6,7 @@ from urllib.error import URLError
from panasonic_viera import TV_TYPE_ENCRYPTED, RemoteControl, SOAPError from panasonic_viera import TV_TYPE_ENCRYPTED, RemoteControl, SOAPError
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, CONF_NAME, CONF_PIN, CONF_PORT from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PIN, CONF_PORT
from .const import ( from .const import (
@ -25,7 +25,7 @@ from .const import (
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class PanasonicVieraConfigFlow(ConfigFlow, domain=DOMAIN):
"""Config flow for Panasonic Viera.""" """Config flow for Panasonic Viera."""
VERSION = 1 VERSION = 1

View file

@ -12,8 +12,7 @@ from peco import (
) )
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
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_COUNTY, CONF_PHONE_NUMBER, COUNTY_LIST, DOMAIN from .const import CONF_COUNTY, CONF_PHONE_NUMBER, COUNTY_LIST, DOMAIN
@ -28,7 +27,7 @@ STEP_USER_DATA_SCHEMA = vol.Schema(
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class PecoConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for PECO Outage Counter.""" """Handle a config flow for PECO Outage Counter."""
VERSION = 1 VERSION = 1
@ -54,7 +53,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(
@ -90,7 +89,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_finish_smart_meter( async def async_step_finish_smart_meter(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle the finish smart meter step.""" """Handle the finish smart meter step."""
if "phone_number" in self.meter_error: if "phone_number" in self.meter_error:
if self.meter_error["type"] == "error": if self.meter_error["type"] == "error":

View file

@ -6,7 +6,7 @@ from typing import Any
from aiopegelonline import CONNECT_ERRORS, PegelOnline from aiopegelonline import CONNECT_ERRORS, PegelOnline
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_LATITUDE, CONF_LATITUDE,
CONF_LOCATION, CONF_LOCATION,
@ -14,7 +14,6 @@ from homeassistant.const import (
CONF_RADIUS, CONF_RADIUS,
UnitOfLength, UnitOfLength,
) )
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 (
LocationSelector, LocationSelector,
@ -29,7 +28,7 @@ from homeassistant.helpers.selector import (
from .const import CONF_STATION, DEFAULT_RADIUS, DOMAIN from .const import CONF_STATION, DEFAULT_RADIUS, DOMAIN
class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN): class FlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a config flow.""" """Handle a config flow."""
VERSION = 1 VERSION = 1
@ -42,7 +41,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:
"""Handle a flow initialized by the user.""" """Handle a flow initialized by the user."""
if not user_input: if not user_input:
return self._show_form_user() return self._show_form_user()
@ -69,7 +68,7 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_select_station( async def async_step_select_station(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle the step select_station of a flow initialized by the user.""" """Handle the step select_station of a flow initialized by the user."""
if not user_input: if not user_input:
stations = [ stations = [
@ -101,7 +100,7 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
self, self,
user_input: dict[str, Any] | None = None, user_input: dict[str, Any] | None = None,
errors: dict[str, Any] | None = None, errors: dict[str, Any] | None = None,
) -> FlowResult: ) -> ConfigFlowResult:
if user_input is None: if user_input is None:
user_input = {} user_input = {}
return self.async_show_form( return self.async_show_form(

View file

@ -13,10 +13,9 @@ from mypermobil import (
) )
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_CODE, CONF_EMAIL, CONF_REGION, CONF_TOKEN, CONF_TTL from homeassistant.const import CONF_CODE, CONF_EMAIL, CONF_REGION, CONF_TOKEN, CONF_TTL
from homeassistant.core import HomeAssistant, async_get_hass from homeassistant.core import HomeAssistant, async_get_hass
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import selector from homeassistant.helpers import selector
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
@ -41,7 +40,7 @@ GET_EMAIL_SCHEMA = vol.Schema(
GET_TOKEN_SCHEMA = vol.Schema({vol.Required(CONF_CODE): cv.string}) GET_TOKEN_SCHEMA = vol.Schema({vol.Required(CONF_CODE): cv.string})
class PermobilConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class PermobilConfigFlow(ConfigFlow, domain=DOMAIN):
"""Permobil config flow.""" """Permobil config flow."""
VERSION = 1 VERSION = 1
@ -56,7 +55,7 @@ class PermobilConfigFlow(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:
"""Invoke when a user initiates a flow via the user interface.""" """Invoke when a user initiates a flow via the user interface."""
errors: dict[str, str] = {} errors: dict[str, str] = {}
@ -80,7 +79,7 @@ class PermobilConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_region( async def async_step_region(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Invoke when a user initiates a flow via the user interface.""" """Invoke when a user initiates a flow via the user interface."""
errors: dict[str, str] = {} errors: dict[str, str] = {}
if not user_input: if not user_input:
@ -130,7 +129,7 @@ class PermobilConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_email_code( async def async_step_email_code(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Second step in config flow to enter the email code.""" """Second step in config flow to enter the email code."""
errors: dict[str, str] = {} errors: dict[str, str] = {}
@ -160,7 +159,9 @@ class PermobilConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
return self.async_create_entry(title=self.data[CONF_EMAIL], data=self.data) return self.async_create_entry(title=self.data[CONF_EMAIL], data=self.data)
async def async_step_reauth(self, user_input: Mapping[str, Any]) -> FlowResult: async def async_step_reauth(
self, user_input: Mapping[str, Any]
) -> ConfigFlowResult:
"""Perform reauth upon an API authentication error.""" """Perform reauth upon an API authentication error."""
reauth_entry = self.hass.config_entries.async_get_entry( reauth_entry = self.hass.config_entries.async_get_entry(
self.context["entry_id"] self.context["entry_id"]

View file

@ -8,7 +8,7 @@ from typing import Any
from haphilipsjs import ConnectionFailure, PairingFailure, PhilipsTV from haphilipsjs import ConnectionFailure, PairingFailure, PhilipsTV
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries, core from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.const import ( from homeassistant.const import (
CONF_API_VERSION, CONF_API_VERSION,
CONF_HOST, CONF_HOST,
@ -16,7 +16,7 @@ from homeassistant.const import (
CONF_PIN, CONF_PIN,
CONF_USERNAME, CONF_USERNAME,
) )
from homeassistant.data_entry_flow import FlowResult from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import selector from homeassistant.helpers import selector
from homeassistant.helpers.schema_config_entry_flow import ( from homeassistant.helpers.schema_config_entry_flow import (
SchemaFlowFormStep, SchemaFlowFormStep,
@ -49,7 +49,7 @@ OPTIONS_FLOW = {
async def _validate_input( async def _validate_input(
hass: core.HomeAssistant, host: str, api_version: int hass: HomeAssistant, host: str, api_version: int
) -> PhilipsTV: ) -> PhilipsTV:
"""Validate the user input allows us to connect.""" """Validate the user input allows us to connect."""
hub = PhilipsTV(host, api_version) hub = PhilipsTV(host, api_version)
@ -63,7 +63,7 @@ async def _validate_input(
return hub return hub
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class PhilipsJSConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Philips TV.""" """Handle a config flow for Philips TV."""
VERSION = 1 VERSION = 1
@ -74,9 +74,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
self._current: dict[str, Any] = {} self._current: dict[str, Any] = {}
self._hub: PhilipsTV | None = None self._hub: PhilipsTV | None = None
self._pair_state: Any = None self._pair_state: Any = None
self._entry: config_entries.ConfigEntry | None = None self._entry: ConfigEntry | None = None
async def _async_create_current(self) -> FlowResult: async def _async_create_current(self) -> ConfigFlowResult:
system = self._current[CONF_SYSTEM] system = self._current[CONF_SYSTEM]
if self._entry: if self._entry:
self.hass.config_entries.async_update_entry( self.hass.config_entries.async_update_entry(
@ -94,7 +94,7 @@ class ConfigFlow(config_entries.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:
"""Attempt to pair with device.""" """Attempt to pair with device."""
assert self._hub assert self._hub
@ -145,7 +145,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
self._current[CONF_PASSWORD] = password self._current[CONF_PASSWORD] = password
return await self._async_create_current() return await self._async_create_current()
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._current[CONF_HOST] = entry_data[CONF_HOST] self._current[CONF_HOST] = entry_data[CONF_HOST]
@ -154,7 +156,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: if user_input:
@ -187,9 +189,9 @@ class ConfigFlow(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)
@staticmethod @staticmethod
@core.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

@ -9,7 +9,7 @@ from hole import Hole
from hole.exceptions import HoleError from hole.exceptions import HoleError
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_API_KEY, CONF_API_KEY,
CONF_HOST, CONF_HOST,
@ -19,7 +19,6 @@ from homeassistant.const import (
CONF_SSL, CONF_SSL,
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 ( from .const import (
@ -33,7 +32,7 @@ from .const import (
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
class PiHoleFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): class PiHoleFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a Pi-hole config flow.""" """Handle a Pi-hole config flow."""
VERSION = 1 VERSION = 1
@ -44,7 +43,7 @@ class PiHoleFlowHandler(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 = {}
@ -103,7 +102,7 @@ class PiHoleFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_api_key( async def async_step_api_key(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle step to setup API key.""" """Handle step to setup API key."""
errors = {} errors = {}
if user_input is not None: if user_input is not None:
@ -120,7 +119,9 @@ class PiHoleFlowHandler(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 upon an API authentication error.""" """Perform reauth upon an API authentication error."""
self._config = dict(entry_data) self._config = dict(entry_data)
return await self.async_step_reauth_confirm() return await self.async_step_reauth_confirm()
@ -128,7 +129,7 @@ class PiHoleFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_reauth_confirm( async def async_step_reauth_confirm(
self, self,
user_input: dict[str, Any] | None = None, user_input: dict[str, Any] | None = None,
) -> FlowResult: ) -> ConfigFlowResult:
"""Perform reauth confirm upon an API authentication error.""" """Perform reauth confirm upon an API authentication error."""
errors = {} errors = {}
if user_input is not None: if user_input is not None:

View file

@ -10,15 +10,15 @@ from python_picnic_api.session import PicnicAuthError
import requests import requests
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries, core, exceptions from homeassistant.config_entries import SOURCE_REAUTH, ConfigFlow, ConfigFlowResult
from homeassistant.config_entries import SOURCE_REAUTH
from homeassistant.const import ( from homeassistant.const import (
CONF_ACCESS_TOKEN, CONF_ACCESS_TOKEN,
CONF_COUNTRY_CODE, CONF_COUNTRY_CODE,
CONF_PASSWORD, CONF_PASSWORD,
CONF_USERNAME, CONF_USERNAME,
) )
from homeassistant.data_entry_flow import FlowResult from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
from .const import COUNTRY_CODES, DOMAIN from .const import COUNTRY_CODES, DOMAIN
@ -45,7 +45,7 @@ class PicnicHub:
return picnic.session.auth_token, picnic.get_user() return picnic.session.auth_token, picnic.get_user()
async def validate_input(hass: core.HomeAssistant, data): async def validate_input(hass: HomeAssistant, data):
"""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.
@ -75,12 +75,14 @@ async def validate_input(hass: core.HomeAssistant, data):
} }
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class PicnicConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Picnic.""" """Handle a config flow for Picnic."""
VERSION = 1 VERSION = 1
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 the re-auth step upon an API authentication error.""" """Perform the re-auth step upon an API authentication error."""
return await self.async_step_user() return await self.async_step_user()
@ -128,9 +130,9 @@ class ConfigFlow(config_entries.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

@ -7,14 +7,18 @@ from typing import Any
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components.device_tracker import ( 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,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.const import CONF_HOST, CONF_NAME from homeassistant.const import CONF_HOST, CONF_NAME
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
from homeassistant.util.network import is_ip_address from homeassistant.util.network import is_ip_address
@ -23,14 +27,14 @@ from .const import CONF_IMPORTED_BY, CONF_PING_COUNT, DEFAULT_PING_COUNT, DOMAIN
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class PingConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Ping.""" """Handle a config flow for Ping."""
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(
@ -56,7 +60,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
}, },
) )
async def async_step_import(self, import_info: Mapping[str, Any]) -> FlowResult: async def async_step_import(
self, import_info: Mapping[str, Any]
) -> ConfigFlowResult:
"""Import an entry.""" """Import an entry."""
to_import = { to_import = {
@ -78,22 +84,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,
) -> config_entries.OptionsFlow: ) -> OptionsFlow:
"""Create the options flow.""" """Create the options flow."""
return OptionsFlowHandler(config_entry) return OptionsFlowHandler(config_entry)
class OptionsFlowHandler(config_entries.OptionsFlow): class OptionsFlowHandler(OptionsFlow):
"""Handle an options flow for Ping.""" """Handle an options flow for Ping."""
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."""
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 pyplaato.plaato import PlaatoDeviceType from pyplaato.plaato import PlaatoDeviceType
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import cloud, webhook from homeassistant.components import cloud, webhook
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry, ConfigFlow, OptionsFlow
from homeassistant.const import CONF_SCAN_INTERVAL, CONF_TOKEN, CONF_WEBHOOK_ID from homeassistant.const import CONF_SCAN_INTERVAL, CONF_TOKEN, CONF_WEBHOOK_ID
from homeassistant.core import callback from homeassistant.core import callback
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
@ -26,7 +25,7 @@ from .const import (
) )
class PlaatoConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class PlaatoConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handles a Plaato config flow.""" """Handles a Plaato config flow."""
VERSION = 1 VERSION = 1
@ -168,7 +167,7 @@ class PlaatoConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
return PlaatoOptionsFlowHandler(config_entry) return PlaatoOptionsFlowHandler(config_entry)
class PlaatoOptionsFlowHandler(config_entries.OptionsFlow): class PlaatoOptionsFlowHandler(OptionsFlow):
"""Handle Plaato options.""" """Handle Plaato options."""
def __init__(self, config_entry: ConfigEntry) -> None: def __init__(self, config_entry: ConfigEntry) -> None:

View file

@ -13,10 +13,17 @@ from plexauth import PlexAuth
import requests.exceptions import requests.exceptions
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import http from homeassistant.components import http
from homeassistant.components.http.view import HomeAssistantView from homeassistant.components.http.view import HomeAssistantView
from homeassistant.components.media_player import DOMAIN as MP_DOMAIN from homeassistant.components.media_player import DOMAIN as MP_DOMAIN
from homeassistant.config_entries import (
SOURCE_INTEGRATION_DISCOVERY,
SOURCE_REAUTH,
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.const import ( from homeassistant.const import (
CONF_CLIENT_ID, CONF_CLIENT_ID,
CONF_HOST, CONF_HOST,
@ -28,7 +35,6 @@ from homeassistant.const import (
CONF_VERIFY_SSL, CONF_VERIFY_SSL,
) )
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import discovery_flow from homeassistant.helpers import discovery_flow
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
@ -80,12 +86,12 @@ async def async_discover(hass):
discovery_flow.async_create_flow( discovery_flow.async_create_flow(
hass, hass,
DOMAIN, DOMAIN,
context={CONF_SOURCE: config_entries.SOURCE_INTEGRATION_DISCOVERY}, context={CONF_SOURCE: SOURCE_INTEGRATION_DISCOVERY},
data=server_data, data=server_data,
) )
class PlexFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): class PlexFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a Plex config flow.""" """Handle a Plex config flow."""
VERSION = 1 VERSION = 1
@ -93,7 +99,7 @@ class PlexFlowHandler(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,
) -> PlexOptionsFlowHandler: ) -> PlexOptionsFlowHandler:
"""Get the options flow for this handler.""" """Get the options flow for this handler."""
return PlexOptionsFlowHandler(config_entry) return PlexOptionsFlowHandler(config_entry)
@ -241,7 +247,7 @@ class PlexFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
} }
entry = await self.async_set_unique_id(server_id) entry = await self.async_set_unique_id(server_id)
if self.context[CONF_SOURCE] == config_entries.SOURCE_REAUTH: if self.context[CONF_SOURCE] == SOURCE_REAUTH:
self.hass.config_entries.async_update_entry(entry, data=data) self.hass.config_entries.async_update_entry(entry, data=data)
_LOGGER.debug("Updated config entry for %s", plex_server.friendly_name) _LOGGER.debug("Updated config entry for %s", plex_server.friendly_name)
await self.hass.config_entries.async_reload(entry.entry_id) await self.hass.config_entries.async_reload(entry.entry_id)
@ -338,7 +344,9 @@ class PlexFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
server_config = {CONF_TOKEN: self.token} server_config = {CONF_TOKEN: self.token}
return await self.async_step_server_validate(server_config) return await self.async_step_server_validate(server_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 a reauthorization flow request.""" """Handle a reauthorization flow request."""
self._reauth_config = { self._reauth_config = {
CONF_SERVER_IDENTIFIER: entry_data[CONF_SERVER_IDENTIFIER] CONF_SERVER_IDENTIFIER: entry_data[CONF_SERVER_IDENTIFIER]
@ -346,10 +354,10 @@ class PlexFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
return await self.async_step_user() return await self.async_step_user()
class PlexOptionsFlowHandler(config_entries.OptionsFlow): class PlexOptionsFlowHandler(OptionsFlow):
"""Handle Plex options.""" """Handle Plex options."""
def __init__(self, config_entry: config_entries.ConfigEntry) -> None: def __init__(self, config_entry: ConfigEntry) -> None:
"""Initialize Plex options flow.""" """Initialize Plex options flow."""
self.options = copy.deepcopy(dict(config_entry.options)) self.options = copy.deepcopy(dict(config_entry.options))
self.server_id = config_entry.data[CONF_SERVER_IDENTIFIER] self.server_id = config_entry.data[CONF_SERVER_IDENTIFIER]

View file

@ -15,7 +15,7 @@ from plugwise.exceptions import (
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 ( 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 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 ( from .const import (
@ -89,7 +88,7 @@ class PlugwiseConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_zeroconf( async def async_step_zeroconf(
self, discovery_info: ZeroconfServiceInfo self, discovery_info: ZeroconfServiceInfo
) -> FlowResult: ) -> ConfigFlowResult:
"""Prepare configuration for a discovered Plugwise Smile.""" """Prepare configuration for a discovered Plugwise Smile."""
self.discovery_info = discovery_info self.discovery_info = discovery_info
_properties = discovery_info.properties _properties = discovery_info.properties
@ -166,7 +165,7 @@ class PlugwiseConfigFlow(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 when using network/gateway setups.""" """Handle the initial step when using network/gateway setups."""
errors = {} errors = {}

View file

@ -8,9 +8,8 @@ from aiohttp import ContentTypeError
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 DOMAIN from .const import DOMAIN
from .utils import load_plum from .utils import load_plum
@ -18,7 +17,7 @@ from .utils import load_plum
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
class PlumLightpadConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class PlumLightpadConfigFlow(ConfigFlow, domain=DOMAIN):
"""Config flow for Plum Lightpad integration.""" """Config flow for Plum Lightpad integration."""
VERSION = 1 VERSION = 1
@ -37,7 +36,7 @@ class PlumLightpadConfigFlow(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 or redirected to by import.""" """Handle a flow initialized by the user or redirected to by import."""
if not user_input: if not user_input:
return self._show_form() return self._show_form()

View file

@ -6,8 +6,8 @@ import logging
from pypoint import PointSession from pypoint import PointSession
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components.http import HomeAssistantView from homeassistant.components.http import HomeAssistantView
from homeassistant.config_entries import ConfigFlow
from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
@ -40,7 +40,7 @@ def register_flow_implementation(hass, domain, client_id, client_secret):
} }
class PointFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): class PointFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a config flow.""" """Handle a config flow."""
VERSION = 1 VERSION = 1

View file

@ -5,9 +5,8 @@ from typing import Any
from poolsense import PoolSense from poolsense import PoolSense
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
@ -15,7 +14,7 @@ from .const import DOMAIN
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
class PoolSenseConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class PoolSenseConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for PoolSense.""" """Handle a config flow for PoolSense."""
VERSION = 1 VERSION = 1
@ -25,7 +24,7 @@ class PoolSenseConfigFlow(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

@ -16,10 +16,16 @@ from tesla_powerwall import (
) )
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries, core, exceptions
from homeassistant.components import dhcp from homeassistant.components import dhcp
from homeassistant.config_entries import (
ConfigEntry,
ConfigEntryState,
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.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.aiohttp_client import async_create_clientsession from homeassistant.helpers.aiohttp_client import async_create_clientsession
from homeassistant.util.network import is_ip_address from homeassistant.util.network import is_ip_address
@ -30,8 +36,8 @@ _LOGGER = logging.getLogger(__name__)
ENTRY_FAILURE_STATES = { ENTRY_FAILURE_STATES = {
config_entries.ConfigEntryState.SETUP_ERROR, ConfigEntryState.SETUP_ERROR,
config_entries.ConfigEntryState.SETUP_RETRY, ConfigEntryState.SETUP_RETRY,
} }
@ -59,9 +65,7 @@ async def _powerwall_is_reachable(ip_address: str, password: str) -> bool:
return True return True
async def validate_input( async def validate_input(hass: HomeAssistant, data: dict[str, str]) -> dict[str, str]:
hass: core.HomeAssistant, data: dict[str, str]
) -> dict[str, str]:
"""Validate the user input allows us to connect. """Validate the user input allows us to connect.
Data has the keys from schema with values provided by the user. Data has the keys from schema with values provided by the user.
@ -85,7 +89,7 @@ async def validate_input(
return {"title": site_info.site_name, "unique_id": gateway_din.upper()} return {"title": site_info.site_name, "unique_id": gateway_din.upper()}
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class PowerwallConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Tesla Powerwall.""" """Handle a config flow for Tesla Powerwall."""
VERSION = 1 VERSION = 1
@ -94,11 +98,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
"""Initialize the powerwall flow.""" """Initialize the powerwall flow."""
self.ip_address: str | None = None self.ip_address: str | None = None
self.title: str | None = None self.title: str | None = None
self.reauth_entry: config_entries.ConfigEntry | None = None self.reauth_entry: ConfigEntry | None = None
async def _async_powerwall_is_offline( async def _async_powerwall_is_offline(self, entry: ConfigEntry) -> bool:
self, entry: config_entries.ConfigEntry
) -> bool:
"""Check if the power wall is offline. """Check if the power wall is offline.
We define offline by the config entry We define offline by the config entry
@ -113,7 +115,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
or not async_last_update_was_successful(self.hass, entry) or not async_last_update_was_successful(self.hass, entry)
) and not await _powerwall_is_reachable(ip_address, password) ) and not await _powerwall_is_reachable(ip_address, password)
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.ip_address = discovery_info.ip self.ip_address = discovery_info.ip
gateway_din = discovery_info.hostname.upper() gateway_din = discovery_info.hostname.upper()
@ -180,7 +184,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:
"""Confirm a discovered powerwall.""" """Confirm a discovered powerwall."""
assert self.ip_address is not None assert self.ip_address is not None
assert self.unique_id is not None assert self.unique_id is not None
@ -209,7 +213,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 = {} errors: dict[str, str] | None = {}
description_placeholders: dict[str, str] = {} description_placeholders: dict[str, str] = {}
@ -243,7 +247,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 reauth confirmation.""" """Handle reauth confirmation."""
assert self.reauth_entry is not None assert self.reauth_entry is not None
errors: dict[str, str] | None = {} errors: dict[str, str] | None = {}
@ -265,7 +269,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
description_placeholders=description_placeholders, description_placeholders=description_placeholders,
) )
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"]
@ -273,5 +279,5 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
return await self.async_step_reauth_confirm() return await self.async_step_reauth_confirm()
class WrongVersion(exceptions.HomeAssistantError): class WrongVersion(HomeAssistantError):
"""Error indicating we cannot interact with the powerwall software version.""" """Error indicating we cannot interact with the powerwall software version."""

View file

@ -8,8 +8,7 @@ import logging
import voluptuous as vol import voluptuous as vol
from homeassistant.components import bluetooth from homeassistant.components import bluetooth
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
from .coordinator import async_last_service_info from .coordinator import async_last_service_info
@ -50,7 +49,7 @@ class BLEDeviceTrackerConfigFlow(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:
"""Set up by user.""" """Set up by user."""
errors: dict[str, str] = {} errors: dict[str, str] = {}

View file

@ -1,10 +1,10 @@
"""Config flow for Profiler integration.""" """Config flow for Profiler integration."""
from homeassistant import config_entries from homeassistant.config_entries import ConfigFlow
from .const import DEFAULT_NAME, DOMAIN from .const import DEFAULT_NAME, DOMAIN
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class ProfilerConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Profiler.""" """Handle a config flow for Profiler."""
VERSION = 1 VERSION = 1

View file

@ -3,7 +3,9 @@
from ProgettiHWSW.ProgettiHWSWAPI import ProgettiHWSWAPI from ProgettiHWSW.ProgettiHWSWAPI import ProgettiHWSWAPI
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries, core, exceptions from homeassistant.config_entries import ConfigFlow
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
from .const import DOMAIN from .const import DOMAIN
@ -12,7 +14,7 @@ DATA_SCHEMA = vol.Schema(
) )
async def validate_input(hass: core.HomeAssistant, data): async def validate_input(hass: HomeAssistant, data):
"""Validate the user host input.""" """Validate the user host input."""
api_instance = ProgettiHWSWAPI(f'{data["host"]}:{data["port"]}') api_instance = ProgettiHWSWAPI(f'{data["host"]}:{data["port"]}')
@ -29,7 +31,7 @@ async def validate_input(hass: core.HomeAssistant, data):
} }
class ProgettiHWSWConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class ProgettiHWSWConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for ProgettiHWSW Automation.""" """Handle a config flow for ProgettiHWSW Automation."""
VERSION = 1 VERSION = 1
@ -88,13 +90,13 @@ class ProgettiHWSWConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
) )
class CannotConnect(exceptions.HomeAssistantError): class CannotConnect(HomeAssistantError):
"""Error to indicate we cannot identify host.""" """Error to indicate we cannot identify host."""
class WrongInfo(exceptions.HomeAssistantError): class WrongInfo(HomeAssistantError):
"""Error to indicate we cannot validate relay modes input.""" """Error to indicate we cannot validate relay modes input."""
class ExistingEntry(exceptions.HomeAssistantError): class ExistingEntry(HomeAssistantError):
"""Error to indicate we cannot validate relay modes input.""" """Error to indicate we cannot validate relay modes input."""

View file

@ -7,10 +7,10 @@ from pyprosegur.auth import COUNTRY, Auth
from pyprosegur.installation import Installation from pyprosegur.installation import Installation
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries, core, exceptions from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_COUNTRY, CONF_PASSWORD, CONF_USERNAME from homeassistant.const import CONF_COUNTRY, CONF_PASSWORD, CONF_USERNAME
from homeassistant.data_entry_flow import FlowResult from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import aiohttp_client, selector from homeassistant.helpers import aiohttp_client, selector
from .const import CONF_CONTRACT, DOMAIN from .const import CONF_CONTRACT, DOMAIN
@ -28,7 +28,7 @@ STEP_USER_DATA_SCHEMA = vol.Schema(
) )
async def validate_input(hass: core.HomeAssistant, data): async def validate_input(hass: HomeAssistant, data):
"""Validate the user input allows us to connect.""" """Validate the user input allows us to connect."""
session = aiohttp_client.async_get_clientsession(hass) session = aiohttp_client.async_get_clientsession(hass)
auth = Auth(session, data[CONF_USERNAME], data[CONF_PASSWORD], data[CONF_COUNTRY]) auth = Auth(session, data[CONF_USERNAME], data[CONF_PASSWORD], data[CONF_COUNTRY])
@ -41,7 +41,7 @@ async def validate_input(hass: core.HomeAssistant, data):
raise CannotConnect from ConnectionError raise CannotConnect from ConnectionError
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class ProsegurConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Prosegur Alarm.""" """Handle a config flow for Prosegur Alarm."""
VERSION = 1 VERSION = 1
@ -74,7 +74,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_choose_contract( async def async_step_choose_contract(
self, user_input: Any | None = None self, user_input: Any | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Let user decide which contract is being setup.""" """Let user decide which contract is being setup."""
if user_input: if user_input:
@ -103,7 +103,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
), ),
) )
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: async def async_step_reauth(
self, entry_data: Mapping[str, Any]
) -> ConfigFlowResult:
"""Handle initiation of re-authentication with Prosegur.""" """Handle initiation of re-authentication with Prosegur."""
self.entry = cast( self.entry = cast(
ConfigEntry, ConfigEntry,
@ -155,9 +157,9 @@ class ConfigFlow(config_entries.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

@ -8,10 +8,14 @@ import voluptuous as vol
from homeassistant.components.device_tracker import DOMAIN as DEVICE_TRACKER_DOMAIN from homeassistant.components.device_tracker import DOMAIN as DEVICE_TRACKER_DOMAIN
from homeassistant.components.person import DOMAIN as PERSON_DOMAIN from homeassistant.components.person import DOMAIN as PERSON_DOMAIN
from homeassistant.components.zone import DOMAIN as ZONE_DOMAIN from homeassistant.components.zone import DOMAIN as ZONE_DOMAIN
from homeassistant.config_entries import ConfigEntry, ConfigFlow, OptionsFlow from homeassistant.config_entries import (
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.const import CONF_ZONE from homeassistant.const import CONF_ZONE
from homeassistant.core import State, callback from homeassistant.core import State, callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.selector import ( from homeassistant.helpers.selector import (
EntitySelector, EntitySelector,
EntitySelectorConfig, EntitySelectorConfig,
@ -85,7 +89,7 @@ class ProximityConfigFlow(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:
self._async_abort_entries_match(user_input) self._async_abort_entries_match(user_input)
@ -111,7 +115,7 @@ class ProximityConfigFlow(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:
"""Import a yaml config entry.""" """Import a yaml config entry."""
return await self.async_step_user(user_input) return await self.async_step_user(user_input)
@ -128,7 +132,7 @@ class ProximityOptionsFlow(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:
"""Handle options flow.""" """Handle options flow."""
if user_input is not None: if user_input is not None:
self.hass.config_entries.async_update_entry( self.hass.config_entries.async_update_entry(

View file

@ -11,10 +11,9 @@ from pyprusalink import PrusaLink
from pyprusalink.types import InvalidAuth from pyprusalink.types import InvalidAuth
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_USERNAME from homeassistant.const import CONF_HOST, 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
@ -63,7 +62,7 @@ async def validate_input(hass: HomeAssistant, data: dict[str, str]) -> dict[str,
return {"title": version["hostname"] or version["text"]} return {"title": version["hostname"] or version["text"]}
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class PrusaLinkConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for PrusaLink.""" """Handle a config flow for PrusaLink."""
VERSION = 1 VERSION = 1
@ -71,7 +70,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

@ -6,7 +6,7 @@ from pyps4_2ndscreen.helpers import Helper
from pyps4_2ndscreen.media_art import COUNTRIES from pyps4_2ndscreen.media_art import COUNTRIES
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries from homeassistant.config_entries import ConfigFlow
from homeassistant.const import ( from homeassistant.const import (
CONF_CODE, CONF_CODE,
CONF_HOST, CONF_HOST,
@ -38,7 +38,7 @@ PORT_MSG = {UDP_PORT: "port_987_bind_error", TCP_PORT: "port_997_bind_error"}
PIN_LENGTH = 8 PIN_LENGTH = 8
class PlayStation4FlowHandler(config_entries.ConfigFlow, domain=DOMAIN): class PlayStation4FlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a PlayStation 4 config flow.""" """Handle a PlayStation 4 config flow."""
VERSION = CONFIG_ENTRY_VERSION VERSION = CONFIG_ENTRY_VERSION

View file

@ -7,9 +7,8 @@ from gridnet import Device, GridNet, GridNetConnectionError
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 homeassistant.helpers.selector import TextSelector from homeassistant.helpers.selector import TextSelector
@ -25,7 +24,7 @@ class PureEnergieFlowHandler(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 = {}
@ -59,7 +58,7 @@ class PureEnergieFlowHandler(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.discovered_host = discovery_info.host self.discovered_host = discovery_info.host
try: try:
@ -83,7 +82,7 @@ class PureEnergieFlowHandler(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:
return self.async_create_entry( return self.async_create_entry(

View file

@ -12,8 +12,12 @@ from aiopurpleair.endpoints.sensors import NearbySensorResult
from aiopurpleair.errors import InvalidApiKeyError, PurpleAirError from aiopurpleair.errors import InvalidApiKeyError, PurpleAirError
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries from homeassistant.config_entries import (
from homeassistant.config_entries import ConfigEntry ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.const import ( from homeassistant.const import (
CONF_API_KEY, CONF_API_KEY,
CONF_LATITUDE, CONF_LATITUDE,
@ -21,7 +25,6 @@ from homeassistant.const import (
CONF_SHOW_ON_MAP, CONF_SHOW_ON_MAP,
) )
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import ( from homeassistant.helpers import (
aiohttp_client, aiohttp_client,
config_validation as cv, config_validation as cv,
@ -193,7 +196,7 @@ async def async_validate_coordinates(
return ValidationResult(data=nearby_sensor_results) return ValidationResult(data=nearby_sensor_results)
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class PurpleAirConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for PurpleAir.""" """Handle a config flow for PurpleAir."""
VERSION = 1 VERSION = 1
@ -213,7 +216,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_by_coordinates( async def async_step_by_coordinates(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle the discovery of sensors near a latitude/longitude.""" """Handle the discovery of sensors near a latitude/longitude."""
if user_input is None: if user_input is None:
return self.async_show_form( return self.async_show_form(
@ -243,7 +246,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_choose_sensor( async def async_step_choose_sensor(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle the selection of a sensor.""" """Handle the selection of a sensor."""
if user_input is None: if user_input is None:
options = self._flow_data.pop(CONF_NEARBY_SENSOR_OPTIONS) options = self._flow_data.pop(CONF_NEARBY_SENSOR_OPTIONS)
@ -260,7 +263,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
options={CONF_SENSOR_INDICES: [int(user_input[CONF_SENSOR_INDEX])]}, options={CONF_SENSOR_INDICES: [int(user_input[CONF_SENSOR_INDEX])]},
) )
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"]
@ -269,7 +274,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 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(
@ -298,7 +303,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(step_id="user", data_schema=API_KEY_SCHEMA) return self.async_show_form(step_id="user", data_schema=API_KEY_SCHEMA)
@ -319,7 +324,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
return await self.async_step_by_coordinates() return await self.async_step_by_coordinates()
class PurpleAirOptionsFlowHandler(config_entries.OptionsFlow): class PurpleAirOptionsFlowHandler(OptionsFlow):
"""Handle a PurpleAir options flow.""" """Handle a PurpleAir options flow."""
def __init__(self, config_entry: ConfigEntry) -> None: def __init__(self, config_entry: ConfigEntry) -> None:
@ -345,7 +350,7 @@ class PurpleAirOptionsFlowHandler(config_entries.OptionsFlow):
async def async_step_add_sensor( async def async_step_add_sensor(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Add a sensor.""" """Add a sensor."""
if user_input is None: if user_input is None:
return self.async_show_form( return self.async_show_form(
@ -376,7 +381,7 @@ class PurpleAirOptionsFlowHandler(config_entries.OptionsFlow):
async def async_step_choose_sensor( async def async_step_choose_sensor(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Choose a sensor.""" """Choose a sensor."""
if user_input is None: if user_input is None:
options = self._flow_data.pop(CONF_NEARBY_SENSOR_OPTIONS) options = self._flow_data.pop(CONF_NEARBY_SENSOR_OPTIONS)
@ -396,7 +401,7 @@ class PurpleAirOptionsFlowHandler(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."""
return self.async_show_menu( return self.async_show_menu(
step_id="init", step_id="init",
@ -405,7 +410,7 @@ class PurpleAirOptionsFlowHandler(config_entries.OptionsFlow):
async def async_step_remove_sensor( async def async_step_remove_sensor(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Remove a sensor.""" """Remove a sensor."""
if user_input is None: if user_input is None:
return self.async_show_form( return self.async_show_form(
@ -467,7 +472,7 @@ class PurpleAirOptionsFlowHandler(config_entries.OptionsFlow):
async def async_step_settings( async def async_step_settings(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Manage settings.""" """Manage settings."""
if user_input is None: if user_input is None:
return self.async_show_form( return self.async_show_form(

View file

@ -6,9 +6,8 @@ from typing import Any
from pushbullet import InvalidKeyError, PushBullet, PushbulletError from pushbullet import InvalidKeyError, PushBullet, PushbulletError
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_NAME from homeassistant.const import CONF_API_KEY, CONF_NAME
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import selector from homeassistant.helpers import selector
from .const import DEFAULT_NAME, DOMAIN from .const import DEFAULT_NAME, DOMAIN
@ -21,12 +20,12 @@ CONFIG_SCHEMA = vol.Schema(
) )
class PushBulletConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class PushBulletConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for pushbullet integration.""" """Handle a config flow for pushbullet integration."""
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

@ -7,10 +7,9 @@ from typing import Any
from pushover_complete import BadAPIRequestError, PushoverAPI from pushover_complete import BadAPIRequestError, PushoverAPI
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_NAME from homeassistant.const import CONF_API_KEY, CONF_NAME
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResult
from .const import CONF_USER_KEY, DEFAULT_NAME, DOMAIN from .const import CONF_USER_KEY, DEFAULT_NAME, DOMAIN
@ -39,12 +38,14 @@ async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> dict[str,
return errors return errors
class PushBulletConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class PushBulletConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for pushover integration.""" """Handle a config flow for pushover integration."""
_reauth_entry: config_entries.ConfigEntry | None _reauth_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:
"""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"]
@ -53,7 +54,7 @@ class PushBulletConfigFlow(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 = {}
if user_input is not None and self._reauth_entry: if user_input is not None and self._reauth_entry:
@ -84,7 +85,7 @@ class PushBulletConfigFlow(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

@ -7,10 +7,9 @@ from typing import Any
from pvo import PVOutput, PVOutputAuthenticationError, PVOutputError from pvo import PVOutput, PVOutputAuthenticationError, PVOutputError
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_API_KEY from homeassistant.const import CONF_API_KEY
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_SYSTEM_ID, DOMAIN, LOGGER from .const import CONF_SYSTEM_ID, DOMAIN, LOGGER
@ -37,7 +36,7 @@ class PVOutputFlowHandler(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 = {}
@ -84,7 +83,9 @@ class PVOutputFlowHandler(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 initiation of re-authentication with PVOutput.""" """Handle initiation of re-authentication with PVOutput."""
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"]
@ -93,7 +94,7 @@ class PVOutputFlowHandler(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 re-authentication with PVOutput.""" """Handle re-authentication with PVOutput."""
errors = {} errors = {}

View file

@ -7,10 +7,14 @@ from typing import Any
from aiopvpc import DEFAULT_POWER_KW, PVPCData from aiopvpc import DEFAULT_POWER_KW, PVPCData
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries from homeassistant.config_entries import (
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlowWithConfigEntry,
)
from homeassistant.const import CONF_API_TOKEN, CONF_NAME from homeassistant.const import CONF_API_TOKEN, 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
from homeassistant.util import dt as dt_util from homeassistant.util import dt as dt_util
@ -32,7 +36,7 @@ _MAIL_TO_LINK = (
) )
class TariffSelectorConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class TariffSelectorConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle config flow for `pvpc_hourly_pricing`.""" """Handle config flow for `pvpc_hourly_pricing`."""
VERSION = 1 VERSION = 1
@ -43,19 +47,19 @@ class TariffSelectorConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
_use_api_token: bool = False _use_api_token: bool = False
_api_token: str | None = None _api_token: str | None = None
_api: PVPCData | None = None _api: PVPCData | None = None
_reauth_entry: config_entries.ConfigEntry | None = None _reauth_entry: ConfigEntry | None = None
@staticmethod @staticmethod
@callback @callback
def async_get_options_flow( def async_get_options_flow(
config_entry: config_entries.ConfigEntry, config_entry: ConfigEntry,
) -> PVPCOptionsFlowHandler: ) -> PVPCOptionsFlowHandler:
"""Get the options flow for this handler.""" """Get the options flow for this handler."""
return PVPCOptionsFlowHandler(config_entry) return PVPCOptionsFlowHandler(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."""
if user_input is not None: if user_input is not None:
await self.async_set_unique_id(user_input[ATTR_TARIFF]) await self.async_set_unique_id(user_input[ATTR_TARIFF])
@ -92,7 +96,7 @@ class TariffSelectorConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_api_token( async def async_step_api_token(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle optional step to define API token for extra sensors.""" """Handle optional step to define API token for extra sensors."""
if user_input is not None: if user_input is not None:
self._api_token = user_input[CONF_API_TOKEN] self._api_token = user_input[CONF_API_TOKEN]
@ -110,7 +114,9 @@ class TariffSelectorConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
description_placeholders={"mail_to_link": _MAIL_TO_LINK}, description_placeholders={"mail_to_link": _MAIL_TO_LINK},
) )
async def _async_verify(self, step_id: str, data_schema: vol.Schema) -> FlowResult: async def _async_verify(
self, step_id: str, data_schema: vol.Schema
) -> ConfigFlowResult:
"""Attempt to verify the provided configuration.""" """Attempt to verify the provided configuration."""
errors: dict[str, str] = {} errors: dict[str, str] = {}
auth_ok = True auth_ok = True
@ -144,7 +150,9 @@ class TariffSelectorConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
assert self._name is not None assert self._name is not None
return self.async_create_entry(title=self._name, data=data) return self.async_create_entry(title=self._name, data=data)
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 ESIOS Token.""" """Handle re-authentication with ESIOS Token."""
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"]
@ -159,7 +167,7 @@ class TariffSelectorConfigFlow(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 reauth dialog.""" """Confirm reauth dialog."""
data_schema = vol.Schema( data_schema = vol.Schema(
{ {
@ -174,7 +182,7 @@ class TariffSelectorConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
return self.async_show_form(step_id="reauth_confirm", data_schema=data_schema) return self.async_show_form(step_id="reauth_confirm", data_schema=data_schema)
class PVPCOptionsFlowHandler(config_entries.OptionsFlowWithConfigEntry): class PVPCOptionsFlowHandler(OptionsFlowWithConfigEntry):
"""Handle PVPC options.""" """Handle PVPC options."""
_power: float | None = None _power: float | None = None
@ -182,7 +190,7 @@ class PVPCOptionsFlowHandler(config_entries.OptionsFlowWithConfigEntry):
async def async_step_api_token( async def async_step_api_token(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle optional step to define API token for extra sensors.""" """Handle optional step to define API token for extra sensors."""
if user_input is not None and user_input.get(CONF_API_TOKEN): if user_input is not None and user_input.get(CONF_API_TOKEN):
return self.async_create_entry( return self.async_create_entry(
@ -208,7 +216,7 @@ class PVPCOptionsFlowHandler(config_entries.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:
if user_input[CONF_USE_API_TOKEN]: if user_input[CONF_USE_API_TOKEN]:

View file

@ -8,9 +8,8 @@ from qbittorrent.client import LoginRequired
from requests.exceptions import RequestException from requests.exceptions import RequestException
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_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 .const import DEFAULT_NAME, DEFAULT_URL, DOMAIN from .const import DEFAULT_NAME, DEFAULT_URL, DOMAIN
from .helpers import setup_client from .helpers import setup_client
@ -32,7 +31,7 @@ class QbittorrentConfigFlow(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 user-initiated config flow.""" """Handle a user-initiated config flow."""
errors = {} errors = {}

View file

@ -12,9 +12,8 @@ from homeassistant.components.bluetooth import (
async_discovered_service_info, async_discovered_service_info,
async_process_advertisements, async_process_advertisements,
) )
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
@ -52,7 +51,7 @@ class QingpingConfigFlow(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()
@ -69,7 +68,7 @@ class QingpingConfigFlow(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
@ -88,7 +87,7 @@ class QingpingConfigFlow(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,7 +8,7 @@ from qnapstats import QNAPStats
from requests.exceptions import ConnectTimeout from requests.exceptions import ConnectTimeout
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_HOST, CONF_HOST,
CONF_PASSWORD, CONF_PASSWORD,
@ -17,7 +17,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 import config_validation as cv from homeassistant.helpers import config_validation as cv
from .const import ( from .const import (
@ -42,7 +41,7 @@ DATA_SCHEMA = vol.Schema(
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
class QnapConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class QnapConfigFlow(ConfigFlow, domain=DOMAIN):
"""Qnap configuration flow.""" """Qnap configuration flow."""
VERSION = 1 VERSION = 1
@ -50,7 +49,7 @@ class QnapConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, self,
user_input: dict[str, Any] | None = None, 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:

View file

@ -8,10 +8,10 @@ from aioqsw.exceptions import LoginError, QswError
from aioqsw.localapi import ConnectionOptions, QnapQswApi from aioqsw.localapi import ConnectionOptions, QnapQswApi
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_PASSWORD, CONF_URL, CONF_USERNAME from homeassistant.const import CONF_PASSWORD, CONF_URL, CONF_USERNAME
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
@ -20,7 +20,7 @@ from .const import DOMAIN
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class QNapQSWConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle config flow for a QNAP QSW device.""" """Handle config flow for a QNAP QSW device."""
_discovered_mac: str | None = None _discovered_mac: str | None = None
@ -28,7 +28,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 = {}
@ -71,7 +71,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_url = f"http://{discovery_info.ip}" self._discovered_url = f"http://{discovery_info.ip}"
self._discovered_mac = discovery_info.macaddress self._discovered_mac = discovery_info.macaddress
@ -97,7 +99,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."""
errors = {} errors = {}
assert self._discovered_url is not None assert self._discovered_url is not None

View file

@ -11,7 +11,6 @@ from homeassistant import config_entries
from homeassistant.components import zeroconf from homeassistant.components import zeroconf
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_HOST, CONF_MAC from homeassistant.const import CONF_ACCESS_TOKEN, CONF_HOST, CONF_MAC
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 device_registry as dr from homeassistant.helpers import device_registry as dr
@ -58,7 +57,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 = {} errors = {}
@ -100,7 +99,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: ) -> config_entries.ConfigFlowResult:
"""Handle zeroconf discovery.""" """Handle zeroconf discovery."""
mac = dr.format_mac(discovery_info.properties["id"]) mac = dr.format_mac(discovery_info.properties["id"])
await self.async_set_unique_id(mac) await self.async_set_unique_id(mac)

View file

@ -8,11 +8,16 @@ from rachiopy import Rachio
from requests.exceptions import ConnectTimeout from requests.exceptions import ConnectTimeout
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries, core, exceptions
from homeassistant.components import zeroconf from homeassistant.components import zeroconf
from homeassistant.config_entries import (
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.const import CONF_API_KEY from homeassistant.const import CONF_API_KEY
from homeassistant.core import callback from homeassistant.core import HomeAssistant, callback
from homeassistant.data_entry_flow import FlowResult from homeassistant.exceptions import HomeAssistantError
from .const import ( from .const import (
CONF_MANUAL_RUN_MINS, CONF_MANUAL_RUN_MINS,
@ -28,7 +33,7 @@ _LOGGER = logging.getLogger(__name__)
DATA_SCHEMA = vol.Schema({vol.Required(CONF_API_KEY): str}, extra=vol.ALLOW_EXTRA) DATA_SCHEMA = vol.Schema({vol.Required(CONF_API_KEY): str}, extra=vol.ALLOW_EXTRA)
async def validate_input(hass: core.HomeAssistant, data): async def validate_input(hass: HomeAssistant, data):
"""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,7 +61,7 @@ async def validate_input(hass: core.HomeAssistant, data):
return {"title": username} return {"title": username}
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class RachioConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Rachio.""" """Handle a config flow for Rachio."""
VERSION = 1 VERSION = 1
@ -84,7 +89,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_homekit( async def async_step_homekit(
self, discovery_info: zeroconf.ZeroconfServiceInfo self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle HomeKit discovery.""" """Handle HomeKit discovery."""
self._async_abort_entries_match() self._async_abort_entries_match()
await self.async_set_unique_id( await self.async_set_unique_id(
@ -96,16 +101,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 Rachio.""" """Handle a option flow for Rachio."""
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
@ -127,9 +132,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

@ -10,10 +10,9 @@ from aiopyarr.models.host_configuration import PyArrHostConfiguration
from aiopyarr.radarr_client import RadarrClient from aiopyarr.radarr_client import RadarrClient
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_API_KEY, CONF_URL, CONF_VERIFY_SSL from homeassistant.const import CONF_API_KEY, CONF_URL, CONF_VERIFY_SSL
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_URL, DOMAIN from .const import DEFAULT_NAME, DEFAULT_URL, DOMAIN
@ -28,7 +27,7 @@ class RadarrConfigFlow(ConfigFlow, domain=DOMAIN):
"""Initialize the flow.""" """Initialize the flow."""
self.entry: ConfigEntry | None = None self.entry: ConfigEntry | None = None
async def async_step_reauth(self, _: Mapping[str, Any]) -> FlowResult: async def async_step_reauth(self, _: 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"])
@ -36,7 +35,7 @@ class RadarrConfigFlow(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."""
if user_input is not None: if user_input is not None:
return await self.async_step_user() return await self.async_step_user()
@ -46,7 +45,7 @@ class RadarrConfigFlow(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 = {}

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 RadioBrowserConfigFlow(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 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,6 +27,6 @@ class RadioBrowserConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_onboarding( async def async_step_onboarding(
self, data: dict[str, Any] | None = None self, data: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle a flow initialized by onboarding.""" """Handle a flow initialized by onboarding."""
return self.async_create_entry(title="Radio Browser", data={}) return self.async_create_entry(title="Radio Browser", data={})

View file

@ -8,11 +8,10 @@ from urllib.error import URLError
from radiotherm.validate import RadiothermTstatError from radiotherm.validate import RadiothermTstatError
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 from homeassistant.const import CONF_HOST
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 .const import DOMAIN from .const import DOMAIN
@ -33,7 +32,7 @@ async def validate_connection(hass: HomeAssistant, host: str) -> RadioThermInitD
raise CannotConnect(f"Failed to connect to {host}: {ex}") from ex raise CannotConnect(f"Failed to connect to {host}: {ex}") from ex
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class RadioThermConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Radio Thermostat.""" """Handle a config flow for Radio Thermostat."""
VERSION = 1 VERSION = 1
@ -43,7 +42,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
self.discovered_ip: str | None = None self.discovered_ip: str | None = None
self.discovered_init_data: RadioThermInitData | None = None self.discovered_init_data: RadioThermInitData | None = None
async def async_step_dhcp(self, discovery_info: dhcp.DhcpServiceInfo) -> FlowResult: async def async_step_dhcp(
self, discovery_info: dhcp.DhcpServiceInfo
) -> ConfigFlowResult:
"""Discover via DHCP.""" """Discover via DHCP."""
self._async_abort_entries_match({CONF_HOST: discovery_info.ip}) self._async_abort_entries_match({CONF_HOST: discovery_info.ip})
try: try:
@ -84,7 +85,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,11 +14,14 @@ from pyrainbird.async_client import (
from pyrainbird.data import WifiParams from pyrainbird.data import WifiParams
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries from homeassistant.config_entries import (
from homeassistant.config_entries import ConfigEntry ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.const import CONF_HOST, CONF_MAC, CONF_PASSWORD from homeassistant.const import CONF_HOST, CONF_MAC, CONF_PASSWORD
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, selector from homeassistant.helpers import config_validation as cv, selector
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
@ -53,7 +56,7 @@ class ConfigFlowError(Exception):
self.error_code = error_code self.error_code = error_code
class RainbirdConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): class RainbirdConfigFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Rain Bird.""" """Handle a config flow for Rain Bird."""
@staticmethod @staticmethod
@ -66,7 +69,7 @@ class RainbirdConfigFlowHandler(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:
"""Configure the Rain Bird device.""" """Configure the Rain Bird device."""
error_code: str | None = None error_code: str | None = None
if user_input: if user_input:
@ -129,7 +132,7 @@ class RainbirdConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
self, self,
data: dict[str, Any], data: dict[str, Any],
options: dict[str, Any], options: dict[str, Any],
) -> FlowResult: ) -> ConfigFlowResult:
"""Create the config entry.""" """Create the config entry."""
# The integration has historically used a serial number, but not all devices # The integration has historically used a serial number, but not all devices
# historically had a valid one. Now the mac address is used as a unique id # historically had a valid one. Now the mac address is used as a unique id
@ -156,7 +159,7 @@ class RainbirdConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
) )
class RainBirdOptionsFlowHandler(config_entries.OptionsFlow): class RainBirdOptionsFlowHandler(OptionsFlow):
"""Handle a RainBird options flow.""" """Handle a RainBird options flow."""
def __init__(self, config_entry: ConfigEntry) -> None: def __init__(self, config_entry: ConfigEntry) -> None:
@ -165,7 +168,7 @@ class RainBirdOptionsFlowHandler(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:
return self.async_create_entry(data=user_input) return self.async_create_entry(data=user_input)

View file

@ -6,9 +6,8 @@ from typing import Any
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_TYPE from homeassistant.const import CONF_HOST, CONF_TYPE
from homeassistant.data_entry_flow import FlowResult
from . import data from . import data
from .const import CONF_CLOUD_ID, CONF_HARDWARE_ADDRESS, CONF_INSTALL_CODE, DOMAIN from .const import CONF_CLOUD_ID, CONF_HARDWARE_ADDRESS, CONF_INSTALL_CODE, DOMAIN
@ -31,14 +30,14 @@ def create_schema(user_input: dict[str, Any] | None) -> vol.Schema:
) )
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class RainforestEagleConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Rainforest Eagle.""" """Handle a config flow for Rainforest Eagle."""
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,10 +11,9 @@ import serial.tools.list_ports
from serial.tools.list_ports_common import ListPortInfo from serial.tools.list_ports_common import ListPortInfo
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import usb from homeassistant.components import usb
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_DEVICE, CONF_MAC, CONF_NAME from homeassistant.const import CONF_DEVICE, CONF_MAC, CONF_NAME
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.selector import ( from homeassistant.helpers.selector import (
SelectSelector, SelectSelector,
SelectSelectorConfig, SelectSelectorConfig,
@ -38,7 +37,7 @@ def _generate_unique_id(info: ListPortInfo | usb.UsbServiceInfo) -> str:
) )
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class RainforestRavenConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Rainforest RAVEn devices.""" """Handle a config flow for Rainforest RAVEn devices."""
def __init__(self) -> None: def __init__(self) -> None:
@ -66,7 +65,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_meters( async def async_step_meters(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Connect to device and discover meters.""" """Connect to device and discover meters."""
errors: dict[str, str] = {} errors: dict[str, str] = {}
if user_input is not None: if user_input is not None:
@ -98,7 +97,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
) )
return self.async_show_form(step_id="meters", data_schema=schema, errors=errors) return self.async_show_form(step_id="meters", data_schema=schema, errors=errors)
async def async_step_usb(self, discovery_info: usb.UsbServiceInfo) -> FlowResult: async def async_step_usb(
self, discovery_info: usb.UsbServiceInfo
) -> ConfigFlowResult:
"""Handle USB Discovery.""" """Handle USB Discovery."""
device = discovery_info.device device = discovery_info.device
dev_path = await self.hass.async_add_executor_job(usb.get_serial_by_id, device) dev_path = await self.hass.async_add_executor_job(usb.get_serial_by_id, device)
@ -114,7 +115,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 initiated by the user.""" """Handle a flow initiated by the user."""
if self._async_in_progress(): if self._async_in_progress():
return self.async_abort(reason="already_in_progress") return self.async_abort(reason="already_in_progress")

View file

@ -8,12 +8,15 @@ from regenmaschine.controller import Controller
from regenmaschine.errors import RainMachineError from regenmaschine.errors import RainMachineError
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,
OptionsFlow,
)
from homeassistant.const import CONF_IP_ADDRESS, CONF_PASSWORD, CONF_PORT, CONF_SSL from homeassistant.const import CONF_IP_ADDRESS, CONF_PASSWORD, CONF_PORT, CONF_SSL
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, config_validation as cv from homeassistant.helpers import aiohttp_client, config_validation as cv
from .const import ( from .const import (
@ -46,7 +49,7 @@ async def async_get_controller(
return get_client_controller(client) return get_client_controller(client)
class RainMachineFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): class RainMachineFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a RainMachine config flow.""" """Handle a RainMachine config flow."""
VERSION = 2 VERSION = 2
@ -63,19 +66,19 @@ class RainMachineFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_homekit( async def async_step_homekit(
self, discovery_info: zeroconf.ZeroconfServiceInfo self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle a flow initialized by homekit discovery.""" """Handle a flow initialized by homekit discovery."""
return await self.async_step_homekit_zeroconf(discovery_info) return await self.async_step_homekit_zeroconf(discovery_info)
async def async_step_zeroconf( async def async_step_zeroconf(
self, discovery_info: zeroconf.ZeroconfServiceInfo self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle discovery via zeroconf.""" """Handle discovery via zeroconf."""
return await self.async_step_homekit_zeroconf(discovery_info) return await self.async_step_homekit_zeroconf(discovery_info)
async def async_step_homekit_zeroconf( async def async_step_homekit_zeroconf(
self, discovery_info: zeroconf.ZeroconfServiceInfo self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle discovery via zeroconf.""" """Handle discovery via zeroconf."""
ip_address = discovery_info.host ip_address = discovery_info.host
@ -117,7 +120,7 @@ class RainMachineFlowHandler(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 start of the config flow.""" """Handle the start of the config flow."""
errors = {} errors = {}
if user_input: if user_input:
@ -161,7 +164,7 @@ class RainMachineFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
) )
class RainMachineOptionsFlowHandler(config_entries.OptionsFlow): class RainMachineOptionsFlowHandler(OptionsFlow):
"""Handle a RainMachine options flow.""" """Handle a RainMachine options flow."""
def __init__(self, config_entry: ConfigEntry) -> None: def __init__(self, config_entry: ConfigEntry) -> None:
@ -170,7 +173,7 @@ class RainMachineOptionsFlowHandler(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:
return self.async_create_entry(data=user_input) return self.async_create_entry(data=user_input)

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

@ -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
@ -14,7 +13,9 @@ class RaspberryPiConfigFlow(ConfigFlow, domain=DOMAIN):
VERSION = 1 VERSION = 1
async def async_step_system(self, data: dict[str, Any] | None = None) -> FlowResult: async def async_step_system(
self, data: dict[str, Any] | None = None
) -> ConfigFlowResult:
"""Handle the initial step.""" """Handle the initial 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

@ -6,8 +6,7 @@ from typing import Any
from vehicle import RDW, RDWError, RDWUnknownLicensePlateError from vehicle import RDW, RDWError, RDWUnknownLicensePlateError
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 homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import CONF_LICENSE_PLATE, DOMAIN from .const import CONF_LICENSE_PLATE, DOMAIN
@ -20,7 +19,7 @@ class RDWFlowHandler(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 = {}

View file

@ -7,10 +7,14 @@ from aiorecollect.client import Client
from aiorecollect.errors import RecollectError from aiorecollect.errors import RecollectError
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_FRIENDLY_NAME from homeassistant.const import CONF_FRIENDLY_NAME
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import aiohttp_client from homeassistant.helpers import aiohttp_client
from .const import CONF_PLACE_ID, CONF_SERVICE_ID, DOMAIN, LOGGER from .const import CONF_PLACE_ID, CONF_SERVICE_ID, DOMAIN, LOGGER
@ -20,7 +24,7 @@ DATA_SCHEMA = vol.Schema(
) )
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class RecollectWasteConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for ReCollect Waste.""" """Handle a config flow for ReCollect Waste."""
VERSION = 2 VERSION = 2
@ -28,14 +32,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,
) -> config_entries.OptionsFlow: ) -> OptionsFlow:
"""Define the config flow to handle options.""" """Define the config flow to handle options."""
return RecollectWasteOptionsFlowHandler(config_entry) return RecollectWasteOptionsFlowHandler(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 configuration via the UI.""" """Handle configuration via the UI."""
if user_input is None: if user_input is None:
return self.async_show_form( return self.async_show_form(
@ -71,16 +75,16 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
) )
class RecollectWasteOptionsFlowHandler(config_entries.OptionsFlow): class RecollectWasteOptionsFlowHandler(OptionsFlow):
"""Handle a Recollect Waste options flow.""" """Handle a Recollect Waste options flow."""
def __init__(self, entry: config_entries.ConfigEntry) -> None: def __init__(self, entry: ConfigEntry) -> None:
"""Initialize.""" """Initialize."""
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."""
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

@ -7,15 +7,14 @@ from typing import TYPE_CHECKING, Any
from renault_api.const import AVAILABLE_LOCALES from renault_api.const import AVAILABLE_LOCALES
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_KAMEREON_ACCOUNT_ID, CONF_LOCALE, DOMAIN from .const import CONF_KAMEREON_ACCOUNT_ID, CONF_LOCALE, DOMAIN
from .renault_hub import RenaultHub from .renault_hub import RenaultHub
class RenaultFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): class RenaultFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a Renault config flow.""" """Handle a Renault config flow."""
VERSION = 1 VERSION = 1
@ -28,7 +27,7 @@ class RenaultFlowHandler(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 Renault config flow start. """Handle a Renault config flow start.
Ask the user for API keys. Ask the user for API keys.
@ -45,7 +44,7 @@ class RenaultFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
return await self.async_step_kamereon() return await self.async_step_kamereon()
return self._show_user_form() return self._show_user_form()
def _show_user_form(self, errors: dict[str, Any] | None = None) -> FlowResult: def _show_user_form(self, errors: dict[str, Any] | None = None) -> ConfigFlowResult:
"""Show the API keys form.""" """Show the API keys form."""
return self.async_show_form( return self.async_show_form(
step_id="user", step_id="user",
@ -61,7 +60,7 @@ class RenaultFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_kamereon( async def async_step_kamereon(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Select Kamereon account.""" """Select Kamereon account."""
if user_input: if user_input:
await self.async_set_unique_id(user_input[CONF_KAMEREON_ACCOUNT_ID]) await self.async_set_unique_id(user_input[CONF_KAMEREON_ACCOUNT_ID])
@ -93,14 +92,16 @@ class RenaultFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
), ),
) )
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: async def async_step_reauth(
self, entry_data: Mapping[str, Any]
) -> ConfigFlowResult:
"""Perform reauth upon an API authentication error.""" """Perform reauth upon an API authentication error."""
self._original_data = entry_data self._original_data = entry_data
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 not user_input: if not user_input:
return self._show_reauth_confirm_form() return self._show_reauth_confirm_form()
@ -128,7 +129,7 @@ class RenaultFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
def _show_reauth_confirm_form( def _show_reauth_confirm_form(
self, errors: dict[str, Any] | None = None self, errors: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Show the API keys form.""" """Show the API keys form."""
if TYPE_CHECKING: if TYPE_CHECKING:
assert self._original_data assert self._original_data

View file

@ -7,10 +7,9 @@ from typing import Any
from renson_endura_delta import renson from renson_endura_delta import renson
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 from homeassistant.const import CONF_HOST
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 .const import DOMAIN from .const import DOMAIN
@ -24,7 +23,7 @@ STEP_USER_DATA_SCHEMA = vol.Schema(
) )
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class RensonConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Renson.""" """Handle a config flow for Renson."""
VERSION = 1 VERSION = 1
@ -42,7 +41,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

@ -8,8 +8,13 @@ from typing import Any
from reolink_aio.exceptions import ApiError, CredentialsInvalidError, ReolinkError from reolink_aio.exceptions import ApiError, CredentialsInvalidError, ReolinkError
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 (
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.const import ( from homeassistant.const import (
CONF_HOST, CONF_HOST,
CONF_PASSWORD, CONF_PASSWORD,
@ -18,7 +23,7 @@ from homeassistant.const import (
CONF_USERNAME, CONF_USERNAME,
) )
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.data_entry_flow import AbortFlow, FlowResult from homeassistant.data_entry_flow import AbortFlow
from homeassistant.helpers import config_validation as cv from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.device_registry import format_mac from homeassistant.helpers.device_registry import format_mac
@ -33,7 +38,7 @@ DEFAULT_PROTOCOL = "rtsp"
DEFAULT_OPTIONS = {CONF_PROTOCOL: DEFAULT_PROTOCOL} DEFAULT_OPTIONS = {CONF_PROTOCOL: DEFAULT_PROTOCOL}
class ReolinkOptionsFlowHandler(config_entries.OptionsFlow): class ReolinkOptionsFlowHandler(OptionsFlow):
"""Handle Reolink options.""" """Handle Reolink options."""
def __init__(self, config_entry): def __init__(self, config_entry):
@ -42,7 +47,7 @@ class ReolinkOptionsFlowHandler(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 Reolink options.""" """Manage the Reolink 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)
@ -60,7 +65,7 @@ class ReolinkOptionsFlowHandler(config_entries.OptionsFlow):
) )
class ReolinkFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): class ReolinkFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Reolink device.""" """Handle a config flow for Reolink device."""
VERSION = 1 VERSION = 1
@ -75,12 +80,14 @@ class ReolinkFlowHandler(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,
) -> ReolinkOptionsFlowHandler: ) -> ReolinkOptionsFlowHandler:
"""Options callback for Reolink.""" """Options callback for Reolink."""
return ReolinkOptionsFlowHandler(config_entry) return ReolinkOptionsFlowHandler(config_entry)
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: async def async_step_reauth(
self, entry_data: Mapping[str, Any]
) -> ConfigFlowResult:
"""Perform reauth upon an authentication error or no admin privileges.""" """Perform reauth upon an authentication error or no admin privileges."""
self._host = entry_data[CONF_HOST] self._host = entry_data[CONF_HOST]
self._username = entry_data[CONF_USERNAME] self._username = entry_data[CONF_USERNAME]
@ -94,13 +101,15 @@ class ReolinkFlowHandler(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:
"""Dialog that informs the user that reauth is required.""" """Dialog that informs the user that reauth is required."""
if user_input is not None: if user_input is not None:
return await self.async_step_user() return await self.async_step_user()
return self.async_show_form(step_id="reauth_confirm") return self.async_show_form(step_id="reauth_confirm")
async def async_step_dhcp(self, discovery_info: dhcp.DhcpServiceInfo) -> FlowResult: async def async_step_dhcp(
self, discovery_info: dhcp.DhcpServiceInfo
) -> ConfigFlowResult:
"""Handle discovery via dhcp.""" """Handle discovery via dhcp."""
mac_address = format_mac(discovery_info.macaddress) mac_address = format_mac(discovery_info.macaddress)
existing_entry = await self.async_set_unique_id(mac_address) existing_entry = await self.async_set_unique_id(mac_address)
@ -157,7 +166,7 @@ class ReolinkFlowHandler(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 = {}
placeholders = { placeholders = {

View file

@ -7,7 +7,7 @@ from homeassistant import data_entry_flow
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
class RepairsFlow(data_entry_flow.BaseFlowHandler[data_entry_flow.FlowResult]): class RepairsFlow(data_entry_flow.FlowHandler):
"""Handle a flow for fixing an issue.""" """Handle a flow for fixing an issue."""
_flow_result = data_entry_flow.FlowResult _flow_result = data_entry_flow.FlowResult

View file

@ -13,8 +13,12 @@ import serial
import serial.tools.list_ports import serial.tools.list_ports
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries, data_entry_flow, exceptions from homeassistant.config_entries import (
from homeassistant.config_entries import ConfigEntry ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
)
from homeassistant.const import ( from homeassistant.const import (
CONF_COMMAND_OFF, CONF_COMMAND_OFF,
CONF_COMMAND_ON, CONF_COMMAND_ON,
@ -26,6 +30,7 @@ from homeassistant.const import (
CONF_TYPE, CONF_TYPE,
) )
from homeassistant.core import State, callback from homeassistant.core import State, callback
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import ( from homeassistant.helpers import (
config_validation as cv, config_validation as cv,
device_registry as dr, device_registry as dr,
@ -74,7 +79,7 @@ def none_or_int(value: str | None, base: int) -> int | None:
return int(value, base) return int(value, base)
class OptionsFlow(config_entries.OptionsFlow): class RfxtrxOptionsFlow(OptionsFlow):
"""Handle Rfxtrx options.""" """Handle Rfxtrx options."""
_device_registry: dr.DeviceRegistry _device_registry: dr.DeviceRegistry
@ -91,13 +96,13 @@ class OptionsFlow(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
) -> data_entry_flow.FlowResult: ) -> ConfigFlowResult:
"""Manage the options.""" """Manage the options."""
return await self.async_step_prompt_options() return await self.async_step_prompt_options()
async def async_step_prompt_options( async def async_step_prompt_options(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> data_entry_flow.FlowResult: ) -> ConfigFlowResult:
"""Prompt for options.""" """Prompt for options."""
errors = {} errors = {}
@ -171,7 +176,7 @@ class OptionsFlow(config_entries.OptionsFlow):
async def async_step_set_device_options( async def async_step_set_device_options(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> data_entry_flow.FlowResult: ) -> ConfigFlowResult:
"""Manage device options.""" """Manage device options."""
errors = {} errors = {}
assert self._selected_device_object assert self._selected_device_object
@ -489,14 +494,14 @@ class OptionsFlow(config_entries.OptionsFlow):
) )
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class RfxtrxConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for RFXCOM RFXtrx.""" """Handle a config flow for RFXCOM RFXtrx."""
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
) -> data_entry_flow.FlowResult: ) -> ConfigFlowResult:
"""Step when user initializes a integration.""" """Step when user initializes a integration."""
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()
@ -515,7 +520,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_setup_network( async def async_step_setup_network(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> data_entry_flow.FlowResult: ) -> ConfigFlowResult:
"""Step when setting up network configuration.""" """Step when setting up network configuration."""
errors: dict[str, str] = {} errors: dict[str, str] = {}
@ -542,7 +547,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_setup_serial( async def async_step_setup_serial(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> data_entry_flow.FlowResult: ) -> ConfigFlowResult:
"""Step when setting up serial configuration.""" """Step when setting up serial configuration."""
errors: dict[str, str] = {} errors: dict[str, str] = {}
@ -581,7 +586,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_setup_serial_manual_path( async def async_step_setup_serial_manual_path(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> data_entry_flow.FlowResult: ) -> ConfigFlowResult:
"""Select path manually.""" """Select path manually."""
errors: dict[str, str] = {} errors: dict[str, str] = {}
@ -628,7 +633,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
@callback @callback
def async_get_options_flow(config_entry: ConfigEntry) -> OptionsFlow: def async_get_options_flow(config_entry: ConfigEntry) -> OptionsFlow:
"""Get the options flow for this handler.""" """Get the options flow for this handler."""
return OptionsFlow(config_entry) return RfxtrxOptionsFlow(config_entry)
def _test_transport(host: str | None, port: int | None, device: str | None) -> bool: def _test_transport(host: str | None, port: int | None, device: str | None) -> bool:
@ -658,5 +663,5 @@ def get_serial_by_id(dev_path: str) -> str:
return dev_path return dev_path
class CannotConnect(exceptions.HomeAssistantError): class CannotConnect(HomeAssistantError):
"""Error to indicate we cannot connect.""" """Error to indicate we cannot connect."""

View file

@ -5,20 +5,19 @@ from typing import Any
import voluptuous as vol import voluptuous as vol
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 ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class RhasspyConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Rhasspy.""" """Handle a config flow for Rhasspy."""
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 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

@ -8,9 +8,8 @@ from aioridwell import async_get_client
from aioridwell.errors import InvalidCredentialsError, RidwellError from aioridwell.errors import InvalidCredentialsError, RidwellError
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 import aiohttp_client, config_validation as cv from homeassistant.helpers import aiohttp_client, config_validation as cv
from .const import DOMAIN, LOGGER from .const import DOMAIN, LOGGER
@ -29,8 +28,8 @@ STEP_USER_DATA_SCHEMA = vol.Schema(
) )
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class RidwellConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for WattTime.""" """Handle a config flow for Ridwell."""
VERSION = 2 VERSION = 2
@ -41,7 +40,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def _async_validate( async def _async_validate(
self, error_step_id: str, error_schema: vol.Schema self, error_step_id: str, error_schema: vol.Schema
) -> FlowResult: ) -> ConfigFlowResult:
"""Validate input credentials and proceed accordingly.""" """Validate input credentials and proceed accordingly."""
errors = {} errors = {}
session = aiohttp_client.async_get_clientsession(self.hass) session = aiohttp_client.async_get_clientsession(self.hass)
@ -81,14 +80,16 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
data={CONF_USERNAME: self._username, CONF_PASSWORD: self._password}, data={CONF_USERNAME: self._username, CONF_PASSWORD: self._password},
) )
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: async def async_step_reauth(
self, entry_data: Mapping[str, Any]
) -> ConfigFlowResult:
"""Handle configuration by re-auth.""" """Handle configuration by re-auth."""
self._username = entry_data[CONF_USERNAME] self._username = entry_data[CONF_USERNAME]
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-auth completion.""" """Handle re-auth completion."""
if not user_input: if not user_input:
return self.async_show_form( return self.async_show_form(
@ -105,7 +106,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 not user_input: if not user_input:
return self.async_show_form( return self.async_show_form(

View file

@ -6,8 +6,7 @@ from typing import Any
import ring_doorbell import ring_doorbell
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries, core, exceptions from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
APPLICATION_NAME, APPLICATION_NAME,
CONF_PASSWORD, CONF_PASSWORD,
@ -15,7 +14,8 @@ from homeassistant.const import (
CONF_USERNAME, CONF_USERNAME,
__version__ as ha_version, __version__ as ha_version,
) )
from homeassistant.data_entry_flow import FlowResult from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
from .const import CONF_2FA, DOMAIN from .const import CONF_2FA, DOMAIN
@ -27,7 +27,7 @@ STEP_USER_DATA_SCHEMA = vol.Schema(
STEP_REAUTH_DATA_SCHEMA = vol.Schema({vol.Required(CONF_PASSWORD): str}) STEP_REAUTH_DATA_SCHEMA = vol.Schema({vol.Required(CONF_PASSWORD): str})
async def validate_input(hass: core.HomeAssistant, data): async def validate_input(hass: HomeAssistant, data):
"""Validate the user input allows us to connect.""" """Validate the user input allows us to connect."""
auth = ring_doorbell.Auth(f"{APPLICATION_NAME}/{ha_version}") auth = ring_doorbell.Auth(f"{APPLICATION_NAME}/{ha_version}")
@ -47,7 +47,7 @@ async def validate_input(hass: core.HomeAssistant, data):
return token return token
class RingConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class RingConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Ring.""" """Handle a config flow for Ring."""
VERSION = 1 VERSION = 1
@ -96,7 +96,9 @@ class RingConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
data_schema=vol.Schema({vol.Required(CONF_2FA): str}), data_schema=vol.Schema({vol.Required(CONF_2FA): str}),
) )
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult: async def async_step_reauth(
self, entry_data: Mapping[str, Any]
) -> ConfigFlowResult:
"""Handle reauth upon an API authentication error.""" """Handle 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"]
@ -105,7 +107,7 @@ class RingConfigFlow(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:
"""Dialog that informs the user that reauth is required.""" """Dialog that informs the user that reauth is required."""
errors = {} errors = {}
assert self.reauth_entry is not None assert self.reauth_entry is not None
@ -143,9 +145,9 @@ class RingConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
) )
class Require2FA(exceptions.HomeAssistantError): class Require2FA(HomeAssistantError):
"""Error to indicate we require 2FA.""" """Error to indicate we require 2FA."""
class InvalidAuth(exceptions.HomeAssistantError): class InvalidAuth(HomeAssistantError):
"""Error to indicate there is invalid auth.""" """Error to indicate there is invalid auth."""

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