mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 09:17:53 +00:00
Migrate integrations e-h to generic flowhandler (#111862)
This commit is contained in:
parent
6fe28d3764
commit
e06446d0fa
@ -2,13 +2,13 @@
|
||||
from aioeafm import get_stations
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.config_entries import ConfigFlow
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
|
||||
from .const import DOMAIN
|
||||
|
||||
|
||||
class UKFloodsFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class UKFloodsFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a UK Environment Agency flood monitoring config flow."""
|
||||
|
||||
VERSION = 1
|
||||
|
@ -3,8 +3,7 @@ from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.config_entries import ConfigFlow
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
|
||||
from .const import DOMAIN
|
||||
|
||||
@ -16,7 +15,7 @@ class EasyEnergyFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the initial step."""
|
||||
|
||||
await self.async_set_unique_id(DOMAIN)
|
||||
|
@ -7,7 +7,7 @@ from pyecobee import (
|
||||
)
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.config_entries import ConfigFlow
|
||||
from homeassistant.const import CONF_API_KEY
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.util.json import load_json_object
|
||||
@ -15,7 +15,7 @@ from homeassistant.util.json import load_json_object
|
||||
from .const import _LOGGER, CONF_REFRESH_TOKEN, DATA_ECOBEE_CONFIG, DOMAIN
|
||||
|
||||
|
||||
class EcobeeFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class EcobeeFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle an ecobee config flow."""
|
||||
|
||||
VERSION = 1
|
||||
|
@ -9,9 +9,8 @@ from pyecoforest.api import EcoforestApi
|
||||
from pyecoforest.exceptions import EcoforestAuthenticationRequired
|
||||
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.data_entry_flow import FlowResult
|
||||
|
||||
from .const import DOMAIN, MANUFACTURER
|
||||
|
||||
@ -26,14 +25,14 @@ STEP_USER_DATA_SCHEMA = vol.Schema(
|
||||
)
|
||||
|
||||
|
||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class EcoForestConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow for Ecoforest."""
|
||||
|
||||
VERSION = 1
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the initial step."""
|
||||
errors: dict[str, str] = {}
|
||||
|
||||
|
@ -3,13 +3,13 @@ from pyeconet import EcoNetApiInterface
|
||||
from pyeconet.errors import InvalidCredentialsError, PyeconetError
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.config_entries import ConfigFlow
|
||||
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD
|
||||
|
||||
from .const import DOMAIN
|
||||
|
||||
|
||||
class EcoNetFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class EcoNetFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle an EcoNet config flow."""
|
||||
|
||||
VERSION = 1
|
||||
|
@ -15,10 +15,10 @@ from deebot_client.util import md5
|
||||
from deebot_client.util.continents import COUNTRIES_TO_CONTINENTS, get_continent
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.config_entries import ConfigFlow
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import CONF_COUNTRY, CONF_MODE, CONF_PASSWORD, CONF_USERNAME
|
||||
from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant
|
||||
from homeassistant.data_entry_flow import AbortFlow, FlowResult
|
||||
from homeassistant.data_entry_flow import AbortFlow
|
||||
from homeassistant.helpers import aiohttp_client, selector
|
||||
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
|
||||
from homeassistant.loader import async_get_issue_tracker
|
||||
@ -136,7 +136,7 @@ class EcovacsConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the initial step."""
|
||||
|
||||
if not self.show_advanced_options:
|
||||
@ -166,7 +166,7 @@ class EcovacsConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_auth(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the auth step."""
|
||||
errors = {}
|
||||
|
||||
@ -217,7 +217,7 @@ class EcovacsConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
last_step=True,
|
||||
)
|
||||
|
||||
async def async_step_import(self, user_input: dict[str, Any]) -> FlowResult:
|
||||
async def async_step_import(self, user_input: dict[str, Any]) -> ConfigFlowResult:
|
||||
"""Import configuration from yaml."""
|
||||
|
||||
def create_repair(
|
||||
|
@ -6,17 +6,16 @@ from typing import Any
|
||||
|
||||
from yarl import URL
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import webhook
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import CONF_WEBHOOK_ID
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers.network import get_url
|
||||
|
||||
from .const import DOMAIN
|
||||
|
||||
|
||||
class EcowittConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class EcowittConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Config flow for the Ecowitt."""
|
||||
|
||||
VERSION = 1
|
||||
@ -24,7 +23,7 @@ class EcowittConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the initial step."""
|
||||
if user_input is None:
|
||||
self._webhook_id = secrets.token_hex(16)
|
||||
|
@ -2,8 +2,7 @@
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
|
||||
from .const import CONF_SERIAL_PORT, DEFAULT_TITLE, DOMAIN
|
||||
|
||||
@ -14,14 +13,14 @@ DATA_SCHEMA = vol.Schema(
|
||||
)
|
||||
|
||||
|
||||
class EDL21ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class EDL21ConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""EDL21 config flow."""
|
||||
|
||||
VERSION = 1
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, str] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the user setup step."""
|
||||
if user_input is not None:
|
||||
self._async_abort_entries_match(
|
||||
|
@ -7,22 +7,21 @@ from typing import Any
|
||||
from pyefergy import Efergy, exceptions
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import CONF_API_KEY
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
|
||||
from .const import DEFAULT_NAME, DOMAIN, LOGGER
|
||||
|
||||
|
||||
class EfergyFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class EfergyFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow for Efergy."""
|
||||
|
||||
VERSION = 1
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle a flow initiated by the user."""
|
||||
errors = {}
|
||||
if user_input is not None:
|
||||
@ -53,7 +52,9 @@ class EfergyFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
errors=errors,
|
||||
)
|
||||
|
||||
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
|
||||
async def async_step_reauth(
|
||||
self, entry_data: Mapping[str, Any]
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle a reauthorization flow request."""
|
||||
return await self.async_step_user()
|
||||
|
||||
|
@ -8,9 +8,8 @@ from electrasmart.api import STATUS_SUCCESS, Attributes, ElectraAPI, ElectraApiE
|
||||
from electrasmart.api.utils import generate_imei
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import CONF_TOKEN
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
|
||||
from .const import CONF_IMEI, CONF_OTP, CONF_PHONE_NUMBER, DOMAIN
|
||||
@ -18,7 +17,7 @@ from .const import CONF_IMEI, CONF_OTP, CONF_PHONE_NUMBER, DOMAIN
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class ElectraSmartConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow for Electra Air Conditioner."""
|
||||
|
||||
VERSION = 1
|
||||
@ -34,7 +33,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the initial step."""
|
||||
|
||||
if not self._api:
|
||||
@ -52,7 +51,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
user_input: dict[str, str] | None = None,
|
||||
errors: dict[str, str] | None = None,
|
||||
step_id: str = "user",
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Show the setup form to the user."""
|
||||
if user_input is None:
|
||||
user_input = {}
|
||||
@ -73,7 +72,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
description_placeholders=self._description_placeholders,
|
||||
)
|
||||
|
||||
async def _validate_phone_number(self, user_input: dict[str, str]) -> FlowResult:
|
||||
async def _validate_phone_number(
|
||||
self, user_input: dict[str, str]
|
||||
) -> ConfigFlowResult:
|
||||
"""Check if config is valid and create entry if so."""
|
||||
|
||||
self._phone_number = user_input[CONF_PHONE_NUMBER]
|
||||
@ -102,7 +103,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def _validate_one_time_password(
|
||||
self, user_input: dict[str, str]
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
self._otp = user_input[CONF_OTP]
|
||||
|
||||
assert isinstance(self._api, ElectraAPI)
|
||||
@ -135,7 +136,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
self,
|
||||
user_input: dict[str, Any] | None = None,
|
||||
errors: dict[str, str] | None = None,
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Ask the verification code to the user."""
|
||||
if errors is None:
|
||||
errors = {}
|
||||
@ -148,7 +149,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
async def _show_otp_form(
|
||||
self,
|
||||
errors: dict[str, str] | None = None,
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Show the verification_code form to the user."""
|
||||
|
||||
return self.async_show_form(
|
||||
|
@ -5,8 +5,7 @@ from collections.abc import Mapping
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.config_entries import ConfigEntry, ConfigFlowResult
|
||||
from homeassistant.helpers import config_entry_oauth2_flow
|
||||
|
||||
from .const import DOMAIN, SCOPE_VALUES
|
||||
@ -34,7 +33,9 @@ class ElectricKiwiOauth2FlowHandler(
|
||||
"""Extra data that needs to be appended to the authorize url."""
|
||||
return {"scope": SCOPE_VALUES}
|
||||
|
||||
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
|
||||
async def async_step_reauth(
|
||||
self, entry_data: Mapping[str, Any]
|
||||
) -> ConfigFlowResult:
|
||||
"""Perform reauth upon an API authentication error."""
|
||||
self._reauth_entry = self.hass.config_entries.async_get_entry(
|
||||
self.context["entry_id"]
|
||||
@ -43,13 +44,13 @@ class ElectricKiwiOauth2FlowHandler(
|
||||
|
||||
async def async_step_reauth_confirm(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Dialog that informs the user that reauth is required."""
|
||||
if user_input is None:
|
||||
return self.async_show_form(step_id="reauth_confirm")
|
||||
return await self.async_step_user()
|
||||
|
||||
async def async_oauth_create_entry(self, data: dict) -> FlowResult:
|
||||
async def async_oauth_create_entry(self, data: dict) -> ConfigFlowResult:
|
||||
"""Create an entry for Electric Kiwi."""
|
||||
existing_entry = await self.async_set_unique_id(DOMAIN)
|
||||
if existing_entry:
|
||||
|
@ -7,10 +7,9 @@ from elgato import Elgato, ElgatoError
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components import onboarding, zeroconf
|
||||
from homeassistant.config_entries import ConfigFlow
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import CONF_HOST, CONF_MAC, CONF_PORT
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
|
||||
from .const import DOMAIN
|
||||
@ -28,7 +27,7 @@ class ElgatoFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle a flow initiated by the user."""
|
||||
if user_input is None:
|
||||
return self._async_show_setup_form()
|
||||
@ -45,7 +44,7 @@ class ElgatoFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_zeroconf(
|
||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle zeroconf discovery."""
|
||||
self.host = discovery_info.host
|
||||
self.mac = discovery_info.properties.get("id")
|
||||
@ -67,14 +66,14 @@ class ElgatoFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_zeroconf_confirm(
|
||||
self, _: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle a flow initiated by zeroconf."""
|
||||
return self._async_create_entry()
|
||||
|
||||
@callback
|
||||
def _async_show_setup_form(
|
||||
self, errors: dict[str, str] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Show the setup form to the user."""
|
||||
return self.async_show_form(
|
||||
step_id="user",
|
||||
@ -88,7 +87,7 @@ class ElgatoFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
)
|
||||
|
||||
@callback
|
||||
def _async_create_entry(self) -> FlowResult:
|
||||
def _async_create_entry(self) -> ConfigFlowResult:
|
||||
return self.async_create_entry(
|
||||
title=self.serial_number,
|
||||
data={
|
||||
|
@ -8,8 +8,8 @@ from elkm1_lib.discovery import ElkSystem
|
||||
from elkm1_lib.elk import Elk
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries, exceptions
|
||||
from homeassistant.components import dhcp
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import (
|
||||
CONF_ADDRESS,
|
||||
CONF_HOST,
|
||||
@ -18,7 +18,7 @@ from homeassistant.const import (
|
||||
CONF_PROTOCOL,
|
||||
CONF_USERNAME,
|
||||
)
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers import device_registry as dr
|
||||
from homeassistant.helpers.typing import DiscoveryInfoType
|
||||
from homeassistant.util import slugify
|
||||
@ -126,7 +126,7 @@ def _placeholders_from_device(device: ElkSystem) -> dict[str, str]:
|
||||
}
|
||||
|
||||
|
||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class Elkm1ConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow for Elk-M1 Control."""
|
||||
|
||||
VERSION = 1
|
||||
@ -136,7 +136,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
self._discovered_device: ElkSystem | None = None
|
||||
self._discovered_devices: dict[str, ElkSystem] = {}
|
||||
|
||||
async def async_step_dhcp(self, discovery_info: dhcp.DhcpServiceInfo) -> FlowResult:
|
||||
async def async_step_dhcp(
|
||||
self, discovery_info: dhcp.DhcpServiceInfo
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle discovery via dhcp."""
|
||||
self._discovered_device = ElkSystem(
|
||||
discovery_info.macaddress, discovery_info.ip, 0
|
||||
@ -146,7 +148,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_integration_discovery(
|
||||
self, discovery_info: DiscoveryInfoType
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle integration discovery."""
|
||||
self._discovered_device = ElkSystem(
|
||||
discovery_info["mac_address"],
|
||||
@ -158,7 +160,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
)
|
||||
return await self._async_handle_discovery()
|
||||
|
||||
async def _async_handle_discovery(self) -> FlowResult:
|
||||
async def _async_handle_discovery(self) -> ConfigFlowResult:
|
||||
"""Handle any discovery."""
|
||||
device = self._discovered_device
|
||||
assert device is not None
|
||||
@ -191,7 +193,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_discovery_confirm(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Confirm discovery."""
|
||||
assert self._discovered_device is not None
|
||||
self.context["title_placeholders"] = _placeholders_from_device(
|
||||
@ -201,7 +203,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the initial step."""
|
||||
if user_input is not None:
|
||||
if mac := user_input[CONF_DEVICE]:
|
||||
@ -236,7 +238,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def _async_create_or_error(
|
||||
self, user_input: dict[str, Any], importing: bool
|
||||
) -> tuple[dict[str, str] | None, FlowResult | None]:
|
||||
) -> tuple[dict[str, str] | None, ConfigFlowResult | None]:
|
||||
"""Try to connect and create the entry or error."""
|
||||
if self._url_already_configured(_make_url_from_data(user_input)):
|
||||
return None, self.async_abort(reason="address_already_configured")
|
||||
@ -267,7 +269,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_discovered_connection(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle connecting the device when we have a discovery."""
|
||||
errors: dict[str, str] | None = {}
|
||||
device = self._discovered_device
|
||||
@ -299,7 +301,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_manual_connection(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle connecting the device when we need manual entry."""
|
||||
errors: dict[str, str] | None = {}
|
||||
if user_input is not None:
|
||||
@ -334,7 +336,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
errors=errors,
|
||||
)
|
||||
|
||||
async def async_step_import(self, user_input: dict[str, Any]) -> FlowResult:
|
||||
async def async_step_import(self, user_input: dict[str, Any]) -> ConfigFlowResult:
|
||||
"""Handle import."""
|
||||
_LOGGER.debug("Elk is importing from yaml")
|
||||
url = _make_url_from_data(user_input)
|
||||
@ -371,5 +373,5 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
return hostname_from_url(url) in existing_hosts
|
||||
|
||||
|
||||
class InvalidAuth(exceptions.HomeAssistantError):
|
||||
class InvalidAuth(HomeAssistantError):
|
||||
"""Error to indicate there is invalid auth."""
|
||||
|
@ -10,8 +10,7 @@ from elmax_api.http import Elmax
|
||||
from elmax_api.model.panel import PanelEntry
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
|
||||
from .const import (
|
||||
@ -55,7 +54,7 @@ def _store_panel_by_name(
|
||||
panel_names[panel_name] = panel_id
|
||||
|
||||
|
||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class ElmaxConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow for elmax-cloud."""
|
||||
|
||||
VERSION = 1
|
||||
@ -64,11 +63,11 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
_password: str
|
||||
_panels_schema: vol.Schema
|
||||
_panel_names: dict
|
||||
_entry: config_entries.ConfigEntry | None
|
||||
_entry: ConfigEntry | None
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle a flow initialized by the user."""
|
||||
# When invokes without parameters, show the login form.
|
||||
if user_input is None:
|
||||
@ -133,7 +132,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_panels(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle Panel selection step."""
|
||||
errors: dict[str, Any] = {}
|
||||
if user_input is None:
|
||||
@ -175,14 +174,16 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
step_id="panels", data_schema=self._panels_schema, errors=errors
|
||||
)
|
||||
|
||||
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
|
||||
async def async_step_reauth(
|
||||
self, entry_data: Mapping[str, Any]
|
||||
) -> ConfigFlowResult:
|
||||
"""Perform reauth upon an API authentication error."""
|
||||
self._entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
|
||||
return await self.async_step_reauth_confirm()
|
||||
|
||||
async def async_step_reauth_confirm(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle reauthorization flow."""
|
||||
errors = {}
|
||||
if user_input is not None:
|
||||
|
@ -13,9 +13,6 @@ from homeassistant.util import dt as dt_util
|
||||
|
||||
from .const import CONF_METERING_POINT_ID, DOMAIN, LOGGER
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
|
||||
|
||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow for Elvia."""
|
||||
@ -28,7 +25,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
async def async_step_user(
|
||||
self,
|
||||
user_input: dict[str, Any] | None = None,
|
||||
) -> FlowResult:
|
||||
) -> config_entries.ConfigFlowResult:
|
||||
"""Handle the initial step."""
|
||||
errors: dict[str, str] = {}
|
||||
if user_input is not None:
|
||||
@ -77,7 +74,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_select_meter(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> config_entries.ConfigFlowResult:
|
||||
"""Handle selecting a metering point ID."""
|
||||
if TYPE_CHECKING:
|
||||
assert self._metering_point_ids is not None
|
||||
@ -105,7 +102,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
self,
|
||||
api_token: str,
|
||||
metering_point_id: str,
|
||||
) -> FlowResult:
|
||||
) -> config_entries.ConfigFlowResult:
|
||||
"""Store metering point ID and API token."""
|
||||
if (await self.async_set_unique_id(metering_point_id)) is not None:
|
||||
return self.async_abort(
|
||||
|
@ -5,10 +5,10 @@ from aioemonitor import Emonitor
|
||||
import aiohttp
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries, core
|
||||
from homeassistant.components import dhcp
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import CONF_HOST, CONF_NAME
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import aiohttp_client
|
||||
from homeassistant.helpers.device_registry import format_mac
|
||||
|
||||
@ -18,7 +18,7 @@ from .const import DOMAIN
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
async def fetch_mac_and_title(hass: core.HomeAssistant, host):
|
||||
async def fetch_mac_and_title(hass: HomeAssistant, host):
|
||||
"""Validate the user input allows us to connect."""
|
||||
session = aiohttp_client.async_get_clientsession(hass)
|
||||
emonitor = Emonitor(host, session)
|
||||
@ -27,7 +27,7 @@ async def fetch_mac_and_title(hass: core.HomeAssistant, host):
|
||||
return {"title": name_short_mac(mac_address[-6:]), "mac_address": mac_address}
|
||||
|
||||
|
||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class EmonitorConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow for SiteSage Emonitor."""
|
||||
|
||||
VERSION = 1
|
||||
@ -63,7 +63,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
errors=errors,
|
||||
)
|
||||
|
||||
async def async_step_dhcp(self, discovery_info: dhcp.DhcpServiceInfo) -> FlowResult:
|
||||
async def async_step_dhcp(
|
||||
self, discovery_info: dhcp.DhcpServiceInfo
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle dhcp discovery."""
|
||||
self.discovered_ip = discovery_info.ip
|
||||
await self.async_set_unique_id(format_mac(discovery_info.macaddress))
|
||||
|
@ -1,7 +1,7 @@
|
||||
"""Config flow to configure emulated_roku component."""
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.config_entries import ConfigFlow
|
||||
from homeassistant.const import CONF_NAME
|
||||
from homeassistant.core import callback
|
||||
|
||||
@ -16,7 +16,7 @@ def configured_servers(hass):
|
||||
}
|
||||
|
||||
|
||||
class EmulatedRokuFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class EmulatedRokuFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle an emulated_roku config flow."""
|
||||
|
||||
VERSION = 1
|
||||
|
@ -3,8 +3,7 @@ from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.config_entries import ConfigFlow
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
|
||||
from .const import DOMAIN
|
||||
|
||||
@ -16,7 +15,7 @@ class EnergyZeroFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the initial step."""
|
||||
|
||||
await self.async_set_unique_id(DOMAIN)
|
||||
|
@ -2,14 +2,14 @@
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.config_entries import ConfigFlow
|
||||
from homeassistant.const import CONF_DEVICE
|
||||
|
||||
from . import dongle
|
||||
from .const import DOMAIN, ERROR_INVALID_DONGLE_PATH, LOGGER
|
||||
|
||||
|
||||
class EnOceanFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class EnOceanFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle the enOcean config flows."""
|
||||
|
||||
VERSION = 1
|
||||
|
@ -9,11 +9,10 @@ from awesomeversion import AwesomeVersion
|
||||
from pyenphase import AUTH_TOKEN_MIN_VERSION, Envoy, EnvoyError
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import zeroconf
|
||||
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PASSWORD, CONF_USERNAME
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.helpers.httpx_client import get_async_client
|
||||
|
||||
from .const import DOMAIN, INVALID_AUTH_ERRORS
|
||||
@ -37,7 +36,7 @@ async def validate_input(
|
||||
return envoy
|
||||
|
||||
|
||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class EnphaseConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow for Enphase Envoy."""
|
||||
|
||||
VERSION = 1
|
||||
@ -47,7 +46,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
self.ip_address: str | None = None
|
||||
self.username = None
|
||||
self.protovers: str | None = None
|
||||
self._reauth_entry: config_entries.ConfigEntry | None = None
|
||||
self._reauth_entry: ConfigEntry | None = None
|
||||
|
||||
@callback
|
||||
def _async_generate_schema(self) -> vol.Schema:
|
||||
@ -87,7 +86,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_zeroconf(
|
||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle a flow initialized by zeroconf discovery."""
|
||||
if discovery_info.ip_address.version != 4:
|
||||
return self.async_abort(reason="not_ipv4_address")
|
||||
@ -109,7 +108,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
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 configuration by re-auth."""
|
||||
self._reauth_entry = self.hass.config_entries.async_get_entry(
|
||||
self.context["entry_id"]
|
||||
@ -125,7 +126,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the initial step."""
|
||||
errors: dict[str, str] = {}
|
||||
description_placeholders: dict[str, str] = {}
|
||||
|
@ -6,7 +6,7 @@ import aiohttp
|
||||
from env_canada import ECWeather, ec_exc
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.config_entries import ConfigFlow
|
||||
from homeassistant.const import CONF_LANGUAGE, CONF_LATITUDE, CONF_LONGITUDE
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
|
||||
@ -40,7 +40,7 @@ async def validate_input(data):
|
||||
}
|
||||
|
||||
|
||||
class EnvironmentCanadaConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class EnvironmentCanadaConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow for Environment Canada weather."""
|
||||
|
||||
VERSION = 1
|
||||
|
@ -7,9 +7,8 @@ from typing import Any
|
||||
from epion import Epion, EpionAuthenticationError, EpionConnectionError
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.config_entries import ConfigFlow
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import CONF_API_KEY
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
|
||||
from .const import DOMAIN
|
||||
|
||||
@ -23,7 +22,7 @@ class EpionConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle a flow initiated by the user."""
|
||||
errors = {}
|
||||
if user_input:
|
||||
|
@ -3,7 +3,7 @@ import logging
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.config_entries import ConfigFlow
|
||||
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT
|
||||
|
||||
from . import validate_projector
|
||||
@ -20,7 +20,7 @@ DATA_SCHEMA = vol.Schema(
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class EpsonConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow for epson."""
|
||||
|
||||
VERSION = 1
|
||||
|
@ -21,10 +21,14 @@ import voluptuous as vol
|
||||
|
||||
from homeassistant.components import dhcp, zeroconf
|
||||
from homeassistant.components.hassio import HassioServiceInfo
|
||||
from homeassistant.config_entries import ConfigEntry, ConfigFlow, OptionsFlow
|
||||
from homeassistant.config_entries import (
|
||||
ConfigEntry,
|
||||
ConfigFlow,
|
||||
ConfigFlowResult,
|
||||
OptionsFlow,
|
||||
)
|
||||
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PASSWORD, CONF_PORT
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.helpers.device_registry import format_mac
|
||||
|
||||
from .const import (
|
||||
@ -64,7 +68,7 @@ class EsphomeFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def _async_step_user_base(
|
||||
self, user_input: dict[str, Any] | None = None, error: str | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
if user_input is not None:
|
||||
self._host = user_input[CONF_HOST]
|
||||
self._port = user_input[CONF_PORT]
|
||||
@ -87,11 +91,13 @@ class EsphomeFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle a flow initialized by the user."""
|
||||
return await self._async_step_user_base(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:
|
||||
"""Handle a flow initialized by a reauth event."""
|
||||
entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
|
||||
assert entry is not None
|
||||
@ -119,7 +125,7 @@ class EsphomeFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_reauth_confirm(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle reauthorization flow."""
|
||||
errors = {}
|
||||
|
||||
@ -151,7 +157,7 @@ class EsphomeFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
self.context[CONF_NAME] = value
|
||||
self.context["title_placeholders"] = {"name": self._name}
|
||||
|
||||
async def _async_try_fetch_device_info(self) -> FlowResult:
|
||||
async def _async_try_fetch_device_info(self) -> ConfigFlowResult:
|
||||
"""Try to fetch device info and return any errors."""
|
||||
response: str | None
|
||||
if self._noise_required:
|
||||
@ -193,7 +199,7 @@ class EsphomeFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
return await self._async_step_user_base(error=response)
|
||||
return await self._async_authenticate_or_add()
|
||||
|
||||
async def _async_authenticate_or_add(self) -> FlowResult:
|
||||
async def _async_authenticate_or_add(self) -> ConfigFlowResult:
|
||||
# Only show authentication step if device uses password
|
||||
assert self._device_info is not None
|
||||
if self._device_info.uses_password:
|
||||
@ -204,7 +210,7 @@ class EsphomeFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_discovery_confirm(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle user-confirmation of discovered node."""
|
||||
if user_input is not None:
|
||||
return await self._async_try_fetch_device_info()
|
||||
@ -214,7 +220,7 @@ class EsphomeFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_zeroconf(
|
||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle zeroconf discovery."""
|
||||
mac_address: str | None = discovery_info.properties.get("mac")
|
||||
|
||||
@ -243,7 +249,9 @@ class EsphomeFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
return await self.async_step_discovery_confirm()
|
||||
|
||||
async def async_step_dhcp(self, discovery_info: dhcp.DhcpServiceInfo) -> FlowResult:
|
||||
async def async_step_dhcp(
|
||||
self, discovery_info: dhcp.DhcpServiceInfo
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle DHCP discovery."""
|
||||
await self.async_set_unique_id(format_mac(discovery_info.macaddress))
|
||||
self._abort_if_unique_id_configured(updates={CONF_HOST: discovery_info.ip})
|
||||
@ -251,7 +259,9 @@ class EsphomeFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
# for configured devices.
|
||||
return self.async_abort(reason="already_configured")
|
||||
|
||||
async def async_step_hassio(self, discovery_info: HassioServiceInfo) -> FlowResult:
|
||||
async def async_step_hassio(
|
||||
self, discovery_info: HassioServiceInfo
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle Supervisor service discovery."""
|
||||
await async_set_dashboard_info(
|
||||
self.hass,
|
||||
@ -262,7 +272,7 @@ class EsphomeFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
return self.async_abort(reason="service_received")
|
||||
|
||||
@callback
|
||||
def _async_get_entry(self) -> FlowResult:
|
||||
def _async_get_entry(self) -> ConfigFlowResult:
|
||||
config_data = {
|
||||
CONF_HOST: self._host,
|
||||
CONF_PORT: self._port,
|
||||
@ -288,7 +298,7 @@ class EsphomeFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_encryption_key(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle getting psk for transport encryption."""
|
||||
errors = {}
|
||||
if user_input is not None:
|
||||
@ -307,7 +317,7 @@ class EsphomeFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_authenticate(
|
||||
self, user_input: dict[str, Any] | None = None, error: str | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle getting password for authentication."""
|
||||
if user_input is not None:
|
||||
self._password = user_input[CONF_PASSWORD]
|
||||
@ -444,7 +454,7 @@ class OptionsFlowHandler(OptionsFlow):
|
||||
|
||||
async def async_step_init(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle options flow."""
|
||||
if user_input is not None:
|
||||
return self.async_create_entry(title="", data=user_input)
|
||||
|
@ -10,9 +10,8 @@ from homeassistant.components.bluetooth import (
|
||||
BluetoothServiceInfoBleak,
|
||||
async_discovered_service_info,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigFlow
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import CONF_ADDRESS, CONF_MODEL
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
|
||||
from .const import DOMAIN
|
||||
|
||||
@ -29,7 +28,7 @@ class EufyLifeConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_bluetooth(
|
||||
self, discovery_info: BluetoothServiceInfoBleak
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the bluetooth discovery step."""
|
||||
await self.async_set_unique_id(discovery_info.address)
|
||||
self._abort_if_unique_id_configured()
|
||||
@ -42,7 +41,7 @@ class EufyLifeConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_bluetooth_confirm(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Confirm discovery."""
|
||||
assert self._discovery_info is not None
|
||||
discovery_info = self._discovery_info
|
||||
@ -64,7 +63,7 @@ class EufyLifeConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the user step to pick discovered device."""
|
||||
if user_input is not None:
|
||||
address = user_input[CONF_ADDRESS]
|
||||
|
@ -9,9 +9,8 @@ import aiohttp
|
||||
import pyevilgenius
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers import aiohttp_client
|
||||
|
||||
@ -40,14 +39,14 @@ async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> dict[str,
|
||||
return {"title": data["name"]["value"], "unique_id": info["wiFiChipId"]}
|
||||
|
||||
|
||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class EvilGeniusLabsConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow for Evil Genius Labs."""
|
||||
|
||||
VERSION = 1
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the initial step."""
|
||||
if user_input is None:
|
||||
return self.async_show_form(
|
||||
|
@ -16,7 +16,12 @@ from pyezviz.exceptions import (
|
||||
from pyezviz.test_cam_rtsp import TestRTSPAuth
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry, ConfigFlow, OptionsFlow
|
||||
from homeassistant.config_entries import (
|
||||
ConfigEntry,
|
||||
ConfigFlow,
|
||||
ConfigFlowResult,
|
||||
OptionsFlow,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
CONF_CUSTOMIZE,
|
||||
CONF_IP_ADDRESS,
|
||||
@ -27,7 +32,6 @@ from homeassistant.const import (
|
||||
CONF_USERNAME,
|
||||
)
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
|
||||
from .const import (
|
||||
ATTR_SERIAL,
|
||||
@ -90,7 +94,7 @@ class EzvizConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
VERSION = 1
|
||||
|
||||
async def _validate_and_create_camera_rtsp(self, data: dict) -> FlowResult:
|
||||
async def _validate_and_create_camera_rtsp(self, data: dict) -> ConfigFlowResult:
|
||||
"""Try DESCRIBE on RTSP camera with credentials."""
|
||||
|
||||
# Get EZVIZ cloud credentials from config entry
|
||||
@ -146,7 +150,7 @@ class EzvizConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle a flow initiated by the user."""
|
||||
|
||||
# Check if EZVIZ cloud account is present in entry config,
|
||||
@ -213,7 +217,7 @@ class EzvizConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_user_custom_url(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle a flow initiated by the user for custom region url."""
|
||||
errors = {}
|
||||
auth_data = {}
|
||||
@ -262,7 +266,7 @@ class EzvizConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_integration_discovery(
|
||||
self, discovery_info: dict[str, Any]
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle a flow for discovered camera without rtsp config entry."""
|
||||
|
||||
await self.async_set_unique_id(discovery_info[ATTR_SERIAL])
|
||||
@ -275,7 +279,7 @@ class EzvizConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_confirm(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Confirm and create entry from discovery step."""
|
||||
errors = {}
|
||||
|
||||
@ -315,14 +319,16 @@ class EzvizConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
},
|
||||
)
|
||||
|
||||
async def async_step_reauth(self, user_input: Mapping[str, Any]) -> FlowResult:
|
||||
async def async_step_reauth(
|
||||
self, user_input: Mapping[str, Any]
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle a flow for reauthentication with password."""
|
||||
|
||||
return await self.async_step_reauth_confirm()
|
||||
|
||||
async def async_step_reauth_confirm(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle a Confirm flow for reauthentication with password."""
|
||||
auth_data = {}
|
||||
errors = {}
|
||||
@ -390,7 +396,7 @@ class EzvizOptionsFlowHandler(OptionsFlow):
|
||||
|
||||
async def async_step_init(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Manage EZVIZ options."""
|
||||
if user_input is not None:
|
||||
return self.async_create_entry(title="", data=user_input)
|
||||
|
@ -6,9 +6,8 @@ from aiohttp import ClientConnectionError
|
||||
import faadelays
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import CONF_ID
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.helpers import aiohttp_client
|
||||
|
||||
from .const import DOMAIN
|
||||
@ -18,14 +17,14 @@ _LOGGER = logging.getLogger(__name__)
|
||||
DATA_SCHEMA = vol.Schema({vol.Required(CONF_ID): str})
|
||||
|
||||
|
||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class FAADelaysConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow for FAA Delays."""
|
||||
|
||||
VERSION = 1
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the initial step."""
|
||||
errors = {}
|
||||
if user_input is not None:
|
||||
|
@ -3,9 +3,8 @@ from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.config_entries import ConfigFlow
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
|
||||
|
||||
from .const import DEFAULT_NAME, DOMAIN
|
||||
@ -18,7 +17,7 @@ class FastdotcomConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the initial step."""
|
||||
if self._async_current_entries():
|
||||
return self.async_abort(reason="single_instance_allowed")
|
||||
@ -30,7 +29,7 @@ class FastdotcomConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_import(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle a flow initiated by configuration file."""
|
||||
async_create_issue(
|
||||
self.hass,
|
||||
|
@ -8,10 +8,9 @@ from typing import Any
|
||||
from slugify import slugify
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import CONF_PASSWORD, CONF_URL, CONF_USERNAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
|
||||
from . import FibaroAuthFailed, FibaroConnectFailed, FibaroController
|
||||
from .const import CONF_IMPORT_PLUGINS, DOMAIN
|
||||
@ -65,18 +64,18 @@ def _normalize_url(url: str) -> str:
|
||||
return url
|
||||
|
||||
|
||||
class FibaroConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class FibaroConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow for Fibaro."""
|
||||
|
||||
VERSION = 1
|
||||
|
||||
def __init__(self) -> None:
|
||||
"""Initialize."""
|
||||
self._reauth_entry: config_entries.ConfigEntry | None = None
|
||||
self._reauth_entry: ConfigEntry | None = None
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the initial step."""
|
||||
errors = {}
|
||||
|
||||
@ -97,7 +96,9 @@ class FibaroConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
step_id="user", data_schema=STEP_USER_DATA_SCHEMA, errors=errors
|
||||
)
|
||||
|
||||
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
|
||||
async def async_step_reauth(
|
||||
self, entry_data: Mapping[str, Any]
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle reauthentication."""
|
||||
self._reauth_entry = self.hass.config_entries.async_get_entry(
|
||||
self.context["entry_id"]
|
||||
@ -106,7 +107,7 @@ class FibaroConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_reauth_confirm(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle a flow initiated by reauthentication."""
|
||||
errors = {}
|
||||
|
||||
|
@ -7,10 +7,9 @@ from typing import Any
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.config_entries import ConfigFlow
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import CONF_FILE_PATH
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
|
||||
from .const import DOMAIN
|
||||
@ -43,7 +42,7 @@ class FilesizeConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle a flow initialized by the user."""
|
||||
errors: dict[str, Any] = {}
|
||||
|
||||
|
@ -7,9 +7,8 @@ from typing import Any
|
||||
from pyfireservicerota import FireServiceRota, InvalidAuthError
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import CONF_PASSWORD, CONF_TOKEN, CONF_URL, CONF_USERNAME
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
|
||||
from .const import DOMAIN, URL_LIST
|
||||
|
||||
@ -22,7 +21,7 @@ DATA_SCHEMA = vol.Schema(
|
||||
)
|
||||
|
||||
|
||||
class FireServiceRotaFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class FireServiceRotaFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a FireServiceRota config flow."""
|
||||
|
||||
VERSION = 1
|
||||
@ -116,7 +115,9 @@ class FireServiceRotaFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
description_placeholders=self._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:
|
||||
"""Initialise re-authentication."""
|
||||
await self.async_set_unique_id(entry_data[CONF_USERNAME])
|
||||
self._existing_entry = {**entry_data}
|
||||
@ -125,7 +126,7 @@ class FireServiceRotaFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_reauth_confirm(
|
||||
self, user_input: dict[str, str] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Get new tokens for a config entry that can't authenticate."""
|
||||
if user_input is None:
|
||||
return self._show_setup_form(step_id="reauth_confirm")
|
||||
|
@ -5,9 +5,8 @@ from typing import Any
|
||||
|
||||
from pymata_express.pymata_express_serial import serial
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import CONF_NAME
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
|
||||
from .board import get_board
|
||||
from .const import CONF_SERIAL_PORT, DOMAIN
|
||||
@ -15,12 +14,14 @@ from .const import CONF_SERIAL_PORT, DOMAIN
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class FirmataFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class FirmataFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a firmata config flow."""
|
||||
|
||||
VERSION = 1
|
||||
|
||||
async def async_step_import(self, import_config: dict[str, Any]) -> FlowResult:
|
||||
async def async_step_import(
|
||||
self, import_config: dict[str, Any]
|
||||
) -> ConfigFlowResult:
|
||||
"""Import a firmata board as a config entry.
|
||||
|
||||
This flow is triggered by `async_setup` for configured boards.
|
||||
|
@ -4,9 +4,8 @@ from collections.abc import Mapping
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.config_entries import ConfigEntry, ConfigFlowResult
|
||||
from homeassistant.const import CONF_TOKEN
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.helpers import config_entry_oauth2_flow
|
||||
|
||||
from . import api
|
||||
@ -38,7 +37,9 @@ class OAuth2FlowHandler(
|
||||
"prompt": "consent" if not self.reauth_entry else "none",
|
||||
}
|
||||
|
||||
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
|
||||
async def async_step_reauth(
|
||||
self, entry_data: Mapping[str, Any]
|
||||
) -> ConfigFlowResult:
|
||||
"""Perform reauth upon an API authentication error."""
|
||||
self.reauth_entry = self.hass.config_entries.async_get_entry(
|
||||
self.context["entry_id"]
|
||||
@ -47,7 +48,7 @@ class OAuth2FlowHandler(
|
||||
|
||||
async def async_step_reauth_confirm(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Confirm reauth dialog."""
|
||||
if user_input is None:
|
||||
return self.async_show_form(step_id="reauth_confirm")
|
||||
@ -55,7 +56,7 @@ class OAuth2FlowHandler(
|
||||
|
||||
async def async_step_creation(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Create config entry from external data with Fitbit specific error handling."""
|
||||
try:
|
||||
return await super().async_step_creation()
|
||||
@ -68,7 +69,7 @@ class OAuth2FlowHandler(
|
||||
_LOGGER.error("Failed to create Fitbit credentials: %s", err)
|
||||
return self.async_abort(reason="cannot_connect")
|
||||
|
||||
async def async_oauth_create_entry(self, data: dict[str, Any]) -> FlowResult:
|
||||
async def async_oauth_create_entry(self, data: dict[str, Any]) -> ConfigFlowResult:
|
||||
"""Create an entry for the flow, or update existing entry."""
|
||||
|
||||
client = api.ConfigFlowFitbitApi(self.hass, data[CONF_TOKEN])
|
||||
@ -92,6 +93,6 @@ class OAuth2FlowHandler(
|
||||
self._abort_if_unique_id_configured()
|
||||
return self.async_create_entry(title=profile.display_name, data=data)
|
||||
|
||||
async def async_step_import(self, data: dict[str, Any]) -> FlowResult:
|
||||
async def async_step_import(self, data: dict[str, Any]) -> ConfigFlowResult:
|
||||
"""Handle import from YAML."""
|
||||
return await self.async_oauth_create_entry(data)
|
||||
|
@ -7,9 +7,8 @@ from typing import Any
|
||||
from fivem import FiveM, FiveMServerOfflineError
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import CONF_HOST, CONF_PORT
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
from .const import DOMAIN
|
||||
@ -37,14 +36,14 @@ async def validate_input(data: dict[str, Any]) -> None:
|
||||
raise InvalidGameNameError
|
||||
|
||||
|
||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class FiveMConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow for FiveM."""
|
||||
|
||||
VERSION = 1
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the initial step."""
|
||||
if user_input is None:
|
||||
return self.async_show_form(
|
||||
|
@ -9,9 +9,8 @@ from flexit_bacnet import FlexitBACnet
|
||||
from flexit_bacnet.bacnet import DecodingError
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import CONF_DEVICE_ID, CONF_IP_ADDRESS
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
|
||||
from .const import DOMAIN
|
||||
|
||||
@ -27,14 +26,14 @@ STEP_USER_DATA_SCHEMA = vol.Schema(
|
||||
)
|
||||
|
||||
|
||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class FlexitBacnetConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow for Flexit Nordic (BACnet)."""
|
||||
|
||||
VERSION = 1
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the initial step."""
|
||||
errors: dict[str, str] = {}
|
||||
|
||||
|
@ -6,13 +6,14 @@ from pyflick.authentication import AuthException, SimpleFlickAuth
|
||||
from pyflick.const import DEFAULT_CLIENT_ID, DEFAULT_CLIENT_SECRET
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries, exceptions
|
||||
from homeassistant.config_entries import ConfigFlow
|
||||
from homeassistant.const import (
|
||||
CONF_CLIENT_ID,
|
||||
CONF_CLIENT_SECRET,
|
||||
CONF_PASSWORD,
|
||||
CONF_USERNAME,
|
||||
)
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers import aiohttp_client
|
||||
|
||||
from .const import DOMAIN
|
||||
@ -29,7 +30,7 @@ DATA_SCHEMA = vol.Schema(
|
||||
)
|
||||
|
||||
|
||||
class FlickConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class FlickConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Flick config flow."""
|
||||
|
||||
VERSION = 1
|
||||
@ -82,9 +83,9 @@ class FlickConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
)
|
||||
|
||||
|
||||
class CannotConnect(exceptions.HomeAssistantError):
|
||||
class CannotConnect(HomeAssistantError):
|
||||
"""Error to indicate we cannot connect."""
|
||||
|
||||
|
||||
class InvalidAuth(exceptions.HomeAssistantError):
|
||||
class InvalidAuth(HomeAssistantError):
|
||||
"""Error to indicate there is invalid auth."""
|
||||
|
@ -7,16 +7,15 @@ from flipr_api import FliprAPIRestClient
|
||||
from requests.exceptions import HTTPError, Timeout
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
|
||||
from .const import CONF_FLIPR_ID, DOMAIN
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class FliprConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow for Flipr."""
|
||||
|
||||
VERSION = 1
|
||||
@ -28,7 +27,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, str] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the initial step."""
|
||||
if user_input is None:
|
||||
return self._show_setup_form()
|
||||
@ -97,7 +96,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_flipr_id(
|
||||
self, user_input: dict[str, str] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the initial step."""
|
||||
if not user_input:
|
||||
# Creation of a select with the proposal of flipr ids values found by API.
|
||||
|
@ -3,8 +3,10 @@ from aioflo import async_get_api
|
||||
from aioflo.errors import RequestError
|
||||
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.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
|
||||
from .const import DOMAIN, LOGGER
|
||||
@ -14,7 +16,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.
|
||||
|
||||
Data has the keys from DATA_SCHEMA with values provided by the user.
|
||||
@ -28,7 +30,7 @@ async def validate_input(hass: core.HomeAssistant, data):
|
||||
raise CannotConnect from request_error
|
||||
|
||||
|
||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class FloConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow for flo."""
|
||||
|
||||
VERSION = 1
|
||||
@ -52,5 +54,5 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
)
|
||||
|
||||
|
||||
class CannotConnect(exceptions.HomeAssistantError):
|
||||
class CannotConnect(HomeAssistantError):
|
||||
"""Error to indicate we cannot connect."""
|
||||
|
@ -10,14 +10,15 @@ from pyflume import FlumeAuth, FlumeDeviceList
|
||||
from requests.exceptions import RequestException
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries, core, exceptions
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import (
|
||||
CONF_CLIENT_ID,
|
||||
CONF_CLIENT_SECRET,
|
||||
CONF_PASSWORD,
|
||||
CONF_USERNAME,
|
||||
)
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
|
||||
from .const import BASE_TOKEN_FILENAME, DOMAIN
|
||||
|
||||
@ -39,7 +40,7 @@ DATA_SCHEMA = vol.Schema(
|
||||
|
||||
|
||||
def _validate_input(
|
||||
hass: core.HomeAssistant, data: dict[str, Any], clear_token_file: bool
|
||||
hass: HomeAssistant, data: dict[str, Any], clear_token_file: bool
|
||||
) -> FlumeDeviceList:
|
||||
"""Validate in the executor."""
|
||||
flume_token_full_path = hass.config.path(
|
||||
@ -60,7 +61,7 @@ def _validate_input(
|
||||
|
||||
|
||||
async def validate_input(
|
||||
hass: core.HomeAssistant, data: dict[str, Any], clear_token_file: bool = False
|
||||
hass: HomeAssistant, data: dict[str, Any], clear_token_file: bool = False
|
||||
) -> dict[str, Any]:
|
||||
"""Validate the user input allows us to connect.
|
||||
|
||||
@ -82,7 +83,7 @@ async def validate_input(
|
||||
return {"title": data[CONF_USERNAME]}
|
||||
|
||||
|
||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class FlumeConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow for flume."""
|
||||
|
||||
VERSION = 1
|
||||
@ -93,7 +94,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the initial step."""
|
||||
errors: dict[str, str] = {}
|
||||
if user_input is not None:
|
||||
@ -112,14 +113,16 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
step_id="user", data_schema=DATA_SCHEMA, errors=errors
|
||||
)
|
||||
|
||||
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
|
||||
async def async_step_reauth(
|
||||
self, entry_data: Mapping[str, Any]
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle reauth."""
|
||||
self._reauth_unique_id = self.context["unique_id"]
|
||||
return await self.async_step_reauth_confirm()
|
||||
|
||||
async def async_step_reauth_confirm(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle reauth input."""
|
||||
errors: dict[str, str] = {}
|
||||
existing_entry = await self.async_set_unique_id(self._reauth_unique_id)
|
||||
@ -153,9 +156,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
)
|
||||
|
||||
|
||||
class CannotConnect(exceptions.HomeAssistantError):
|
||||
class CannotConnect(HomeAssistantError):
|
||||
"""Error to indicate we cannot connect."""
|
||||
|
||||
|
||||
class InvalidAuth(exceptions.HomeAssistantError):
|
||||
class InvalidAuth(HomeAssistantError):
|
||||
"""Error to indicate there is invalid auth."""
|
||||
|
@ -15,11 +15,18 @@ from flux_led.const import (
|
||||
from flux_led.scanner import FluxLEDDiscovery
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import dhcp
|
||||
from homeassistant.config_entries import (
|
||||
SOURCE_IGNORE,
|
||||
ConfigEntry,
|
||||
ConfigEntryState,
|
||||
ConfigFlow,
|
||||
ConfigFlowResult,
|
||||
OptionsFlow,
|
||||
)
|
||||
from homeassistant.const import CONF_DEVICE, CONF_HOST
|
||||
from homeassistant.core import 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.dispatcher import async_dispatcher_send
|
||||
from homeassistant.helpers.typing import DiscoveryInfoType
|
||||
@ -48,7 +55,7 @@ from .discovery import (
|
||||
from .util import format_as_flux_mac, mac_matches_by_one
|
||||
|
||||
|
||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class FluxLedConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow for Magic Home Integration."""
|
||||
|
||||
VERSION = 1
|
||||
@ -61,11 +68,13 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
@staticmethod
|
||||
@callback
|
||||
def async_get_options_flow(config_entry: config_entries.ConfigEntry) -> OptionsFlow:
|
||||
def async_get_options_flow(config_entry: ConfigEntry) -> OptionsFlow:
|
||||
"""Get the options flow for the Flux LED component."""
|
||||
return OptionsFlow(config_entry)
|
||||
return FluxLedOptionsFlow(config_entry)
|
||||
|
||||
async def async_step_dhcp(self, discovery_info: dhcp.DhcpServiceInfo) -> FlowResult:
|
||||
async def async_step_dhcp(
|
||||
self, discovery_info: dhcp.DhcpServiceInfo
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle discovery via dhcp."""
|
||||
self._discovered_device = FluxLEDDiscovery(
|
||||
ipaddr=discovery_info.ip,
|
||||
@ -84,7 +93,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_integration_discovery(
|
||||
self, discovery_info: DiscoveryInfoType
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle integration discovery."""
|
||||
self._allow_update_mac = True
|
||||
self._discovered_device = cast(FluxLEDDiscovery, discovery_info)
|
||||
@ -113,7 +122,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
)
|
||||
):
|
||||
continue
|
||||
if entry.source == config_entries.SOURCE_IGNORE:
|
||||
if entry.source == SOURCE_IGNORE:
|
||||
raise AbortFlow("already_configured")
|
||||
if (
|
||||
async_update_entry_from_discovery(
|
||||
@ -121,10 +130,10 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
)
|
||||
and entry.state
|
||||
not in (
|
||||
config_entries.ConfigEntryState.SETUP_IN_PROGRESS,
|
||||
config_entries.ConfigEntryState.NOT_LOADED,
|
||||
ConfigEntryState.SETUP_IN_PROGRESS,
|
||||
ConfigEntryState.NOT_LOADED,
|
||||
)
|
||||
) or entry.state == config_entries.ConfigEntryState.SETUP_RETRY:
|
||||
) or entry.state == ConfigEntryState.SETUP_RETRY:
|
||||
self.hass.config_entries.async_schedule_reload(entry.entry_id)
|
||||
else:
|
||||
async_dispatcher_send(
|
||||
@ -133,7 +142,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
)
|
||||
raise AbortFlow("already_configured")
|
||||
|
||||
async def _async_handle_discovery(self) -> FlowResult:
|
||||
async def _async_handle_discovery(self) -> ConfigFlowResult:
|
||||
"""Handle any discovery."""
|
||||
device = self._discovered_device
|
||||
assert device is not None
|
||||
@ -165,7 +174,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_discovery_confirm(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Confirm discovery."""
|
||||
assert self._discovered_device is not None
|
||||
device = self._discovered_device
|
||||
@ -186,7 +195,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
)
|
||||
|
||||
@callback
|
||||
def _async_create_entry_from_device(self, device: FluxLEDDiscovery) -> FlowResult:
|
||||
def _async_create_entry_from_device(
|
||||
self, device: FluxLEDDiscovery
|
||||
) -> ConfigFlowResult:
|
||||
"""Create a config entry from a device."""
|
||||
self._async_abort_entries_match({CONF_HOST: device[ATTR_IPADDR]})
|
||||
name = async_name_from_discovery(device)
|
||||
@ -199,7 +210,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the initial step."""
|
||||
errors = {}
|
||||
if user_input is not None:
|
||||
@ -225,7 +236,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_pick_device(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the step to pick discovered device."""
|
||||
if user_input is not None:
|
||||
mac = user_input[CONF_DEVICE]
|
||||
@ -298,16 +309,16 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
)
|
||||
|
||||
|
||||
class OptionsFlow(config_entries.OptionsFlow):
|
||||
class FluxLedOptionsFlow(OptionsFlow):
|
||||
"""Handle flux_led options."""
|
||||
|
||||
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
|
||||
def __init__(self, config_entry: ConfigEntry) -> None:
|
||||
"""Initialize the flux_led options flow."""
|
||||
self._config_entry = config_entry
|
||||
|
||||
async def async_step_init(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Configure the options."""
|
||||
errors: dict[str, str] = {}
|
||||
if user_input is not None:
|
||||
|
@ -6,10 +6,14 @@ from typing import Any
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry, ConfigFlow, OptionsFlow
|
||||
from homeassistant.config_entries import (
|
||||
ConfigEntry,
|
||||
ConfigFlow,
|
||||
ConfigFlowResult,
|
||||
OptionsFlow,
|
||||
)
|
||||
from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
|
||||
from .const import (
|
||||
@ -40,7 +44,7 @@ class ForecastSolarFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle a flow initiated by the user."""
|
||||
if user_input is not None:
|
||||
return self.async_create_entry(
|
||||
@ -92,7 +96,7 @@ class ForecastSolarOptionFlowHandler(OptionsFlow):
|
||||
|
||||
async def async_step_init(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Manage the options."""
|
||||
errors = {}
|
||||
if user_input is not None:
|
||||
|
@ -5,11 +5,15 @@ import logging
|
||||
from pyforked_daapd import ForkedDaapdAPI
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import zeroconf
|
||||
from homeassistant.config_entries import (
|
||||
ConfigEntry,
|
||||
ConfigFlow,
|
||||
ConfigFlowResult,
|
||||
OptionsFlow,
|
||||
)
|
||||
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PASSWORD, CONF_PORT
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
|
||||
from .const import (
|
||||
@ -43,10 +47,10 @@ TEST_CONNECTION_ERROR_DICT = {
|
||||
}
|
||||
|
||||
|
||||
class ForkedDaapdOptionsFlowHandler(config_entries.OptionsFlow):
|
||||
class ForkedDaapdOptionsFlowHandler(OptionsFlow):
|
||||
"""Handle a forked-daapd options flow."""
|
||||
|
||||
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
|
||||
def __init__(self, config_entry: ConfigEntry) -> None:
|
||||
"""Initialize."""
|
||||
self.config_entry = config_entry
|
||||
|
||||
@ -99,7 +103,7 @@ def fill_in_schema_dict(some_input):
|
||||
return schema_dict
|
||||
|
||||
|
||||
class ForkedDaapdFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class ForkedDaapdFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a forked-daapd config flow."""
|
||||
|
||||
VERSION = 1
|
||||
@ -111,7 +115,7 @@ class ForkedDaapdFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
@staticmethod
|
||||
@callback
|
||||
def async_get_options_flow(
|
||||
config_entry: config_entries.ConfigEntry,
|
||||
config_entry: ConfigEntry,
|
||||
) -> ForkedDaapdOptionsFlowHandler:
|
||||
"""Return options flow handler."""
|
||||
return ForkedDaapdOptionsFlowHandler(config_entry)
|
||||
@ -159,7 +163,7 @@ class ForkedDaapdFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_zeroconf(
|
||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Prepare configuration for a discovered forked-daapd device."""
|
||||
version_num = 0
|
||||
zeroconf_properties = discovery_info.properties
|
||||
|
@ -7,7 +7,7 @@ from libpyfoscam.foscam import (
|
||||
)
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries, exceptions
|
||||
from homeassistant.config_entries import ConfigFlow
|
||||
from homeassistant.const import (
|
||||
CONF_HOST,
|
||||
CONF_NAME,
|
||||
@ -16,6 +16,7 @@ from homeassistant.const import (
|
||||
CONF_USERNAME,
|
||||
)
|
||||
from homeassistant.data_entry_flow import AbortFlow
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
|
||||
from .const import CONF_RTSP_PORT, CONF_STREAM, DOMAIN, LOGGER
|
||||
|
||||
@ -37,7 +38,7 @@ DATA_SCHEMA = vol.Schema(
|
||||
)
|
||||
|
||||
|
||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class FoscamConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow for foscam."""
|
||||
|
||||
VERSION = 2
|
||||
@ -117,13 +118,13 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
)
|
||||
|
||||
|
||||
class CannotConnect(exceptions.HomeAssistantError):
|
||||
class CannotConnect(HomeAssistantError):
|
||||
"""Error to indicate we cannot connect."""
|
||||
|
||||
|
||||
class InvalidAuth(exceptions.HomeAssistantError):
|
||||
class InvalidAuth(HomeAssistantError):
|
||||
"""Error to indicate there is invalid auth."""
|
||||
|
||||
|
||||
class InvalidResponse(exceptions.HomeAssistantError):
|
||||
class InvalidResponse(HomeAssistantError):
|
||||
"""Error to indicate there is invalid response."""
|
||||
|
@ -5,10 +5,9 @@ from typing import Any
|
||||
from freebox_api.exceptions import AuthorizationError, HttpRequestError
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import zeroconf
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import CONF_HOST, CONF_PORT
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
|
||||
from .const import DOMAIN
|
||||
from .router import get_api, get_hosts_list_if_supported
|
||||
@ -16,7 +15,7 @@ from .router import get_api, get_hosts_list_if_supported
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class FreeboxFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class FreeboxFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow."""
|
||||
|
||||
VERSION = 1
|
||||
@ -27,7 +26,7 @@ class FreeboxFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle a flow initiated by the user."""
|
||||
if user_input is None:
|
||||
return self.async_show_form(
|
||||
@ -51,7 +50,7 @@ class FreeboxFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_link(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Attempt to link with the Freebox router.
|
||||
|
||||
Given a configured host, will ask the user to press the button
|
||||
@ -100,7 +99,7 @@ class FreeboxFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_zeroconf(
|
||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Initialize flow from zeroconf."""
|
||||
zeroconf_properties = discovery_info.properties
|
||||
host = zeroconf_properties["api_domain"]
|
||||
|
@ -2,8 +2,10 @@
|
||||
from pyfreedompro import get_list
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries, core, exceptions
|
||||
from homeassistant.config_entries import ConfigFlow
|
||||
from homeassistant.const import CONF_API_KEY
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers import aiohttp_client
|
||||
|
||||
from .const import DOMAIN
|
||||
@ -26,7 +28,7 @@ class Hub:
|
||||
)
|
||||
|
||||
|
||||
async def validate_input(hass: core.HomeAssistant, api_key):
|
||||
async def validate_input(hass: HomeAssistant, api_key):
|
||||
"""Validate api key."""
|
||||
hub = Hub(hass, api_key)
|
||||
result = await hub.authenticate()
|
||||
@ -37,7 +39,7 @@ async def validate_input(hass: core.HomeAssistant, api_key):
|
||||
raise CannotConnect
|
||||
|
||||
|
||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class FreedomProConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow."""
|
||||
|
||||
VERSION = 1
|
||||
@ -65,9 +67,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
)
|
||||
|
||||
|
||||
class CannotConnect(exceptions.HomeAssistantError):
|
||||
class CannotConnect(HomeAssistantError):
|
||||
"""Error to indicate we cannot connect."""
|
||||
|
||||
|
||||
class InvalidAuth(exceptions.HomeAssistantError):
|
||||
class InvalidAuth(HomeAssistantError):
|
||||
"""Error to indicate there is invalid auth."""
|
||||
|
@ -20,12 +20,12 @@ from homeassistant.components.device_tracker import (
|
||||
from homeassistant.config_entries import (
|
||||
ConfigEntry,
|
||||
ConfigFlow,
|
||||
ConfigFlowResult,
|
||||
OptionsFlow,
|
||||
OptionsFlowWithConfigEntry,
|
||||
)
|
||||
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT, CONF_USERNAME
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
|
||||
from .const import (
|
||||
CONF_OLD_DISCOVERY,
|
||||
@ -110,7 +110,7 @@ class FritzBoxToolsFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
return None
|
||||
|
||||
@callback
|
||||
def _async_create_entry(self) -> FlowResult:
|
||||
def _async_create_entry(self) -> ConfigFlowResult:
|
||||
"""Async create flow handler entry."""
|
||||
return self.async_create_entry(
|
||||
title=self._name,
|
||||
@ -126,7 +126,9 @@ class FritzBoxToolsFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
},
|
||||
)
|
||||
|
||||
async def async_step_ssdp(self, discovery_info: ssdp.SsdpServiceInfo) -> FlowResult:
|
||||
async def async_step_ssdp(
|
||||
self, discovery_info: ssdp.SsdpServiceInfo
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle a flow initialized by discovery."""
|
||||
ssdp_location: ParseResult = urlparse(discovery_info.ssdp_location or "")
|
||||
self._host = ssdp_location.hostname
|
||||
@ -166,7 +168,7 @@ class FritzBoxToolsFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_confirm(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle user-confirmation of discovered node."""
|
||||
if user_input is None:
|
||||
return self._show_setup_form_confirm()
|
||||
@ -184,7 +186,9 @@ class FritzBoxToolsFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
return self._async_create_entry()
|
||||
|
||||
def _show_setup_form_init(self, errors: dict[str, str] | None = None) -> FlowResult:
|
||||
def _show_setup_form_init(
|
||||
self, errors: dict[str, str] | None = None
|
||||
) -> ConfigFlowResult:
|
||||
"""Show the setup form to the user."""
|
||||
return self.async_show_form(
|
||||
step_id="user",
|
||||
@ -201,7 +205,7 @@ class FritzBoxToolsFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
def _show_setup_form_confirm(
|
||||
self, errors: dict[str, str] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Show the setup form to the user."""
|
||||
return self.async_show_form(
|
||||
step_id="confirm",
|
||||
@ -217,7 +221,7 @@ class FritzBoxToolsFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle a flow initiated by the user."""
|
||||
if user_input is None:
|
||||
return self._show_setup_form_init()
|
||||
@ -237,7 +241,9 @@ class FritzBoxToolsFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
return self._async_create_entry()
|
||||
|
||||
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
|
||||
async def async_step_reauth(
|
||||
self, entry_data: Mapping[str, Any]
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle flow upon an API authentication error."""
|
||||
self._entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
|
||||
self._host = entry_data[CONF_HOST]
|
||||
@ -248,7 +254,7 @@ class FritzBoxToolsFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
def _show_setup_form_reauth_confirm(
|
||||
self, user_input: dict[str, Any], errors: dict[str, str] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Show the reauth form to the user."""
|
||||
default_username = user_input.get(CONF_USERNAME)
|
||||
return self.async_show_form(
|
||||
@ -265,7 +271,7 @@ class FritzBoxToolsFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_reauth_confirm(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Dialog that informs the user that reauth is required."""
|
||||
if user_input is None:
|
||||
return self._show_setup_form_reauth_confirm(
|
||||
@ -299,7 +305,7 @@ class FritzBoxToolsOptionsFlowHandler(OptionsFlowWithConfigEntry):
|
||||
|
||||
async def async_step_init(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle options flow."""
|
||||
|
||||
if user_input is not None:
|
||||
|
@ -11,9 +11,8 @@ from requests.exceptions import HTTPError
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components import ssdp
|
||||
from homeassistant.config_entries import ConfigEntry, ConfigFlow
|
||||
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
|
||||
from .const import DEFAULT_HOST, DEFAULT_USERNAME, DOMAIN
|
||||
|
||||
@ -51,7 +50,7 @@ class FritzboxConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
self._password: str | None = None
|
||||
self._username: str | None = None
|
||||
|
||||
def _get_entry(self, name: str) -> FlowResult:
|
||||
def _get_entry(self, name: str) -> ConfigFlowResult:
|
||||
return self.async_create_entry(
|
||||
title=name,
|
||||
data={
|
||||
@ -92,7 +91,7 @@ class FritzboxConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle a flow initialized by the user."""
|
||||
errors = {}
|
||||
|
||||
@ -116,7 +115,9 @@ class FritzboxConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
step_id="user", data_schema=DATA_SCHEMA_USER, errors=errors
|
||||
)
|
||||
|
||||
async def async_step_ssdp(self, discovery_info: ssdp.SsdpServiceInfo) -> FlowResult:
|
||||
async def async_step_ssdp(
|
||||
self, discovery_info: ssdp.SsdpServiceInfo
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle a flow initialized by discovery."""
|
||||
host = urlparse(discovery_info.ssdp_location).hostname
|
||||
assert isinstance(host, str)
|
||||
@ -153,7 +154,7 @@ class FritzboxConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_confirm(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle user-confirmation of discovered node."""
|
||||
errors = {}
|
||||
|
||||
@ -176,7 +177,9 @@ class FritzboxConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
errors=errors,
|
||||
)
|
||||
|
||||
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
|
||||
async def async_step_reauth(
|
||||
self, entry_data: Mapping[str, Any]
|
||||
) -> ConfigFlowResult:
|
||||
"""Trigger a reauthentication flow."""
|
||||
entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
|
||||
assert entry is not None
|
||||
@ -189,7 +192,7 @@ class FritzboxConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_reauth_confirm(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle reauthorization flow."""
|
||||
errors = {}
|
||||
|
||||
|
@ -9,7 +9,13 @@ from fritzconnection.core.exceptions import FritzConnectionException, FritzSecur
|
||||
from requests.exceptions import ConnectionError as RequestsConnectionError
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.config_entries import (
|
||||
SOURCE_IMPORT,
|
||||
ConfigEntry,
|
||||
ConfigFlow,
|
||||
ConfigFlowResult,
|
||||
OptionsFlow,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
CONF_HOST,
|
||||
CONF_NAME,
|
||||
@ -18,7 +24,6 @@ from homeassistant.const import (
|
||||
CONF_USERNAME,
|
||||
)
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
|
||||
from .base import FritzBoxPhonebook
|
||||
from .const import (
|
||||
@ -54,7 +59,7 @@ class ConnectResult(StrEnum):
|
||||
SUCCESS = "success"
|
||||
|
||||
|
||||
class FritzBoxCallMonitorConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class FritzBoxCallMonitorConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a fritzbox_callmonitor config flow."""
|
||||
|
||||
VERSION = 1
|
||||
@ -73,7 +78,7 @@ class FritzBoxCallMonitorConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
"""Initialize flow."""
|
||||
self._phonebook_names: list[str] | None = None
|
||||
|
||||
def _get_config_entry(self) -> FlowResult:
|
||||
def _get_config_entry(self) -> ConfigFlowResult:
|
||||
"""Create and return an config entry."""
|
||||
return self.async_create_entry(
|
||||
title=self._phonebook_name,
|
||||
@ -132,14 +137,14 @@ class FritzBoxCallMonitorConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
@staticmethod
|
||||
@callback
|
||||
def async_get_options_flow(
|
||||
config_entry: config_entries.ConfigEntry,
|
||||
config_entry: ConfigEntry,
|
||||
) -> FritzBoxCallMonitorOptionsFlowHandler:
|
||||
"""Get the options flow for this handler."""
|
||||
return FritzBoxCallMonitorOptionsFlowHandler(config_entry)
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle a flow initialized by the user."""
|
||||
|
||||
if user_input is None:
|
||||
@ -164,7 +169,7 @@ class FritzBoxCallMonitorConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
if result != ConnectResult.SUCCESS:
|
||||
return self.async_abort(reason=result)
|
||||
|
||||
if self.context["source"] == config_entries.SOURCE_IMPORT:
|
||||
if self.context["source"] == SOURCE_IMPORT:
|
||||
self._phonebook_id = user_input[CONF_PHONEBOOK]
|
||||
self._phonebook_name = user_input[CONF_NAME]
|
||||
|
||||
@ -182,7 +187,7 @@ class FritzBoxCallMonitorConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_phonebook(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle a flow to chose one of multiple available phonebooks."""
|
||||
|
||||
if self._phonebook_names is None:
|
||||
@ -206,10 +211,10 @@ class FritzBoxCallMonitorConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
return self._get_config_entry()
|
||||
|
||||
|
||||
class FritzBoxCallMonitorOptionsFlowHandler(config_entries.OptionsFlow):
|
||||
class FritzBoxCallMonitorOptionsFlowHandler(OptionsFlow):
|
||||
"""Handle a fritzbox_callmonitor options flow."""
|
||||
|
||||
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
|
||||
def __init__(self, config_entry: ConfigEntry) -> None:
|
||||
"""Initialize."""
|
||||
self.config_entry = config_entry
|
||||
|
||||
@ -240,7 +245,7 @@ class FritzBoxCallMonitorOptionsFlowHandler(config_entries.OptionsFlow):
|
||||
|
||||
async def async_step_init(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Manage the options."""
|
||||
|
||||
option_schema_prefixes = self._get_option_schema_prefixes()
|
||||
|
@ -8,11 +8,10 @@ from typing import Any, Final
|
||||
from pyfronius import Fronius, FroniusError
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.dhcp import DhcpServiceInfo
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import CONF_HOST
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
|
||||
@ -73,7 +72,7 @@ async def validate_host(
|
||||
)
|
||||
|
||||
|
||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class FroniusConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow for Fronius."""
|
||||
|
||||
VERSION = 1
|
||||
@ -84,7 +83,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the initial step."""
|
||||
if user_input is None:
|
||||
return self.async_show_form(
|
||||
@ -110,7 +109,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
step_id="user", data_schema=STEP_USER_DATA_SCHEMA, errors=errors
|
||||
)
|
||||
|
||||
async def async_step_dhcp(self, discovery_info: DhcpServiceInfo) -> FlowResult:
|
||||
async def async_step_dhcp(
|
||||
self, discovery_info: DhcpServiceInfo
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle a flow initiated by the DHCP client."""
|
||||
for entry in self._async_current_entries(include_ignore=False):
|
||||
if entry.data[CONF_HOST].lstrip("http://").rstrip("/").lower() in (
|
||||
@ -133,7 +134,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_confirm_discovery(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Attempt to confirm."""
|
||||
title = create_title(self.info)
|
||||
if user_input is not None:
|
||||
|
@ -14,10 +14,9 @@ from afsapi import (
|
||||
)
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import ssdp
|
||||
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import CONF_HOST, CONF_PIN, CONF_PORT
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
|
||||
from .const import (
|
||||
CONF_WEBFSAPI_URL,
|
||||
@ -51,18 +50,18 @@ def hostname_from_url(url: str) -> str:
|
||||
return str(urlparse(url).hostname)
|
||||
|
||||
|
||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class FrontierSiliconConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow for Frontier Silicon Media Player."""
|
||||
|
||||
VERSION = 1
|
||||
|
||||
_name: str
|
||||
_webfsapi_url: str
|
||||
_reauth_entry: config_entries.ConfigEntry | None = None # Only used in reauth flows
|
||||
_reauth_entry: ConfigEntry | None = None # Only used in reauth flows
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the initial step of manual configuration."""
|
||||
errors = {}
|
||||
|
||||
@ -87,7 +86,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
step_id="user", data_schema=data_schema, errors=errors
|
||||
)
|
||||
|
||||
async def async_step_ssdp(self, discovery_info: ssdp.SsdpServiceInfo) -> FlowResult:
|
||||
async def async_step_ssdp(
|
||||
self, discovery_info: ssdp.SsdpServiceInfo
|
||||
) -> ConfigFlowResult:
|
||||
"""Process entity discovered via SSDP."""
|
||||
|
||||
device_url = discovery_info.ssdp_location
|
||||
@ -131,7 +132,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
return await self.async_step_confirm()
|
||||
|
||||
async def _async_step_device_config_if_needed(self) -> FlowResult:
|
||||
async def _async_step_device_config_if_needed(self) -> ConfigFlowResult:
|
||||
"""Most users will not have changed the default PIN on their radio.
|
||||
|
||||
We try to use this default PIN, and only if this fails ask for it via `async_step_device_config`
|
||||
@ -159,7 +160,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_confirm(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Allow the user to confirm adding the device. Used when the default PIN could successfully be used."""
|
||||
|
||||
if user_input is not None:
|
||||
@ -170,7 +171,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
step_id="confirm", description_placeholders={"name": self._name}
|
||||
)
|
||||
|
||||
async def async_step_reauth(self, config: Mapping[str, Any]) -> FlowResult:
|
||||
async def async_step_reauth(self, config: Mapping[str, Any]) -> ConfigFlowResult:
|
||||
"""Perform reauth upon an API authentication error."""
|
||||
self._webfsapi_url = config[CONF_WEBFSAPI_URL]
|
||||
|
||||
@ -182,7 +183,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_device_config(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle device configuration step.
|
||||
|
||||
We ask for the PIN in this step.
|
||||
|
@ -10,8 +10,8 @@ from fullykiosk import FullyKiosk
|
||||
from fullykiosk.exceptions import FullyKioskError
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.dhcp import DhcpServiceInfo
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import (
|
||||
CONF_HOST,
|
||||
CONF_MAC,
|
||||
@ -19,7 +19,6 @@ from homeassistant.const import (
|
||||
CONF_SSL,
|
||||
CONF_VERIFY_SSL,
|
||||
)
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
from homeassistant.helpers.device_registry import format_mac
|
||||
from homeassistant.helpers.service_info.mqtt import MqttServiceInfo
|
||||
@ -27,7 +26,7 @@ from homeassistant.helpers.service_info.mqtt import MqttServiceInfo
|
||||
from .const import DEFAULT_PORT, DOMAIN, LOGGER
|
||||
|
||||
|
||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class FullyKioskConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow for Fully Kiosk Browser."""
|
||||
|
||||
VERSION = 1
|
||||
@ -42,7 +41,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
user_input: dict[str, Any],
|
||||
errors: dict[str, str],
|
||||
description_placeholders: dict[str, str] | Any = None,
|
||||
) -> FlowResult | None:
|
||||
) -> ConfigFlowResult | None:
|
||||
fully = FullyKiosk(
|
||||
async_get_clientsession(self.hass),
|
||||
host,
|
||||
@ -85,7 +84,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the initial step."""
|
||||
errors: dict[str, str] = {}
|
||||
placeholders: dict[str, str] = {}
|
||||
@ -110,7 +109,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
errors=errors,
|
||||
)
|
||||
|
||||
async def async_step_dhcp(self, discovery_info: DhcpServiceInfo) -> FlowResult:
|
||||
async def async_step_dhcp(
|
||||
self, discovery_info: DhcpServiceInfo
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle dhcp discovery."""
|
||||
mac = format_mac(discovery_info.macaddress)
|
||||
|
||||
@ -129,7 +130,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_discovery_confirm(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Confirm discovery."""
|
||||
errors: dict[str, str] = {}
|
||||
if user_input is not None:
|
||||
@ -157,7 +158,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
errors=errors,
|
||||
)
|
||||
|
||||
async def async_step_mqtt(self, discovery_info: MqttServiceInfo) -> FlowResult:
|
||||
async def async_step_mqtt(
|
||||
self, discovery_info: MqttServiceInfo
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle a flow initialized by MQTT discovery."""
|
||||
device_info: dict[str, Any] = json.loads(discovery_info.payload)
|
||||
device_id: str = device_info["deviceId"]
|
||||
|
@ -8,8 +8,7 @@ from aiohttp import ClientResponseError
|
||||
from odp_amsterdam import ODPAmsterdam, VehicleType
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.helpers import aiohttp_client
|
||||
|
||||
from .const import DOMAIN
|
||||
@ -17,7 +16,7 @@ from .const import DOMAIN
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class GaragesAmsterdamConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow for Garages Amsterdam."""
|
||||
|
||||
VERSION = 1
|
||||
@ -25,7 +24,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the initial step."""
|
||||
if self._options is None:
|
||||
self._options = []
|
||||
|
@ -10,13 +10,13 @@ from gardena_bluetooth.exceptions import CharacteristicNotFound, CommunicationFa
|
||||
from gardena_bluetooth.parse import ManufacturerData, ProductType
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.bluetooth import (
|
||||
BluetoothServiceInfo,
|
||||
async_discovered_service_info,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import CONF_ADDRESS
|
||||
from homeassistant.data_entry_flow import AbortFlow, FlowResult
|
||||
from homeassistant.data_entry_flow import AbortFlow
|
||||
|
||||
from . import get_connection
|
||||
from .const import DOMAIN
|
||||
@ -55,7 +55,7 @@ def _get_name(discovery_info: BluetoothServiceInfo):
|
||||
return PRODUCT_NAMES.get(product_type, "Gardena Device")
|
||||
|
||||
|
||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class GardenaBluetoothConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow for Gardena Bluetooth."""
|
||||
|
||||
VERSION = 1
|
||||
@ -82,7 +82,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_bluetooth(
|
||||
self, discovery_info: BluetoothServiceInfo
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the bluetooth discovery step."""
|
||||
_LOGGER.debug("Discovered device: %s", discovery_info)
|
||||
if not _is_supported(discovery_info):
|
||||
@ -96,7 +96,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_confirm(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Confirm discovery."""
|
||||
assert self.address
|
||||
title = self.devices[self.address]
|
||||
@ -117,7 +117,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the initial step."""
|
||||
if user_input is not None:
|
||||
self.address = user_input[CONF_ADDRESS]
|
||||
|
@ -4,14 +4,13 @@ from typing import Any
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import (
|
||||
CONF_LATITUDE,
|
||||
CONF_LONGITUDE,
|
||||
CONF_RADIUS,
|
||||
CONF_SCAN_INTERVAL,
|
||||
)
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
|
||||
from .const import CONF_CATEGORIES, DEFAULT_RADIUS, DEFAULT_SCAN_INTERVAL, DOMAIN
|
||||
@ -23,10 +22,12 @@ DATA_SCHEMA = vol.Schema(
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class GdacsFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class GdacsFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a GDACS config flow."""
|
||||
|
||||
async def _show_form(self, errors: dict[str, str] | None = None) -> FlowResult:
|
||||
async def _show_form(
|
||||
self, errors: dict[str, str] | None = None
|
||||
) -> ConfigFlowResult:
|
||||
"""Show the form to the user."""
|
||||
return self.async_show_form(
|
||||
step_id="user", data_schema=DATA_SCHEMA, errors=errors or {}
|
||||
@ -34,7 +35,7 @@ class GdacsFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the start of the config flow."""
|
||||
_LOGGER.debug("User input: %s", user_input)
|
||||
if not user_input:
|
||||
|
@ -30,7 +30,12 @@ from homeassistant.components.stream import (
|
||||
SOURCE_TIMEOUT,
|
||||
create_stream,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry, ConfigFlow, OptionsFlow
|
||||
from homeassistant.config_entries import (
|
||||
ConfigEntry,
|
||||
ConfigFlow,
|
||||
ConfigFlowResult,
|
||||
OptionsFlow,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
CONF_AUTHENTICATION,
|
||||
CONF_NAME,
|
||||
@ -41,7 +46,7 @@ from homeassistant.const import (
|
||||
HTTP_DIGEST_AUTHENTICATION,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResult, UnknownFlow
|
||||
from homeassistant.data_entry_flow import UnknownFlow
|
||||
from homeassistant.exceptions import TemplateError
|
||||
from homeassistant.helpers import config_validation as cv, template as template_helper
|
||||
from homeassistant.helpers.httpx_client import get_async_client
|
||||
@ -313,7 +318,7 @@ class GenericIPCamConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the start of the config flow."""
|
||||
errors = {}
|
||||
hass = self.hass
|
||||
@ -357,7 +362,7 @@ class GenericIPCamConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_user_confirm_still(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle user clicking confirm after still preview."""
|
||||
if user_input:
|
||||
if not user_input.get(CONF_CONFIRMED_OK):
|
||||
@ -389,7 +394,7 @@ class GenericOptionsFlowHandler(OptionsFlow):
|
||||
|
||||
async def async_step_init(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Manage Generic IP Camera options."""
|
||||
errors: dict[str, str] = {}
|
||||
hass = self.hass
|
||||
@ -430,7 +435,7 @@ class GenericOptionsFlowHandler(OptionsFlow):
|
||||
|
||||
async def async_step_confirm_still(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle user clicking confirm after still preview."""
|
||||
if user_input:
|
||||
if not user_input.get(CONF_CONFIRMED_OK):
|
||||
|
@ -6,7 +6,7 @@ from typing import Any
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import (
|
||||
CONF_LATITUDE,
|
||||
CONF_LOCATION,
|
||||
@ -15,7 +15,6 @@ from homeassistant.const import (
|
||||
CONF_URL,
|
||||
UnitOfLength,
|
||||
)
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.helpers import config_validation as cv, selector
|
||||
from homeassistant.util.unit_conversion import DistanceConverter
|
||||
|
||||
@ -31,12 +30,12 @@ DATA_SCHEMA = vol.Schema(
|
||||
)
|
||||
|
||||
|
||||
class GeoJsonEventsFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class GeoJsonEventsFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a GeoJSON events config flow."""
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the start of the config flow."""
|
||||
if not user_input:
|
||||
suggested_values: Mapping[str, Any] = {
|
||||
|
@ -7,7 +7,7 @@ from typing import Any
|
||||
|
||||
from geocachingapi.geocachingapi import GeocachingApi
|
||||
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.config_entries import ConfigFlowResult
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
from homeassistant.helpers.config_entry_oauth2_flow import AbstractOAuth2FlowHandler
|
||||
|
||||
@ -25,19 +25,21 @@ class GeocachingFlowHandler(AbstractOAuth2FlowHandler, domain=DOMAIN):
|
||||
"""Return logger."""
|
||||
return logging.getLogger(__name__)
|
||||
|
||||
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
|
||||
async def async_step_reauth(
|
||||
self, entry_data: Mapping[str, Any]
|
||||
) -> ConfigFlowResult:
|
||||
"""Perform reauth upon an API authentication error."""
|
||||
return await self.async_step_reauth_confirm()
|
||||
|
||||
async def async_step_reauth_confirm(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Dialog that informs the user that reauth is required."""
|
||||
if user_input is None:
|
||||
return self.async_show_form(step_id="reauth_confirm")
|
||||
return await self.async_step_user()
|
||||
|
||||
async def async_oauth_create_entry(self, data: dict[str, Any]) -> FlowResult:
|
||||
async def async_oauth_create_entry(self, data: dict[str, Any]) -> ConfigFlowResult:
|
||||
"""Create an oauth config entry or update existing entry for reauth."""
|
||||
api = GeocachingApi(
|
||||
environment=ENVIRONMENT,
|
||||
|
@ -3,7 +3,7 @@ import logging
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.config_entries import ConfigFlow
|
||||
from homeassistant.const import (
|
||||
CONF_LATITUDE,
|
||||
CONF_LONGITUDE,
|
||||
@ -34,7 +34,7 @@ DATA_SCHEMA = vol.Schema(
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class GeonetnzQuakesFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class GeonetnzQuakesFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a GeoNet NZ Quakes config flow."""
|
||||
|
||||
async def _show_form(self, errors=None):
|
||||
|
@ -1,7 +1,7 @@
|
||||
"""Config flow to configure the GeoNet NZ Volcano integration."""
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.config_entries import ConfigFlow
|
||||
from homeassistant.const import (
|
||||
CONF_LATITUDE,
|
||||
CONF_LONGITUDE,
|
||||
@ -31,7 +31,7 @@ def configured_instances(hass):
|
||||
}
|
||||
|
||||
|
||||
class GeonetnzVolcanoFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class GeonetnzVolcanoFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a GeoNet NZ Volcano config flow."""
|
||||
|
||||
async def _show_form(self, errors=None):
|
||||
|
@ -8,22 +8,21 @@ from aiohttp.client_exceptions import ClientConnectorError
|
||||
from gios import ApiError, Gios, InvalidSensorsDataError, NoStationError
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import CONF_NAME
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
|
||||
from .const import API_TIMEOUT, CONF_STATION_ID, DOMAIN
|
||||
|
||||
|
||||
class GiosFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class GiosFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
"""Config flow for GIOS."""
|
||||
|
||||
VERSION = 1
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle a flow initialized by the user."""
|
||||
errors = {}
|
||||
|
||||
|
@ -14,10 +14,14 @@ from aiogithubapi import (
|
||||
from aiogithubapi.const import OAUTH_USER_LOGIN
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.config_entries import (
|
||||
ConfigEntry,
|
||||
ConfigFlow,
|
||||
ConfigFlowResult,
|
||||
OptionsFlow,
|
||||
)
|
||||
from homeassistant.const import CONF_ACCESS_TOKEN
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.helpers.aiohttp_client import (
|
||||
SERVER_SOFTWARE,
|
||||
async_get_clientsession,
|
||||
@ -88,7 +92,7 @@ async def get_repositories(hass: HomeAssistant, access_token: str) -> list[str]:
|
||||
)
|
||||
|
||||
|
||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class GitHubConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow for GitHub."""
|
||||
|
||||
VERSION = 1
|
||||
@ -104,7 +108,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
async def async_step_user(
|
||||
self,
|
||||
user_input: dict[str, Any] | None = None,
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the initial step."""
|
||||
if self._async_current_entries():
|
||||
return self.async_abort(reason="already_configured")
|
||||
@ -114,7 +118,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
async def async_step_device(
|
||||
self,
|
||||
user_input: dict[str, Any] | None = None,
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle device steps."""
|
||||
|
||||
async def _wait_for_login() -> None:
|
||||
@ -167,7 +171,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
async def async_step_repositories(
|
||||
self,
|
||||
user_input: dict[str, Any] | None = None,
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle repositories step."""
|
||||
|
||||
if TYPE_CHECKING:
|
||||
@ -196,30 +200,30 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
async def async_step_could_not_register(
|
||||
self,
|
||||
user_input: dict[str, Any] | None = None,
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle issues that need transition await from progress step."""
|
||||
return self.async_abort(reason="could_not_register")
|
||||
|
||||
@staticmethod
|
||||
@callback
|
||||
def async_get_options_flow(
|
||||
config_entry: config_entries.ConfigEntry,
|
||||
config_entry: ConfigEntry,
|
||||
) -> OptionsFlowHandler:
|
||||
"""Get the options flow for this handler."""
|
||||
return OptionsFlowHandler(config_entry)
|
||||
|
||||
|
||||
class OptionsFlowHandler(config_entries.OptionsFlow):
|
||||
class OptionsFlowHandler(OptionsFlow):
|
||||
"""Handle a option flow for GitHub."""
|
||||
|
||||
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
|
||||
def __init__(self, config_entry: ConfigEntry) -> None:
|
||||
"""Initialize options flow."""
|
||||
self.config_entry = config_entry
|
||||
|
||||
async def async_step_init(
|
||||
self,
|
||||
user_input: dict[str, Any] | None = None,
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle options flow."""
|
||||
if not user_input:
|
||||
configured_repositories: list[str] = self.config_entry.options[
|
||||
|
@ -10,7 +10,7 @@ from glances_api.exceptions import (
|
||||
)
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import (
|
||||
CONF_HOST,
|
||||
CONF_PASSWORD,
|
||||
@ -19,7 +19,6 @@ from homeassistant.const import (
|
||||
CONF_USERNAME,
|
||||
CONF_VERIFY_SSL,
|
||||
)
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
|
||||
from . import ServerVersionMismatch, get_api
|
||||
from .const import DEFAULT_HOST, DEFAULT_PORT, DOMAIN
|
||||
@ -36,13 +35,15 @@ DATA_SCHEMA = vol.Schema(
|
||||
)
|
||||
|
||||
|
||||
class GlancesFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class GlancesFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a Glances config flow."""
|
||||
|
||||
VERSION = 1
|
||||
_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."""
|
||||
self._reauth_entry = self.hass.config_entries.async_get_entry(
|
||||
self.context["entry_id"]
|
||||
@ -51,7 +52,7 @@ class GlancesFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_reauth_confirm(
|
||||
self, user_input: dict[str, str] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Confirm reauth dialog."""
|
||||
errors = {}
|
||||
assert self._reauth_entry
|
||||
@ -85,7 +86,7 @@ class GlancesFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the initial step."""
|
||||
errors = {}
|
||||
if user_input is not None:
|
||||
|
@ -7,10 +7,9 @@ from typing import Any
|
||||
from goalzero import Yeti, exceptions
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import dhcp
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import CONF_HOST, CONF_NAME
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
from homeassistant.helpers.device_registry import format_mac
|
||||
|
||||
@ -19,7 +18,7 @@ from .const import DEFAULT_NAME, DOMAIN, MANUFACTURER
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class GoalZeroFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class GoalZeroFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow for Goal Zero Yeti."""
|
||||
|
||||
VERSION = 1
|
||||
@ -28,7 +27,9 @@ class GoalZeroFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
"""Initialize a Goal Zero Yeti flow."""
|
||||
self.ip_address: str | None = None
|
||||
|
||||
async def async_step_dhcp(self, discovery_info: dhcp.DhcpServiceInfo) -> FlowResult:
|
||||
async def async_step_dhcp(
|
||||
self, discovery_info: dhcp.DhcpServiceInfo
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle dhcp discovery."""
|
||||
self.ip_address = discovery_info.ip
|
||||
|
||||
@ -43,7 +44,7 @@ class GoalZeroFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_confirm_discovery(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Allow the user to confirm adding the device."""
|
||||
if user_input is not None:
|
||||
return self.async_create_entry(
|
||||
@ -65,7 +66,7 @@ class GoalZeroFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle a flow initiated by the user."""
|
||||
errors = {}
|
||||
if user_input is not None:
|
||||
|
@ -10,14 +10,14 @@ from ismartgate.const import GogoGate2ApiErrorCode, ISmartGateApiErrorCode
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components import dhcp, zeroconf
|
||||
from homeassistant.config_entries import ConfigFlow
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import (
|
||||
CONF_DEVICE,
|
||||
CONF_IP_ADDRESS,
|
||||
CONF_PASSWORD,
|
||||
CONF_USERNAME,
|
||||
)
|
||||
from homeassistant.data_entry_flow import AbortFlow, FlowResult
|
||||
from homeassistant.data_entry_flow import AbortFlow
|
||||
|
||||
from .common import get_api
|
||||
from .const import DEVICE_TYPE_GOGOGATE2, DEVICE_TYPE_ISMARTGATE, DOMAIN
|
||||
@ -40,19 +40,21 @@ class Gogogate2FlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_homekit(
|
||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle homekit discovery."""
|
||||
await self.async_set_unique_id(
|
||||
discovery_info.properties[zeroconf.ATTR_PROPERTIES_ID]
|
||||
)
|
||||
return await self._async_discovery_handler(discovery_info.host)
|
||||
|
||||
async def async_step_dhcp(self, discovery_info: dhcp.DhcpServiceInfo) -> FlowResult:
|
||||
async def async_step_dhcp(
|
||||
self, discovery_info: dhcp.DhcpServiceInfo
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle dhcp discovery."""
|
||||
await self.async_set_unique_id(discovery_info.macaddress)
|
||||
return await self._async_discovery_handler(discovery_info.ip)
|
||||
|
||||
async def _async_discovery_handler(self, ip_address: str) -> FlowResult:
|
||||
async def _async_discovery_handler(self, ip_address: str) -> ConfigFlowResult:
|
||||
"""Start the user flow from any discovery."""
|
||||
self.context[CONF_IP_ADDRESS] = ip_address
|
||||
self._abort_if_unique_id_configured({CONF_IP_ADDRESS: ip_address})
|
||||
@ -69,7 +71,7 @@ class Gogogate2FlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle user initiated flow."""
|
||||
user_input = user_input or {}
|
||||
errors = {}
|
||||
|
@ -6,9 +6,8 @@ import logging
|
||||
from goodwe import InverterError, connect
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import CONF_HOST
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
|
||||
from .const import CONF_MODEL_FAMILY, DEFAULT_NAME, DOMAIN
|
||||
|
||||
@ -21,12 +20,12 @@ CONFIG_SCHEMA = vol.Schema(
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class GoodweFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class GoodweFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a Goodwe config flow."""
|
||||
|
||||
VERSION = 1
|
||||
|
||||
async def async_step_user(self, user_input: dict | None = None) -> FlowResult:
|
||||
async def async_step_user(self, user_input: dict | None = None) -> ConfigFlowResult:
|
||||
"""Handle a flow initialized by the user."""
|
||||
errors = {}
|
||||
if user_input is not None:
|
||||
|
@ -10,9 +10,8 @@ from gcal_sync.api import GoogleCalendarService
|
||||
from gcal_sync.exceptions import ApiException, ApiForbiddenException
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.config_entries import ConfigEntry, ConfigFlowResult, OptionsFlow
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.helpers import config_entry_oauth2_flow
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
|
||||
@ -74,7 +73,7 @@ class OAuth2FlowHandler(
|
||||
def __init__(self) -> None:
|
||||
"""Set up instance."""
|
||||
super().__init__()
|
||||
self._reauth_config_entry: config_entries.ConfigEntry | None = None
|
||||
self._reauth_config_entry: ConfigEntry | None = None
|
||||
self._device_flow: DeviceFlow | None = None
|
||||
# First attempt is device auth, then fallback to web auth
|
||||
self._web_auth = False
|
||||
@ -94,7 +93,7 @@ class OAuth2FlowHandler(
|
||||
"prompt": "consent",
|
||||
}
|
||||
|
||||
async def async_step_import(self, info: dict[str, Any]) -> FlowResult:
|
||||
async def async_step_import(self, info: dict[str, Any]) -> ConfigFlowResult:
|
||||
"""Import existing auth into a new config entry."""
|
||||
if self._async_current_entries():
|
||||
return self.async_abort(reason="single_instance_allowed")
|
||||
@ -108,7 +107,7 @@ class OAuth2FlowHandler(
|
||||
|
||||
async def async_step_auth(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Create an entry for auth."""
|
||||
# The default behavior from the parent class is to redirect the
|
||||
# user with an external step. When using the device flow, we instead
|
||||
@ -179,13 +178,13 @@ class OAuth2FlowHandler(
|
||||
|
||||
async def async_step_creation(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle external yaml configuration."""
|
||||
if not self._web_auth and self.external_data.get(DEVICE_AUTH_CREDS) is None:
|
||||
return self.async_abort(reason="code_expired")
|
||||
return await super().async_step_creation(user_input)
|
||||
|
||||
async def async_oauth_create_entry(self, data: dict) -> FlowResult:
|
||||
async def async_oauth_create_entry(self, data: dict) -> ConfigFlowResult:
|
||||
"""Create an entry for the flow, or update existing entry."""
|
||||
data[CONF_CREDENTIAL_TYPE] = (
|
||||
CredentialType.WEB_AUTH if self._web_auth else CredentialType.DEVICE_AUTH
|
||||
@ -230,7 +229,9 @@ class OAuth2FlowHandler(
|
||||
},
|
||||
)
|
||||
|
||||
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
|
||||
async def async_step_reauth(
|
||||
self, entry_data: Mapping[str, Any]
|
||||
) -> ConfigFlowResult:
|
||||
"""Perform reauth upon an API authentication error."""
|
||||
self._reauth_config_entry = self.hass.config_entries.async_get_entry(
|
||||
self.context["entry_id"]
|
||||
@ -240,7 +241,7 @@ class OAuth2FlowHandler(
|
||||
|
||||
async def async_step_reauth_confirm(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Confirm reauth dialog."""
|
||||
if user_input is None:
|
||||
return self.async_show_form(step_id="reauth_confirm")
|
||||
@ -249,22 +250,22 @@ class OAuth2FlowHandler(
|
||||
@staticmethod
|
||||
@callback
|
||||
def async_get_options_flow(
|
||||
config_entry: config_entries.ConfigEntry,
|
||||
) -> config_entries.OptionsFlow:
|
||||
config_entry: ConfigEntry,
|
||||
) -> OptionsFlow:
|
||||
"""Create an options flow."""
|
||||
return OptionsFlowHandler(config_entry)
|
||||
|
||||
|
||||
class OptionsFlowHandler(config_entries.OptionsFlow):
|
||||
class OptionsFlowHandler(OptionsFlow):
|
||||
"""Google Calendar options flow."""
|
||||
|
||||
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
|
||||
def __init__(self, config_entry: ConfigEntry) -> None:
|
||||
"""Initialize options flow."""
|
||||
self.config_entry = config_entry
|
||||
|
||||
async def async_step_init(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Manage the options."""
|
||||
if user_input is not None:
|
||||
return self.async_create_entry(title="", data=user_input)
|
||||
|
@ -1,11 +1,11 @@
|
||||
"""Config flow for google assistant component."""
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.config_entries import ConfigFlow
|
||||
|
||||
from .const import CONF_PROJECT_ID, DOMAIN
|
||||
|
||||
|
||||
class GoogleAssistantHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class GoogleAssistantHandler(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow."""
|
||||
|
||||
VERSION = 1
|
||||
|
@ -7,10 +7,8 @@ from typing import Any
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.config_entries import ConfigEntry, ConfigFlowResult, OptionsFlow
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.helpers import config_entry_oauth2_flow
|
||||
|
||||
from .const import CONF_LANGUAGE_CODE, DEFAULT_NAME, DOMAIN, SUPPORTED_LANGUAGE_CODES
|
||||
@ -43,7 +41,9 @@ class OAuth2FlowHandler(
|
||||
"prompt": "consent",
|
||||
}
|
||||
|
||||
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
|
||||
async def async_step_reauth(
|
||||
self, entry_data: Mapping[str, Any]
|
||||
) -> ConfigFlowResult:
|
||||
"""Perform reauth upon an API authentication error."""
|
||||
self.reauth_entry = self.hass.config_entries.async_get_entry(
|
||||
self.context["entry_id"]
|
||||
@ -52,13 +52,13 @@ class OAuth2FlowHandler(
|
||||
|
||||
async def async_step_reauth_confirm(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Confirm reauth dialog."""
|
||||
if user_input is None:
|
||||
return self.async_show_form(step_id="reauth_confirm")
|
||||
return await self.async_step_user()
|
||||
|
||||
async def async_oauth_create_entry(self, data: dict[str, Any]) -> FlowResult:
|
||||
async def async_oauth_create_entry(self, data: dict[str, Any]) -> ConfigFlowResult:
|
||||
"""Create an entry for the flow, or update existing entry."""
|
||||
if self.reauth_entry:
|
||||
self.hass.config_entries.async_update_entry(self.reauth_entry, data=data)
|
||||
@ -80,22 +80,22 @@ class OAuth2FlowHandler(
|
||||
@staticmethod
|
||||
@callback
|
||||
def async_get_options_flow(
|
||||
config_entry: config_entries.ConfigEntry,
|
||||
) -> config_entries.OptionsFlow:
|
||||
config_entry: ConfigEntry,
|
||||
) -> OptionsFlow:
|
||||
"""Create the options flow."""
|
||||
return OptionsFlowHandler(config_entry)
|
||||
|
||||
|
||||
class OptionsFlowHandler(config_entries.OptionsFlow):
|
||||
class OptionsFlowHandler(OptionsFlow):
|
||||
"""Google Assistant SDK options flow."""
|
||||
|
||||
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
|
||||
def __init__(self, config_entry: ConfigEntry) -> None:
|
||||
"""Initialize options flow."""
|
||||
self.config_entry = config_entry
|
||||
|
||||
async def async_step_init(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Manage the options."""
|
||||
if user_input is not None:
|
||||
return self.async_create_entry(title="", data=user_input)
|
||||
|
@ -11,10 +11,14 @@ from google.api_core.exceptions import ClientError
|
||||
import google.generativeai as genai
|
||||
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.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.helpers.selector import (
|
||||
NumberSelector,
|
||||
NumberSelectorConfig,
|
||||
@ -66,14 +70,14 @@ async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> None:
|
||||
await hass.async_add_executor_job(partial(genai.list_models))
|
||||
|
||||
|
||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class GoogleGenerativeAIConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow for Google Generative AI Conversation."""
|
||||
|
||||
VERSION = 1
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the initial step."""
|
||||
if user_input is None:
|
||||
return self.async_show_form(
|
||||
@ -103,22 +107,22 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
@staticmethod
|
||||
def async_get_options_flow(
|
||||
config_entry: config_entries.ConfigEntry,
|
||||
) -> config_entries.OptionsFlow:
|
||||
config_entry: ConfigEntry,
|
||||
) -> OptionsFlow:
|
||||
"""Create the options flow."""
|
||||
return OptionsFlow(config_entry)
|
||||
return GoogleGenerativeAIOptionsFlow(config_entry)
|
||||
|
||||
|
||||
class OptionsFlow(config_entries.OptionsFlow):
|
||||
class GoogleGenerativeAIOptionsFlow(OptionsFlow):
|
||||
"""Google Generative AI config flow options handler."""
|
||||
|
||||
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
|
||||
def __init__(self, config_entry: ConfigEntry) -> None:
|
||||
"""Initialize options flow."""
|
||||
self.config_entry = config_entry
|
||||
|
||||
async def async_step_init(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Manage the options."""
|
||||
if user_input is not None:
|
||||
return self.async_create_entry(
|
||||
|
@ -8,9 +8,8 @@ from typing import Any, cast
|
||||
from google.oauth2.credentials import Credentials
|
||||
from googleapiclient.discovery import build
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.config_entries import ConfigEntry, ConfigFlowResult
|
||||
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_TOKEN
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.helpers import config_entry_oauth2_flow
|
||||
|
||||
from .const import DEFAULT_ACCESS, DOMAIN
|
||||
@ -40,7 +39,9 @@ class OAuth2FlowHandler(
|
||||
"prompt": "consent",
|
||||
}
|
||||
|
||||
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
|
||||
async def async_step_reauth(
|
||||
self, entry_data: Mapping[str, Any]
|
||||
) -> ConfigFlowResult:
|
||||
"""Perform reauth upon an API authentication error."""
|
||||
self.reauth_entry = self.hass.config_entries.async_get_entry(
|
||||
self.context["entry_id"]
|
||||
@ -49,13 +50,13 @@ class OAuth2FlowHandler(
|
||||
|
||||
async def async_step_reauth_confirm(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Confirm reauth dialog."""
|
||||
if user_input is None:
|
||||
return self.async_show_form(step_id="reauth_confirm")
|
||||
return await self.async_step_user()
|
||||
|
||||
async def async_oauth_create_entry(self, data: dict[str, Any]) -> FlowResult:
|
||||
async def async_oauth_create_entry(self, data: dict[str, Any]) -> ConfigFlowResult:
|
||||
"""Create an entry for the flow, or update existing entry."""
|
||||
|
||||
def _get_profile() -> str:
|
||||
|
@ -8,9 +8,8 @@ from typing import Any
|
||||
from google.oauth2.credentials import Credentials
|
||||
from gspread import Client, GSpreadException
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.config_entries import ConfigEntry, ConfigFlowResult
|
||||
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_TOKEN
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.helpers import config_entry_oauth2_flow
|
||||
|
||||
from .const import DEFAULT_ACCESS, DEFAULT_NAME, DOMAIN
|
||||
@ -42,7 +41,9 @@ class OAuth2FlowHandler(
|
||||
"prompt": "consent",
|
||||
}
|
||||
|
||||
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
|
||||
async def async_step_reauth(
|
||||
self, entry_data: Mapping[str, Any]
|
||||
) -> ConfigFlowResult:
|
||||
"""Perform reauth upon an API authentication error."""
|
||||
self.reauth_entry = self.hass.config_entries.async_get_entry(
|
||||
self.context["entry_id"]
|
||||
@ -51,13 +52,13 @@ class OAuth2FlowHandler(
|
||||
|
||||
async def async_step_reauth_confirm(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Confirm reauth dialog."""
|
||||
if user_input is None:
|
||||
return self.async_show_form(step_id="reauth_confirm")
|
||||
return await self.async_step_user()
|
||||
|
||||
async def async_oauth_create_entry(self, data: dict[str, Any]) -> FlowResult:
|
||||
async def async_oauth_create_entry(self, data: dict[str, Any]) -> ConfigFlowResult:
|
||||
"""Create an entry for the flow, or update existing entry."""
|
||||
service = Client(Credentials(data[CONF_TOKEN][CONF_ACCESS_TOKEN]))
|
||||
|
||||
|
@ -7,8 +7,8 @@ from googleapiclient.discovery import build
|
||||
from googleapiclient.errors import HttpError
|
||||
from googleapiclient.http import HttpRequest
|
||||
|
||||
from homeassistant.config_entries import ConfigFlowResult
|
||||
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_TOKEN
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.helpers import config_entry_oauth2_flow
|
||||
|
||||
from .const import DOMAIN, OAUTH2_SCOPES
|
||||
@ -36,7 +36,7 @@ class OAuth2FlowHandler(
|
||||
"prompt": "consent",
|
||||
}
|
||||
|
||||
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."""
|
||||
try:
|
||||
resource = build(
|
||||
|
@ -5,9 +5,8 @@ from typing import Any
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.tts import CONF_LANG
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
|
||||
from .const import (
|
||||
CONF_TLD,
|
||||
@ -26,14 +25,14 @@ STEP_USER_DATA_SCHEMA = vol.Schema(
|
||||
)
|
||||
|
||||
|
||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class GoogleTranslateConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow for Google Translate text-to-speech."""
|
||||
|
||||
VERSION = 1
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the initial step."""
|
||||
if user_input is not None:
|
||||
self._async_abort_entries_match(
|
||||
@ -50,7 +49,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_onboarding(
|
||||
self, data: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle a flow initialized by onboarding."""
|
||||
return self.async_create_entry(
|
||||
title="Google Translate text-to-speech",
|
||||
|
@ -3,10 +3,14 @@ from __future__ import annotations
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.config_entries import (
|
||||
ConfigEntry,
|
||||
ConfigFlow,
|
||||
ConfigFlowResult,
|
||||
OptionsFlow,
|
||||
)
|
||||
from homeassistant.const import CONF_API_KEY, CONF_LANGUAGE, CONF_MODE, CONF_NAME
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.selector import (
|
||||
SelectSelector,
|
||||
@ -124,14 +128,14 @@ def default_options(hass: HomeAssistant) -> dict[str, str]:
|
||||
}
|
||||
|
||||
|
||||
class GoogleOptionsFlow(config_entries.OptionsFlow):
|
||||
class GoogleOptionsFlow(OptionsFlow):
|
||||
"""Handle an options flow for Google Travel Time."""
|
||||
|
||||
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
|
||||
def __init__(self, config_entry: ConfigEntry) -> None:
|
||||
"""Initialize google options flow."""
|
||||
self.config_entry = config_entry
|
||||
|
||||
async def async_step_init(self, user_input=None) -> FlowResult:
|
||||
async def async_step_init(self, user_input=None) -> ConfigFlowResult:
|
||||
"""Handle the initial step."""
|
||||
if user_input is not None:
|
||||
time_type = user_input.pop(CONF_TIME_TYPE)
|
||||
@ -159,7 +163,7 @@ class GoogleOptionsFlow(config_entries.OptionsFlow):
|
||||
)
|
||||
|
||||
|
||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class GoogleTravelTimeConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow for Google Maps Travel Time."""
|
||||
|
||||
VERSION = 1
|
||||
@ -167,12 +171,12 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
@staticmethod
|
||||
@callback
|
||||
def async_get_options_flow(
|
||||
config_entry: config_entries.ConfigEntry,
|
||||
config_entry: ConfigEntry,
|
||||
) -> GoogleOptionsFlow:
|
||||
"""Get the options flow for this handler."""
|
||||
return GoogleOptionsFlow(config_entry)
|
||||
|
||||
async def async_step_user(self, user_input=None) -> FlowResult:
|
||||
async def async_step_user(self, user_input=None) -> ConfigFlowResult:
|
||||
"""Handle the initial step."""
|
||||
errors = {}
|
||||
user_input = user_input or {}
|
||||
|
@ -10,9 +10,8 @@ from homeassistant.components.bluetooth import (
|
||||
BluetoothServiceInfoBleak,
|
||||
async_discovered_service_info,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigFlow
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import CONF_ADDRESS
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
|
||||
from .const import DOMAIN
|
||||
|
||||
@ -30,7 +29,7 @@ class GoveeConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_bluetooth(
|
||||
self, discovery_info: BluetoothServiceInfoBleak
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the bluetooth discovery step."""
|
||||
await self.async_set_unique_id(discovery_info.address)
|
||||
self._abort_if_unique_id_configured()
|
||||
@ -43,7 +42,7 @@ class GoveeConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_bluetooth_confirm(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Confirm discovery."""
|
||||
assert self._discovered_device is not None
|
||||
device = self._discovered_device
|
||||
@ -62,7 +61,7 @@ class GoveeConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the user step to pick discovered device."""
|
||||
if user_input is not None:
|
||||
address = user_input[CONF_ADDRESS]
|
||||
|
@ -7,9 +7,8 @@ from typing import Any
|
||||
from gps3.agps3threaded import GPSD_PORT as DEFAULT_PORT, HOST as DEFAULT_HOST
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
|
||||
from .const import DOMAIN
|
||||
@ -22,18 +21,18 @@ STEP_USER_DATA_SCHEMA = vol.Schema(
|
||||
)
|
||||
|
||||
|
||||
class GPSDConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class GPSDConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow for GPSD."""
|
||||
|
||||
VERSION = 1
|
||||
|
||||
async def async_step_import(self, import_data: dict[str, Any]) -> FlowResult:
|
||||
async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult:
|
||||
"""Import a config entry from configuration.yaml."""
|
||||
return await self.async_step_user(import_data)
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the initial step."""
|
||||
if user_input is not None:
|
||||
self._async_abort_entries_match(user_input)
|
||||
|
@ -2,7 +2,7 @@
|
||||
import growattServer
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.config_entries import ConfigFlow
|
||||
from homeassistant.const import CONF_NAME, CONF_PASSWORD, CONF_URL, CONF_USERNAME
|
||||
from homeassistant.core import callback
|
||||
|
||||
@ -15,7 +15,7 @@ from .const import (
|
||||
)
|
||||
|
||||
|
||||
class GrowattServerConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class GrowattServerConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Config flow class."""
|
||||
|
||||
VERSION = 1
|
||||
|
@ -7,11 +7,10 @@ from aioguardian import Client
|
||||
from aioguardian.errors import GuardianError
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import dhcp, zeroconf
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import CONF_IP_ADDRESS, CONF_PORT
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
|
||||
from .const import CONF_UID, DOMAIN, LOGGER
|
||||
|
||||
@ -52,7 +51,7 @@ async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> dict[str,
|
||||
}
|
||||
|
||||
|
||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class GuardianConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow for Elexa Guardian."""
|
||||
|
||||
VERSION = 1
|
||||
@ -76,7 +75,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle configuration via the UI."""
|
||||
if user_input is None:
|
||||
return self.async_show_form(
|
||||
@ -100,7 +99,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
title=info[CONF_UID], data={CONF_UID: info["uid"], **user_input}
|
||||
)
|
||||
|
||||
async def async_step_dhcp(self, discovery_info: dhcp.DhcpServiceInfo) -> FlowResult:
|
||||
async def async_step_dhcp(
|
||||
self, discovery_info: dhcp.DhcpServiceInfo
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the configuration via dhcp."""
|
||||
self.discovery_info = {
|
||||
CONF_IP_ADDRESS: discovery_info.ip,
|
||||
@ -113,7 +114,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_zeroconf(
|
||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the configuration via zeroconf."""
|
||||
self.discovery_info = {
|
||||
CONF_IP_ADDRESS: discovery_info.host,
|
||||
@ -123,7 +124,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
await self._async_set_unique_id(pin)
|
||||
return await self._async_handle_discovery()
|
||||
|
||||
async def _async_handle_discovery(self) -> FlowResult:
|
||||
async def _async_handle_discovery(self) -> ConfigFlowResult:
|
||||
"""Handle any discovery."""
|
||||
self.context[CONF_IP_ADDRESS] = self.discovery_info[CONF_IP_ADDRESS]
|
||||
if any(
|
||||
@ -136,7 +137,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_discovery_confirm(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Finish the configuration via any discovery."""
|
||||
if user_input is None:
|
||||
self._set_confirm_only()
|
||||
|
@ -7,8 +7,10 @@ from aiohttp import ClientResponseError
|
||||
from habitipy.aio import HabitipyAsync
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries, core, exceptions
|
||||
from homeassistant.config_entries import ConfigFlow
|
||||
from homeassistant.const import CONF_API_KEY, CONF_NAME, CONF_URL
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
|
||||
from .const import CONF_API_USER, DEFAULT_URL, DOMAIN
|
||||
@ -25,9 +27,7 @@ DATA_SCHEMA = vol.Schema(
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
async def validate_input(
|
||||
hass: core.HomeAssistant, data: dict[str, str]
|
||||
) -> dict[str, str]:
|
||||
async def validate_input(hass: HomeAssistant, data: dict[str, str]) -> dict[str, str]:
|
||||
"""Validate the user input allows us to connect."""
|
||||
|
||||
websession = async_get_clientsession(hass)
|
||||
@ -48,7 +48,7 @@ async def validate_input(
|
||||
raise InvalidAuth() from ex
|
||||
|
||||
|
||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class HabiticaConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow for habitica."""
|
||||
|
||||
VERSION = 1
|
||||
@ -81,5 +81,5 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
return await self.async_step_user(import_data)
|
||||
|
||||
|
||||
class InvalidAuth(exceptions.HomeAssistantError):
|
||||
class InvalidAuth(HomeAssistantError):
|
||||
"""Error to indicate there is invalid auth."""
|
||||
|
@ -3,8 +3,7 @@ from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.config_entries import ConfigFlow
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
|
||||
from .const import DOMAIN
|
||||
|
||||
@ -14,7 +13,9 @@ class HardkernelConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
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."""
|
||||
if self._async_current_entries():
|
||||
return self.async_abort(reason="single_instance_allowed")
|
||||
|
@ -10,16 +10,21 @@ from aioharmony.hubconnector_websocket import HubConnector
|
||||
import aiohttp
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries, exceptions
|
||||
from homeassistant.components import ssdp
|
||||
from homeassistant.components.remote import (
|
||||
ATTR_ACTIVITY,
|
||||
ATTR_DELAY_SECS,
|
||||
DEFAULT_DELAY_SECS,
|
||||
)
|
||||
from homeassistant.config_entries import (
|
||||
ConfigEntry,
|
||||
ConfigFlow,
|
||||
ConfigFlowResult,
|
||||
OptionsFlow,
|
||||
)
|
||||
from homeassistant.const import CONF_HOST, CONF_NAME
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
|
||||
from .const import DOMAIN, HARMONY_DATA, PREVIOUS_ACTIVE_ACTIVITY, UNIQUE_ID
|
||||
from .util import (
|
||||
@ -51,7 +56,7 @@ async def validate_input(data: dict[str, Any]) -> dict[str, Any]:
|
||||
}
|
||||
|
||||
|
||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class HarmonyConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow for Logitech Harmony Hub."""
|
||||
|
||||
VERSION = 1
|
||||
@ -62,7 +67,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the initial step."""
|
||||
errors: dict[str, str] = {}
|
||||
if user_input is not None:
|
||||
@ -86,7 +91,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
step_id="user", data_schema=DATA_SCHEMA, errors=errors
|
||||
)
|
||||
|
||||
async def async_step_ssdp(self, discovery_info: ssdp.SsdpServiceInfo) -> FlowResult:
|
||||
async def async_step_ssdp(
|
||||
self, discovery_info: ssdp.SsdpServiceInfo
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle a discovered Harmony device."""
|
||||
_LOGGER.debug("SSDP discovery_info: %s", discovery_info)
|
||||
|
||||
@ -120,7 +127,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_link(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Attempt to link with the Harmony."""
|
||||
errors: dict[str, str] = {}
|
||||
|
||||
@ -144,14 +151,14 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
@staticmethod
|
||||
@callback
|
||||
def async_get_options_flow(
|
||||
config_entry: config_entries.ConfigEntry,
|
||||
config_entry: ConfigEntry,
|
||||
) -> OptionsFlowHandler:
|
||||
"""Get the options flow for this handler."""
|
||||
return OptionsFlowHandler(config_entry)
|
||||
|
||||
async def _async_create_entry_from_valid_input(
|
||||
self, validated: dict[str, Any], user_input: dict[str, Any]
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Single path to create the config entry from validated input."""
|
||||
|
||||
data = {
|
||||
@ -174,16 +181,16 @@ def _options_from_user_input(user_input: dict[str, Any]) -> dict[str, Any]:
|
||||
return options
|
||||
|
||||
|
||||
class OptionsFlowHandler(config_entries.OptionsFlow):
|
||||
class OptionsFlowHandler(OptionsFlow):
|
||||
"""Handle a option flow for Harmony."""
|
||||
|
||||
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
|
||||
def __init__(self, config_entry: ConfigEntry) -> None:
|
||||
"""Initialize options flow."""
|
||||
self.config_entry = config_entry
|
||||
|
||||
async def async_step_init(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle options flow."""
|
||||
if user_input is not None:
|
||||
return self.async_create_entry(title="", data=user_input)
|
||||
@ -209,5 +216,5 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
|
||||
return self.async_show_form(step_id="init", data_schema=data_schema)
|
||||
|
||||
|
||||
class CannotConnect(exceptions.HomeAssistantError):
|
||||
class CannotConnect(HomeAssistantError):
|
||||
"""Error to indicate we cannot connect."""
|
||||
|
@ -4,22 +4,21 @@ from __future__ import annotations
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
|
||||
from . import DOMAIN
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class HassIoConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow for Home Assistant Supervisor."""
|
||||
|
||||
VERSION = 1
|
||||
|
||||
async def async_step_system(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the initial step."""
|
||||
# We only need one Hass.io config entry
|
||||
await self.async_set_unique_id(DOMAIN)
|
||||
|
@ -5,10 +5,9 @@ from urllib.parse import urlparse
|
||||
from pyheos import Heos, HeosError
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import ssdp
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import CONF_HOST
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
|
||||
from .const import DATA_DISCOVERED_HOSTS, DOMAIN
|
||||
|
||||
@ -18,12 +17,14 @@ def format_title(host: str) -> str:
|
||||
return f"Controller ({host})"
|
||||
|
||||
|
||||
class HeosFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class HeosFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
"""Define a flow for HEOS."""
|
||||
|
||||
VERSION = 1
|
||||
|
||||
async def async_step_ssdp(self, discovery_info: ssdp.SsdpServiceInfo) -> FlowResult:
|
||||
async def async_step_ssdp(
|
||||
self, discovery_info: ssdp.SsdpServiceInfo
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle a discovered Heos device."""
|
||||
# Store discovered host
|
||||
if TYPE_CHECKING:
|
||||
|
@ -14,7 +14,12 @@ from here_routing import (
|
||||
from here_transit import HERETransitError
|
||||
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,
|
||||
CONF_LATITUDE,
|
||||
@ -23,7 +28,6 @@ from homeassistant.const import (
|
||||
CONF_NAME,
|
||||
)
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.selector import (
|
||||
EntitySelector,
|
||||
@ -91,7 +95,7 @@ def get_user_step_schema(data: dict[str, Any]) -> vol.Schema:
|
||||
)
|
||||
|
||||
|
||||
class HERETravelTimeConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class HERETravelTimeConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow for HERE Travel Time."""
|
||||
|
||||
VERSION = 1
|
||||
@ -103,14 +107,14 @@ class HERETravelTimeConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
@staticmethod
|
||||
@callback
|
||||
def async_get_options_flow(
|
||||
config_entry: config_entries.ConfigEntry,
|
||||
config_entry: ConfigEntry,
|
||||
) -> HERETravelTimeOptionsFlow:
|
||||
"""Get the options flow."""
|
||||
return HERETravelTimeOptionsFlow(config_entry)
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the initial step."""
|
||||
errors = {}
|
||||
user_input = user_input or {}
|
||||
@ -129,7 +133,7 @@ class HERETravelTimeConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
step_id="user", data_schema=get_user_step_schema(user_input), errors=errors
|
||||
)
|
||||
|
||||
async def async_step_origin_menu(self, _: None = None) -> FlowResult:
|
||||
async def async_step_origin_menu(self, _: None = None) -> ConfigFlowResult:
|
||||
"""Show the origin menu."""
|
||||
return self.async_show_menu(
|
||||
step_id="origin_menu",
|
||||
@ -138,7 +142,7 @@ class HERETravelTimeConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_origin_coordinates(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Configure origin by using gps coordinates."""
|
||||
if user_input is not None:
|
||||
self._config[CONF_ORIGIN_LATITUDE] = user_input[CONF_ORIGIN][CONF_LATITUDE]
|
||||
@ -159,7 +163,7 @@ class HERETravelTimeConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
)
|
||||
return self.async_show_form(step_id="origin_coordinates", data_schema=schema)
|
||||
|
||||
async def async_step_destination_menu(self, _: None = None) -> FlowResult:
|
||||
async def async_step_destination_menu(self, _: None = None) -> ConfigFlowResult:
|
||||
"""Show the destination menu."""
|
||||
return self.async_show_menu(
|
||||
step_id="destination_menu",
|
||||
@ -168,7 +172,7 @@ class HERETravelTimeConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_origin_entity(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Configure origin by using an entity."""
|
||||
if user_input is not None:
|
||||
self._config[CONF_ORIGIN_ENTITY_ID] = user_input[CONF_ORIGIN_ENTITY_ID]
|
||||
@ -179,7 +183,7 @@ class HERETravelTimeConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
async def async_step_destination_coordinates(
|
||||
self,
|
||||
user_input: dict[str, Any] | None = None,
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Configure destination by using gps coordinates."""
|
||||
if user_input is not None:
|
||||
self._config[CONF_DESTINATION_LATITUDE] = user_input[CONF_DESTINATION][
|
||||
@ -211,7 +215,7 @@ class HERETravelTimeConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
async def async_step_destination_entity(
|
||||
self,
|
||||
user_input: dict[str, Any] | None = None,
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Configure destination by using an entity."""
|
||||
if user_input is not None:
|
||||
self._config[CONF_DESTINATION_ENTITY_ID] = user_input[
|
||||
@ -228,17 +232,17 @@ class HERETravelTimeConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
return self.async_show_form(step_id="destination_entity", data_schema=schema)
|
||||
|
||||
|
||||
class HERETravelTimeOptionsFlow(config_entries.OptionsFlow):
|
||||
class HERETravelTimeOptionsFlow(OptionsFlow):
|
||||
"""Handle HERE Travel Time options."""
|
||||
|
||||
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
|
||||
def __init__(self, config_entry: ConfigEntry) -> None:
|
||||
"""Initialize HERE Travel Time options flow."""
|
||||
self.config_entry = config_entry
|
||||
self._config: dict[str, Any] = {}
|
||||
|
||||
async def async_step_init(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Manage the HERE Travel Time options."""
|
||||
if user_input is not None:
|
||||
self._config = user_input
|
||||
@ -257,7 +261,7 @@ class HERETravelTimeOptionsFlow(config_entries.OptionsFlow):
|
||||
|
||||
return self.async_show_form(step_id="init", data_schema=schema)
|
||||
|
||||
async def async_step_time_menu(self, _: None = None) -> FlowResult:
|
||||
async def async_step_time_menu(self, _: None = None) -> ConfigFlowResult:
|
||||
"""Show the time menu."""
|
||||
return self.async_show_menu(
|
||||
step_id="time_menu",
|
||||
@ -266,13 +270,13 @@ class HERETravelTimeOptionsFlow(config_entries.OptionsFlow):
|
||||
|
||||
async def async_step_no_time(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Create Options Entry."""
|
||||
return self.async_create_entry(title="", data=self._config)
|
||||
|
||||
async def async_step_arrival_time(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Configure arrival time."""
|
||||
if user_input is not None:
|
||||
self._config[CONF_ARRIVAL_TIME] = user_input[CONF_ARRIVAL_TIME]
|
||||
@ -286,7 +290,7 @@ class HERETravelTimeOptionsFlow(config_entries.OptionsFlow):
|
||||
|
||||
async def async_step_departure_time(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Configure departure time."""
|
||||
if user_input is not None:
|
||||
self._config[CONF_DEPARTURE_TIME] = user_input[CONF_DEPARTURE_TIME]
|
||||
|
@ -13,15 +13,20 @@ from apyhiveapi.helper.hive_exceptions import (
|
||||
)
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.config_entries import (
|
||||
SOURCE_REAUTH,
|
||||
ConfigEntry,
|
||||
ConfigFlow,
|
||||
ConfigFlowResult,
|
||||
OptionsFlow,
|
||||
)
|
||||
from homeassistant.const import CONF_PASSWORD, CONF_SCAN_INTERVAL, CONF_USERNAME
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
|
||||
from .const import CONF_CODE, CONF_DEVICE_NAME, CONFIG_ENTRY_VERSION, DOMAIN
|
||||
|
||||
|
||||
class HiveFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class HiveFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a Hive config flow."""
|
||||
|
||||
VERSION = CONFIG_ENTRY_VERSION
|
||||
@ -47,7 +52,7 @@ class HiveFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
# Get user from existing entry and abort if already setup
|
||||
self.entry = await self.async_set_unique_id(self.data[CONF_USERNAME])
|
||||
if self.context["source"] != config_entries.SOURCE_REAUTH:
|
||||
if self.context["source"] != SOURCE_REAUTH:
|
||||
self._abort_if_unique_id_configured()
|
||||
|
||||
# Login to the Hive.
|
||||
@ -94,7 +99,7 @@ class HiveFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
errors["base"] = "no_internet_available"
|
||||
|
||||
if not errors:
|
||||
if self.context["source"] == config_entries.SOURCE_REAUTH:
|
||||
if self.context["source"] == SOURCE_REAUTH:
|
||||
return await self.async_setup_hive_entry()
|
||||
self.device_registration = True
|
||||
return await self.async_step_configuration()
|
||||
@ -132,7 +137,7 @@ class HiveFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
# Setup the config entry
|
||||
self.data["tokens"] = self.tokens
|
||||
if self.context["source"] == config_entries.SOURCE_REAUTH:
|
||||
if self.context["source"] == SOURCE_REAUTH:
|
||||
self.hass.config_entries.async_update_entry(
|
||||
self.entry, title=self.data["username"], data=self.data
|
||||
)
|
||||
@ -140,7 +145,9 @@ class HiveFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
return self.async_abort(reason="reauth_successful")
|
||||
return self.async_create_entry(title=self.data["username"], data=self.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:
|
||||
"""Re Authenticate a user."""
|
||||
data = {
|
||||
CONF_USERNAME: entry_data[CONF_USERNAME],
|
||||
@ -155,16 +162,16 @@ class HiveFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
@staticmethod
|
||||
@callback
|
||||
def async_get_options_flow(
|
||||
config_entry: config_entries.ConfigEntry,
|
||||
config_entry: ConfigEntry,
|
||||
) -> HiveOptionsFlowHandler:
|
||||
"""Hive options callback."""
|
||||
return HiveOptionsFlowHandler(config_entry)
|
||||
|
||||
|
||||
class HiveOptionsFlowHandler(config_entries.OptionsFlow):
|
||||
class HiveOptionsFlowHandler(OptionsFlow):
|
||||
"""Config flow options for Hive."""
|
||||
|
||||
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
|
||||
def __init__(self, config_entry: ConfigEntry) -> None:
|
||||
"""Initialize Hive options flow."""
|
||||
self.hive = None
|
||||
self.config_entry = config_entry
|
||||
|
@ -7,9 +7,8 @@ from typing import Any
|
||||
from hko import HKO, LOCATIONS, HKOError
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import CONF_LOCATION
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
from homeassistant.helpers.selector import SelectSelector, SelectSelectorConfig
|
||||
|
||||
@ -30,14 +29,14 @@ STEP_USER_DATA_SCHEMA = vol.Schema(
|
||||
)
|
||||
|
||||
|
||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class HKOConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow for Hong Kong Observatory."""
|
||||
|
||||
VERSION = 1
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the initial step."""
|
||||
if user_input is None:
|
||||
return self.async_show_form(
|
||||
|
@ -4,7 +4,7 @@ import asyncio
|
||||
from hlk_sw16 import create_hlk_sw16_connection
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.config_entries import ConfigFlow
|
||||
from homeassistant.const import CONF_HOST, CONF_PORT
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
@ -63,7 +63,7 @@ async def validate_input(hass: HomeAssistant, user_input):
|
||||
client.stop()
|
||||
|
||||
|
||||
class SW16FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class SW16FlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a HLK-SW16 config flow."""
|
||||
|
||||
VERSION = 1
|
||||
|
@ -7,9 +7,8 @@ from babel import Locale, UnknownLocaleError
|
||||
from holidays import list_supported_countries
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import CONF_COUNTRY
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.helpers.selector import (
|
||||
CountrySelector,
|
||||
CountrySelectorConfig,
|
||||
@ -23,7 +22,7 @@ from .const import CONF_PROVINCE, DOMAIN
|
||||
SUPPORTED_COUNTRIES = list_supported_countries(include_aliases=False)
|
||||
|
||||
|
||||
class HolidayConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class HolidayConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow for Holiday."""
|
||||
|
||||
VERSION = 1
|
||||
@ -34,7 +33,7 @@ class HolidayConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the initial step."""
|
||||
if user_input is not None:
|
||||
self.data = user_input
|
||||
@ -71,7 +70,7 @@ class HolidayConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_province(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the province step."""
|
||||
if user_input is not None:
|
||||
combined_input: dict[str, Any] = {**self.data, **user_input}
|
||||
|
@ -14,9 +14,13 @@ from homeassistant.components.hassio import (
|
||||
async_set_green_settings,
|
||||
is_hassio,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry, ConfigFlow, OptionsFlow
|
||||
from homeassistant.config_entries import (
|
||||
ConfigEntry,
|
||||
ConfigFlow,
|
||||
ConfigFlowResult,
|
||||
OptionsFlow,
|
||||
)
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.helpers import selector
|
||||
|
||||
from .const import DOMAIN
|
||||
@ -46,7 +50,9 @@ class HomeAssistantGreenConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Return the options flow."""
|
||||
return HomeAssistantGreenOptionsFlow()
|
||||
|
||||
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."""
|
||||
if self._async_current_entries():
|
||||
return self.async_abort(reason="single_instance_allowed")
|
||||
@ -61,7 +67,7 @@ class HomeAssistantGreenOptionsFlow(OptionsFlow):
|
||||
|
||||
async def async_step_init(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Manage the options."""
|
||||
if not is_hassio(self.hass):
|
||||
return self.async_abort(reason="not_hassio")
|
||||
@ -70,7 +76,7 @@ class HomeAssistantGreenOptionsFlow(OptionsFlow):
|
||||
|
||||
async def async_step_hardware_settings(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle hardware settings."""
|
||||
|
||||
if user_input is not None:
|
||||
|
@ -10,7 +10,6 @@ from typing import Any, Protocol
|
||||
import voluptuous as vol
|
||||
import yarl
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.hassio import (
|
||||
AddonError,
|
||||
AddonInfo,
|
||||
@ -19,8 +18,14 @@ from homeassistant.components.hassio import (
|
||||
hostname_from_addon_slug,
|
||||
is_hassio,
|
||||
)
|
||||
from homeassistant.config_entries import (
|
||||
ConfigEntry,
|
||||
ConfigFlowResult,
|
||||
OptionsFlow,
|
||||
OptionsFlowManager,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.data_entry_flow import AbortFlow, FlowResult
|
||||
from homeassistant.data_entry_flow import AbortFlow
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers.integration_platform import (
|
||||
async_process_integration_platforms,
|
||||
@ -295,10 +300,10 @@ def is_multiprotocol_url(url: str) -> bool:
|
||||
return parsed.host == hostname
|
||||
|
||||
|
||||
class OptionsFlowHandler(config_entries.OptionsFlow, ABC):
|
||||
class OptionsFlowHandler(OptionsFlow, ABC):
|
||||
"""Handle an options flow for the Silicon Labs Multiprotocol add-on."""
|
||||
|
||||
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
|
||||
def __init__(self, config_entry: ConfigEntry) -> None:
|
||||
"""Set up the options flow."""
|
||||
# pylint: disable-next=import-outside-toplevel
|
||||
from homeassistant.components.zha.radio_manager import (
|
||||
@ -334,7 +339,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow, ABC):
|
||||
"""Return the ZHA name."""
|
||||
|
||||
@property
|
||||
def flow_manager(self) -> config_entries.OptionsFlowManager:
|
||||
def flow_manager(self) -> OptionsFlowManager:
|
||||
"""Return the correct flow manager."""
|
||||
return self.hass.config_entries.options
|
||||
|
||||
@ -363,7 +368,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow, ABC):
|
||||
|
||||
async def async_step_init(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Manage the options."""
|
||||
if not is_hassio(self.hass):
|
||||
return self.async_abort(reason="not_hassio")
|
||||
@ -372,7 +377,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow, ABC):
|
||||
|
||||
async def async_step_on_supervisor(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle logic when on Supervisor host."""
|
||||
multipan_manager = await get_multiprotocol_addon_manager(self.hass)
|
||||
addon_info = await self._async_get_addon_info(multipan_manager)
|
||||
@ -383,7 +388,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow, ABC):
|
||||
|
||||
async def async_step_addon_not_installed(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle logic when the addon is not yet installed."""
|
||||
if user_input is None:
|
||||
return self.async_show_form(
|
||||
@ -400,7 +405,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow, ABC):
|
||||
|
||||
async def async_step_install_addon(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Install Silicon Labs Multiprotocol add-on."""
|
||||
multipan_manager = await get_multiprotocol_addon_manager(self.hass)
|
||||
|
||||
@ -430,7 +435,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow, ABC):
|
||||
|
||||
async def async_step_install_failed(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Add-on installation failed."""
|
||||
multipan_manager = await get_multiprotocol_addon_manager(self.hass)
|
||||
return self.async_abort(
|
||||
@ -440,7 +445,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow, ABC):
|
||||
|
||||
async def async_step_configure_addon(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Configure the Silicon Labs Multiprotocol add-on."""
|
||||
# pylint: disable-next=import-outside-toplevel
|
||||
from homeassistant.components.zha import DOMAIN as ZHA_DOMAIN
|
||||
@ -509,7 +514,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow, ABC):
|
||||
|
||||
async def async_step_start_addon(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Start Silicon Labs Multiprotocol add-on."""
|
||||
multipan_manager = await get_multiprotocol_addon_manager(self.hass)
|
||||
|
||||
@ -538,7 +543,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow, ABC):
|
||||
|
||||
async def async_step_start_failed(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Add-on start failed."""
|
||||
multipan_manager = await get_multiprotocol_addon_manager(self.hass)
|
||||
return self.async_abort(
|
||||
@ -548,7 +553,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow, ABC):
|
||||
|
||||
async def async_step_finish_addon_setup(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Prepare info needed to complete the config entry update."""
|
||||
# Always reload entry after installing the addon.
|
||||
self.hass.async_create_task(
|
||||
@ -567,7 +572,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow, ABC):
|
||||
|
||||
async def async_step_addon_installed_other_device(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Show dialog explaining the addon is in use by another device."""
|
||||
if user_input is None:
|
||||
return self.async_show_form(step_id="addon_installed_other_device")
|
||||
@ -575,7 +580,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow, ABC):
|
||||
|
||||
async def async_step_addon_installed(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle logic when the addon is already installed."""
|
||||
multipan_manager = await get_multiprotocol_addon_manager(self.hass)
|
||||
addon_info = await self._async_get_addon_info(multipan_manager)
|
||||
@ -587,7 +592,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow, ABC):
|
||||
|
||||
async def async_step_addon_menu(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Show menu options for the addon."""
|
||||
return self.async_show_menu(
|
||||
step_id="addon_menu",
|
||||
@ -599,7 +604,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow, ABC):
|
||||
|
||||
async def async_step_reconfigure_addon(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Reconfigure the addon."""
|
||||
multipan_manager = await get_multiprotocol_addon_manager(self.hass)
|
||||
active_platforms = await multipan_manager.async_active_platforms()
|
||||
@ -609,7 +614,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow, ABC):
|
||||
|
||||
async def async_step_notify_unknown_multipan_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Notify that there may be unknown multipan platforms."""
|
||||
if user_input is None:
|
||||
return self.async_show_form(
|
||||
@ -619,7 +624,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow, ABC):
|
||||
|
||||
async def async_step_change_channel(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Change the channel."""
|
||||
multipan_manager = await get_multiprotocol_addon_manager(self.hass)
|
||||
if user_input is None:
|
||||
@ -651,7 +656,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow, ABC):
|
||||
|
||||
async def async_step_notify_channel_change(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Notify that the channel change will take about five minutes."""
|
||||
if user_input is None:
|
||||
return self.async_show_form(
|
||||
@ -664,7 +669,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow, ABC):
|
||||
|
||||
async def async_step_uninstall_addon(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Uninstall the addon and revert the firmware."""
|
||||
if user_input is None:
|
||||
return self.async_show_form(
|
||||
@ -681,7 +686,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow, ABC):
|
||||
|
||||
async def async_step_firmware_revert(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Install the flasher addon, if necessary."""
|
||||
|
||||
flasher_manager = get_flasher_addon_manager(self.hass)
|
||||
@ -701,7 +706,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow, ABC):
|
||||
|
||||
async def async_step_install_flasher_addon(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Show progress dialog for installing flasher addon."""
|
||||
flasher_manager = get_flasher_addon_manager(self.hass)
|
||||
addon_info = await self._async_get_addon_info(flasher_manager)
|
||||
@ -734,7 +739,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow, ABC):
|
||||
|
||||
async def async_step_configure_flasher_addon(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Perform initial backup and reconfigure ZHA."""
|
||||
# pylint: disable-next=import-outside-toplevel
|
||||
from homeassistant.components.zha import DOMAIN as ZHA_DOMAIN
|
||||
@ -794,7 +799,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow, ABC):
|
||||
|
||||
async def async_step_uninstall_multiprotocol_addon(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Uninstall Silicon Labs Multiprotocol add-on."""
|
||||
multipan_manager = await get_multiprotocol_addon_manager(self.hass)
|
||||
|
||||
@ -821,7 +826,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow, ABC):
|
||||
|
||||
async def async_step_start_flasher_addon(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Start Silicon Labs Flasher add-on."""
|
||||
flasher_manager = get_flasher_addon_manager(self.hass)
|
||||
|
||||
@ -856,7 +861,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow, ABC):
|
||||
|
||||
async def async_step_flasher_failed(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Flasher add-on start failed."""
|
||||
flasher_manager = get_flasher_addon_manager(self.hass)
|
||||
return self.async_abort(
|
||||
@ -866,7 +871,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow, ABC):
|
||||
|
||||
async def async_step_flashing_complete(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Finish flashing and update the config entry."""
|
||||
flasher_manager = get_flasher_addon_manager(self.hass)
|
||||
await flasher_manager.async_uninstall_addon_waiting()
|
||||
|
@ -5,9 +5,8 @@ from typing import Any
|
||||
|
||||
from homeassistant.components import usb
|
||||
from homeassistant.components.homeassistant_hardware import silabs_multiprotocol_addon
|
||||
from homeassistant.config_entries import ConfigEntry, ConfigFlow
|
||||
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
|
||||
from .const import DOMAIN
|
||||
from .util import get_usb_service_info
|
||||
@ -26,7 +25,9 @@ class HomeAssistantSkyConnectConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Return the options flow."""
|
||||
return HomeAssistantSkyConnectOptionsFlow(config_entry)
|
||||
|
||||
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."""
|
||||
device = discovery_info.device
|
||||
vid = discovery_info.vid
|
||||
|
@ -15,9 +15,8 @@ from homeassistant.components.hassio import (
|
||||
async_set_yellow_settings,
|
||||
)
|
||||
from homeassistant.components.homeassistant_hardware import silabs_multiprotocol_addon
|
||||
from homeassistant.config_entries import ConfigEntry, ConfigFlow
|
||||
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.helpers import selector
|
||||
|
||||
from .const import DOMAIN, ZHA_HW_DISCOVERY_DATA
|
||||
@ -46,7 +45,9 @@ class HomeAssistantYellowConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Return the options flow."""
|
||||
return HomeAssistantYellowOptionsFlow(config_entry)
|
||||
|
||||
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."""
|
||||
if self._async_current_entries():
|
||||
return self.async_abort(reason="single_instance_allowed")
|
||||
@ -61,11 +62,11 @@ class HomeAssistantYellowOptionsFlow(silabs_multiprotocol_addon.OptionsFlowHandl
|
||||
|
||||
async def async_step_on_supervisor(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle logic when on Supervisor host."""
|
||||
return await self.async_step_main_menu()
|
||||
|
||||
async def async_step_main_menu(self, _: None = None) -> FlowResult:
|
||||
async def async_step_main_menu(self, _: None = None) -> ConfigFlowResult:
|
||||
"""Show the main menu."""
|
||||
return self.async_show_menu(
|
||||
step_id="main_menu",
|
||||
@ -77,7 +78,7 @@ class HomeAssistantYellowOptionsFlow(silabs_multiprotocol_addon.OptionsFlowHandl
|
||||
|
||||
async def async_step_hardware_settings(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle hardware settings."""
|
||||
|
||||
if user_input is not None:
|
||||
@ -108,7 +109,7 @@ class HomeAssistantYellowOptionsFlow(silabs_multiprotocol_addon.OptionsFlowHandl
|
||||
|
||||
async def async_step_reboot_menu(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Confirm reboot host."""
|
||||
return self.async_show_menu(
|
||||
step_id="reboot_menu",
|
||||
@ -120,20 +121,20 @@ class HomeAssistantYellowOptionsFlow(silabs_multiprotocol_addon.OptionsFlowHandl
|
||||
|
||||
async def async_step_reboot_now(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Reboot now."""
|
||||
await async_reboot_host(self.hass)
|
||||
return self.async_create_entry(data={})
|
||||
|
||||
async def async_step_reboot_later(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Reboot later."""
|
||||
return self.async_create_entry(data={})
|
||||
|
||||
async def async_step_multipan_settings(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle multipan settings."""
|
||||
return await super().async_step_on_supervisor(user_input)
|
||||
|
||||
|
@ -11,13 +11,18 @@ from typing import Any, Final, TypedDict
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import device_automation
|
||||
from homeassistant.components.camera import DOMAIN as CAMERA_DOMAIN
|
||||
from homeassistant.components.lock import DOMAIN as LOCK_DOMAIN
|
||||
from homeassistant.components.media_player import DOMAIN as MEDIA_PLAYER_DOMAIN
|
||||
from homeassistant.components.remote import DOMAIN as REMOTE_DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_IMPORT
|
||||
from homeassistant.config_entries import (
|
||||
SOURCE_IMPORT,
|
||||
ConfigEntry,
|
||||
ConfigFlow,
|
||||
ConfigFlowResult,
|
||||
OptionsFlow,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
ATTR_FRIENDLY_NAME,
|
||||
CONF_DEVICES,
|
||||
@ -28,7 +33,6 @@ from homeassistant.const import (
|
||||
CONF_PORT,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, callback, split_entity_id
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.helpers import (
|
||||
config_validation as cv,
|
||||
device_registry as dr,
|
||||
@ -191,7 +195,7 @@ async def _async_name_to_type_map(hass: HomeAssistant) -> dict[str, str]:
|
||||
}
|
||||
|
||||
|
||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class HomeKitConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow for HomeKit."""
|
||||
|
||||
VERSION = 1
|
||||
@ -202,7 +206,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Choose specific domains in bridge mode."""
|
||||
if user_input is not None:
|
||||
self.hk_data[CONF_FILTER] = _make_entity_filter(
|
||||
@ -228,7 +232,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_pairing(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Pairing instructions."""
|
||||
hk_data = self.hk_data
|
||||
|
||||
@ -278,7 +282,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
)
|
||||
)
|
||||
|
||||
async def async_step_accessory(self, accessory_input: dict[str, Any]) -> FlowResult:
|
||||
async def async_step_accessory(
|
||||
self, accessory_input: dict[str, Any]
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle creation a single accessory in accessory mode."""
|
||||
entity_id = accessory_input[CONF_ENTITY_ID]
|
||||
port = accessory_input[CONF_PORT]
|
||||
@ -302,7 +308,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
title=f"{name}:{entry_data[CONF_PORT]}", data=entry_data
|
||||
)
|
||||
|
||||
async def async_step_import(self, user_input: dict[str, Any]) -> FlowResult:
|
||||
async def async_step_import(self, user_input: dict[str, Any]) -> ConfigFlowResult:
|
||||
"""Handle import from yaml."""
|
||||
if not self._async_is_unique_name_port(user_input):
|
||||
return self.async_abort(reason="port_name_in_use")
|
||||
@ -349,16 +355,16 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
@staticmethod
|
||||
@callback
|
||||
def async_get_options_flow(
|
||||
config_entry: config_entries.ConfigEntry,
|
||||
config_entry: ConfigEntry,
|
||||
) -> OptionsFlowHandler:
|
||||
"""Get the options flow for this handler."""
|
||||
return OptionsFlowHandler(config_entry)
|
||||
|
||||
|
||||
class OptionsFlowHandler(config_entries.OptionsFlow):
|
||||
class OptionsFlowHandler(OptionsFlow):
|
||||
"""Handle a option flow for homekit."""
|
||||
|
||||
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
|
||||
def __init__(self, config_entry: ConfigEntry) -> None:
|
||||
"""Initialize options flow."""
|
||||
self.config_entry = config_entry
|
||||
self.hk_options: dict[str, Any] = {}
|
||||
@ -366,7 +372,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
|
||||
|
||||
async def async_step_yaml(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""No options for yaml managed entries."""
|
||||
if user_input is not None:
|
||||
# Apparently not possible to abort an options flow
|
||||
@ -377,7 +383,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
|
||||
|
||||
async def async_step_advanced(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Choose advanced options."""
|
||||
hk_options = self.hk_options
|
||||
show_advanced_options = self.show_advanced_options
|
||||
@ -414,7 +420,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
|
||||
|
||||
async def async_step_cameras(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Choose camera config."""
|
||||
hk_options = self.hk_options
|
||||
all_entity_config: dict[str, dict[str, Any]]
|
||||
@ -465,7 +471,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
|
||||
|
||||
async def async_step_accessory(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Choose entity for the accessory."""
|
||||
hk_options = self.hk_options
|
||||
domains = hk_options[CONF_DOMAINS]
|
||||
@ -508,7 +514,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
|
||||
|
||||
async def async_step_include(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Choose entities to include from the domain on the bridge."""
|
||||
hk_options = self.hk_options
|
||||
domains = hk_options[CONF_DOMAINS]
|
||||
@ -546,7 +552,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
|
||||
|
||||
async def async_step_exclude(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Choose entities to exclude from the domain on the bridge."""
|
||||
hk_options = self.hk_options
|
||||
domains = hk_options[CONF_DOMAINS]
|
||||
@ -598,7 +604,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
|
||||
|
||||
async def async_step_init(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle options flow."""
|
||||
if self.config_entry.source == SOURCE_IMPORT:
|
||||
return await self.async_step_yaml(user_input)
|
||||
|
@ -18,10 +18,10 @@ from aiohomekit.model.status_flags import StatusFlags
|
||||
from aiohomekit.utils import domain_supported, domain_to_name, serialize_broadcast_key
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import zeroconf
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.core import 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 .const import DOMAIN, KNOWN_DEVICES
|
||||
@ -95,7 +95,7 @@ def ensure_pin_format(pin: str, allow_insecure_setup_codes: Any = None) -> str:
|
||||
return "-".join(match.groups())
|
||||
|
||||
|
||||
class HomekitControllerFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class HomekitControllerFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a HomeKit config flow."""
|
||||
|
||||
VERSION = 1
|
||||
@ -116,7 +116,7 @@ class HomekitControllerFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle a flow start."""
|
||||
errors: dict[str, str] = {}
|
||||
|
||||
@ -166,7 +166,7 @@ class HomekitControllerFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
),
|
||||
)
|
||||
|
||||
async def async_step_unignore(self, user_input: dict[str, Any]) -> FlowResult:
|
||||
async def async_step_unignore(self, user_input: dict[str, Any]) -> ConfigFlowResult:
|
||||
"""Rediscover a previously ignored discover."""
|
||||
unique_id = user_input["unique_id"]
|
||||
await self.async_set_unique_id(unique_id)
|
||||
@ -208,7 +208,7 @@ class HomekitControllerFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_zeroconf(
|
||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle a discovered HomeKit accessory.
|
||||
|
||||
This flow is triggered by the discovery component.
|
||||
@ -361,7 +361,7 @@ class HomekitControllerFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_bluetooth(
|
||||
self, discovery_info: bluetooth.BluetoothServiceInfoBleak
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the bluetooth discovery step."""
|
||||
if not aiohomekit_const.BLE_TRANSPORT_SUPPORTED:
|
||||
return self.async_abort(reason="ignored_model")
|
||||
@ -409,7 +409,7 @@ class HomekitControllerFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_pair(
|
||||
self, pair_info: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Pair with a new HomeKit accessory."""
|
||||
# If async_step_pair is called with no pairing code then we do the M1
|
||||
# phase of pairing. If this is successful the device enters pairing
|
||||
@ -516,7 +516,7 @@ class HomekitControllerFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_busy_error(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Retry pairing after the accessory is busy."""
|
||||
if user_input is not None:
|
||||
return await self.async_step_pair()
|
||||
@ -525,7 +525,7 @@ class HomekitControllerFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_max_tries_error(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Retry pairing after the accessory has reached max tries."""
|
||||
if user_input is not None:
|
||||
return await self.async_step_pair()
|
||||
@ -534,7 +534,7 @@ class HomekitControllerFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_protocol_error(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Retry pairing after the accessory has a protocol error."""
|
||||
if user_input is not None:
|
||||
return await self.async_step_pair()
|
||||
@ -546,7 +546,7 @@ class HomekitControllerFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
self,
|
||||
errors: dict[str, str] | None = None,
|
||||
description_placeholders: dict[str, str] | None = None,
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
assert self.category
|
||||
|
||||
placeholders = self.context["title_placeholders"] = {
|
||||
@ -565,7 +565,7 @@ class HomekitControllerFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
data_schema=vol.Schema(schema),
|
||||
)
|
||||
|
||||
async def _entry_from_accessory(self, pairing: AbstractPairing) -> FlowResult:
|
||||
async def _entry_from_accessory(self, pairing: AbstractPairing) -> ConfigFlowResult:
|
||||
"""Return a config entry from an initialized bridge."""
|
||||
# The bulk of the pairing record is stored on the config entry.
|
||||
# A specific exception is the 'accessories' key. This is more
|
||||
|
@ -5,14 +5,13 @@ from typing import Any
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
|
||||
from .const import _LOGGER, DOMAIN, HMIPC_AUTHTOKEN, HMIPC_HAPID, HMIPC_NAME, HMIPC_PIN
|
||||
from .hap import HomematicipAuth
|
||||
|
||||
|
||||
class HomematicipCloudFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class HomematicipCloudFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
"""Config flow for the HomematicIP Cloud component."""
|
||||
|
||||
VERSION = 1
|
||||
@ -24,13 +23,13 @@ class HomematicipCloudFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle a flow initialized by the user."""
|
||||
return await self.async_step_init(user_input)
|
||||
|
||||
async def async_step_init(
|
||||
self, user_input: dict[str, str] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle a flow start."""
|
||||
errors = {}
|
||||
|
||||
@ -61,7 +60,7 @@ class HomematicipCloudFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
errors=errors,
|
||||
)
|
||||
|
||||
async def async_step_link(self, user_input: None = None) -> FlowResult:
|
||||
async def async_step_link(self, user_input: None = None) -> ConfigFlowResult:
|
||||
"""Attempt to link with the HomematicIP Cloud access point."""
|
||||
errors = {}
|
||||
|
||||
@ -83,7 +82,7 @@ class HomematicipCloudFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
return self.async_show_form(step_id="link", errors=errors)
|
||||
|
||||
async def async_step_import(self, import_info: dict[str, str]) -> FlowResult:
|
||||
async def async_step_import(self, import_info: dict[str, str]) -> ConfigFlowResult:
|
||||
"""Import a new access point as a config entry."""
|
||||
hapid = import_info[HMIPC_HAPID].replace("-", "").upper()
|
||||
authtoken = import_info[HMIPC_AUTHTOKEN]
|
||||
|
@ -11,9 +11,9 @@ from homewizard_energy.models import Device
|
||||
from voluptuous import Required, Schema
|
||||
|
||||
from homeassistant.components import onboarding, zeroconf
|
||||
from homeassistant.config_entries import ConfigEntry, ConfigFlow
|
||||
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import CONF_IP_ADDRESS, CONF_PATH
|
||||
from homeassistant.data_entry_flow import AbortFlow, FlowResult
|
||||
from homeassistant.data_entry_flow import AbortFlow
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
|
||||
from .const import (
|
||||
@ -46,7 +46,7 @@ class HomeWizardConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle a flow initiated by the user."""
|
||||
errors: dict[str, str] | None = None
|
||||
if user_input is not None:
|
||||
@ -77,7 +77,7 @@ class HomeWizardConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_zeroconf(
|
||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle zeroconf discovery."""
|
||||
if (
|
||||
CONF_API_ENABLED not in discovery_info.properties
|
||||
@ -109,7 +109,7 @@ class HomeWizardConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_discovery_confirm(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Confirm discovery."""
|
||||
errors: dict[str, str] | None = None
|
||||
if user_input is not None or not onboarding.async_is_onboarded(self.hass):
|
||||
@ -143,14 +143,16 @@ class HomeWizardConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
errors=errors,
|
||||
)
|
||||
|
||||
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
|
||||
async def async_step_reauth(
|
||||
self, entry_data: Mapping[str, Any]
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle re-auth if API was disabled."""
|
||||
self.entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
|
||||
return await self.async_step_reauth_confirm()
|
||||
|
||||
async def async_step_reauth_confirm(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Confirm reauth dialog."""
|
||||
errors: dict[str, str] | None = None
|
||||
if user_input is not None:
|
||||
|
@ -7,10 +7,14 @@ from typing import Any
|
||||
import aiosomecomfort
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.config_entries import (
|
||||
ConfigEntry,
|
||||
ConfigFlow,
|
||||
ConfigFlowResult,
|
||||
OptionsFlow,
|
||||
)
|
||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
|
||||
from .const import (
|
||||
@ -29,13 +33,15 @@ REAUTH_SCHEMA = vol.Schema(
|
||||
)
|
||||
|
||||
|
||||
class HoneywellConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class HoneywellConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a honeywell config flow."""
|
||||
|
||||
VERSION = 1
|
||||
entry: config_entries.ConfigEntry | None
|
||||
entry: ConfigEntry | None
|
||||
|
||||
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
|
||||
async def async_step_reauth(
|
||||
self, entry_data: Mapping[str, Any]
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle re-authentication with Honeywell."""
|
||||
|
||||
self.entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
|
||||
@ -43,7 +49,7 @@ class HoneywellConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_reauth_confirm(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Confirm re-authentication with Honeywell."""
|
||||
errors: dict[str, str] = {}
|
||||
assert self.entry is not None
|
||||
@ -81,7 +87,7 @@ class HoneywellConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
errors=errors,
|
||||
)
|
||||
|
||||
async def async_step_user(self, user_input=None) -> FlowResult:
|
||||
async def async_step_user(self, user_input=None) -> ConfigFlowResult:
|
||||
"""Create config entry. Show the setup form to the user."""
|
||||
errors = {}
|
||||
if user_input is not None:
|
||||
@ -124,20 +130,20 @@ class HoneywellConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
@staticmethod
|
||||
@callback
|
||||
def async_get_options_flow(
|
||||
config_entry: config_entries.ConfigEntry,
|
||||
config_entry: ConfigEntry,
|
||||
) -> HoneywellOptionsFlowHandler:
|
||||
"""Options callback for Honeywell."""
|
||||
return HoneywellOptionsFlowHandler(config_entry)
|
||||
|
||||
|
||||
class HoneywellOptionsFlowHandler(config_entries.OptionsFlow):
|
||||
class HoneywellOptionsFlowHandler(OptionsFlow):
|
||||
"""Config flow options for Honeywell."""
|
||||
|
||||
def __init__(self, entry: config_entries.ConfigEntry) -> None:
|
||||
def __init__(self, entry: ConfigEntry) -> None:
|
||||
"""Initialize Honeywell options flow."""
|
||||
self.config_entry = entry
|
||||
|
||||
async def async_step_init(self, user_input=None) -> FlowResult:
|
||||
async def async_step_init(self, user_input=None) -> ConfigFlowResult:
|
||||
"""Manage the options."""
|
||||
if user_input is not None:
|
||||
return self.async_create_entry(title=DOMAIN, data=user_input)
|
||||
|
@ -20,8 +20,13 @@ from requests.exceptions import SSLError, Timeout
|
||||
from url_normalize import url_normalize
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import ssdp
|
||||
from homeassistant.config_entries import (
|
||||
ConfigEntry,
|
||||
ConfigFlow,
|
||||
ConfigFlowResult,
|
||||
OptionsFlow,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
CONF_MAC,
|
||||
CONF_NAME,
|
||||
@ -32,7 +37,6 @@ from homeassistant.const import (
|
||||
CONF_VERIFY_SSL,
|
||||
)
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
|
||||
from .const import (
|
||||
CONF_MANUFACTURER,
|
||||
@ -50,7 +54,7 @@ from .utils import get_device_macs, non_verifying_requests_session
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class ConfigFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle Huawei LTE config flow."""
|
||||
|
||||
VERSION = 3
|
||||
@ -58,7 +62,7 @@ class ConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
@staticmethod
|
||||
@callback
|
||||
def async_get_options_flow(
|
||||
config_entry: config_entries.ConfigEntry,
|
||||
config_entry: ConfigEntry,
|
||||
) -> OptionsFlowHandler:
|
||||
"""Get options flow."""
|
||||
return OptionsFlowHandler(config_entry)
|
||||
@ -67,7 +71,7 @@ class ConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
self,
|
||||
user_input: dict[str, Any] | None = None,
|
||||
errors: dict[str, str] | None = None,
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
if user_input is None:
|
||||
user_input = {}
|
||||
return self.async_show_form(
|
||||
@ -103,7 +107,7 @@ class ConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
self,
|
||||
user_input: dict[str, Any],
|
||||
errors: dict[str, str] | None = None,
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
return self.async_show_form(
|
||||
step_id="reauth_confirm",
|
||||
data_schema=vol.Schema(
|
||||
@ -181,7 +185,7 @@ class ConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle user initiated config flow."""
|
||||
if user_input is None:
|
||||
return await self._async_show_user_form()
|
||||
@ -256,7 +260,9 @@ class ConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
return self.async_create_entry(title=title, data=user_input)
|
||||
|
||||
async def async_step_ssdp(self, discovery_info: ssdp.SsdpServiceInfo) -> FlowResult:
|
||||
async def async_step_ssdp(
|
||||
self, discovery_info: ssdp.SsdpServiceInfo
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle SSDP initiated config flow."""
|
||||
|
||||
if TYPE_CHECKING:
|
||||
@ -302,13 +308,15 @@ class ConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
)
|
||||
return await self._async_show_user_form()
|
||||
|
||||
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
|
||||
async def async_step_reauth(
|
||||
self, entry_data: Mapping[str, Any]
|
||||
) -> ConfigFlowResult:
|
||||
"""Perform reauth upon an API authentication error."""
|
||||
return await self.async_step_reauth_confirm()
|
||||
|
||||
async def async_step_reauth_confirm(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Dialog that informs the user that reauth is required."""
|
||||
entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
|
||||
assert entry
|
||||
@ -335,16 +343,16 @@ class ConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
return self.async_abort(reason="reauth_successful")
|
||||
|
||||
|
||||
class OptionsFlowHandler(config_entries.OptionsFlow):
|
||||
class OptionsFlowHandler(OptionsFlow):
|
||||
"""Huawei LTE options flow."""
|
||||
|
||||
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
|
||||
def __init__(self, config_entry: ConfigEntry) -> None:
|
||||
"""Initialize options flow."""
|
||||
self.config_entry = config_entry
|
||||
|
||||
async def async_step_init(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle options flow."""
|
||||
|
||||
# Recipients are persisted as a list, but handled as comma separated string in UI
|
||||
|
@ -12,11 +12,15 @@ from aiohue.util import normalize_bridge_id
|
||||
import slugify as unicode_slug
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import zeroconf
|
||||
from homeassistant.config_entries import (
|
||||
ConfigEntry,
|
||||
ConfigFlow,
|
||||
ConfigFlowResult,
|
||||
OptionsFlow,
|
||||
)
|
||||
from homeassistant.const import CONF_API_KEY, CONF_API_VERSION, CONF_HOST
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.helpers import (
|
||||
aiohttp_client,
|
||||
config_validation as cv,
|
||||
@ -40,7 +44,7 @@ HUE_IGNORED_BRIDGE_NAMES = ["Home Assistant Bridge", "Espalexa"]
|
||||
HUE_MANUAL_BRIDGE_ID = "manual"
|
||||
|
||||
|
||||
class HueFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class HueFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a Hue config flow."""
|
||||
|
||||
VERSION = 1
|
||||
@ -48,7 +52,7 @@ class HueFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
@staticmethod
|
||||
@callback
|
||||
def async_get_options_flow(
|
||||
config_entry: config_entries.ConfigEntry,
|
||||
config_entry: ConfigEntry,
|
||||
) -> HueV1OptionsFlowHandler | HueV2OptionsFlowHandler:
|
||||
"""Get the options flow for this handler."""
|
||||
if config_entry.data.get(CONF_API_VERSION, 1) == 1:
|
||||
@ -62,7 +66,7 @@ class HueFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle a flow initialized by the user."""
|
||||
# This is for backwards compatibility.
|
||||
return await self.async_step_init(user_input)
|
||||
@ -90,7 +94,7 @@ class HueFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_init(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle a flow start."""
|
||||
# Check if user chooses manual entry
|
||||
if user_input is not None and user_input["id"] == HUE_MANUAL_BRIDGE_ID:
|
||||
@ -141,7 +145,7 @@ class HueFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_manual(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle manual bridge setup."""
|
||||
if user_input is None:
|
||||
return self.async_show_form(
|
||||
@ -157,7 +161,7 @@ class HueFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_link(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Attempt to link with the Hue bridge.
|
||||
|
||||
Given a configured host, will ask the user to press the link button
|
||||
@ -210,7 +214,7 @@ class HueFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_zeroconf(
|
||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle a discovered Hue bridge.
|
||||
|
||||
This flow is triggered by the Zeroconf component. It will check if the
|
||||
@ -239,7 +243,7 @@ class HueFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_homekit(
|
||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle a discovered Hue bridge on HomeKit.
|
||||
|
||||
The bridge ID communicated over HomeKit differs, so we cannot use that
|
||||
@ -253,7 +257,7 @@ class HueFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
await self._async_handle_discovery_without_unique_id()
|
||||
return await self.async_step_link()
|
||||
|
||||
async def async_step_import(self, import_info: dict[str, Any]) -> FlowResult:
|
||||
async def async_step_import(self, import_info: dict[str, Any]) -> ConfigFlowResult:
|
||||
"""Import a new bridge as a config entry.
|
||||
|
||||
This flow is triggered by `async_setup` for both configured and
|
||||
@ -272,16 +276,16 @@ class HueFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
return await self.async_step_link()
|
||||
|
||||
|
||||
class HueV1OptionsFlowHandler(config_entries.OptionsFlow):
|
||||
class HueV1OptionsFlowHandler(OptionsFlow):
|
||||
"""Handle Hue options for V1 implementation."""
|
||||
|
||||
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
|
||||
def __init__(self, config_entry: ConfigEntry) -> None:
|
||||
"""Initialize Hue options flow."""
|
||||
self.config_entry = config_entry
|
||||
|
||||
async def async_step_init(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Manage Hue options."""
|
||||
if user_input is not None:
|
||||
return self.async_create_entry(title="", data=user_input)
|
||||
@ -307,16 +311,16 @@ class HueV1OptionsFlowHandler(config_entries.OptionsFlow):
|
||||
)
|
||||
|
||||
|
||||
class HueV2OptionsFlowHandler(config_entries.OptionsFlow):
|
||||
class HueV2OptionsFlowHandler(OptionsFlow):
|
||||
"""Handle Hue options for V2 implementation."""
|
||||
|
||||
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
|
||||
def __init__(self, config_entry: ConfigEntry) -> None:
|
||||
"""Initialize Hue options flow."""
|
||||
self.config_entry = config_entry
|
||||
|
||||
async def async_step_init(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Manage Hue options."""
|
||||
if user_input is not None:
|
||||
return self.async_create_entry(title="", data=user_input)
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user