Migrate integrations s-t to generic flowhandler (#111865)
This commit is contained in:
parent
e0c1feb22c
commit
b0ed8c4961
106 changed files with 792 additions and 661 deletions
|
@ -6,7 +6,7 @@ from typing import Any
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_API_KEY,
|
CONF_API_KEY,
|
||||||
CONF_HOST,
|
CONF_HOST,
|
||||||
|
@ -15,7 +15,6 @@ from homeassistant.const import (
|
||||||
CONF_SSL,
|
CONF_SSL,
|
||||||
CONF_URL,
|
CONF_URL,
|
||||||
)
|
)
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
|
|
||||||
from .const import DEFAULT_NAME, DOMAIN
|
from .const import DEFAULT_NAME, DOMAIN
|
||||||
from .sab import get_client
|
from .sab import get_client
|
||||||
|
@ -31,7 +30,7 @@ USER_SCHEMA = vol.Schema(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class SABnzbdConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class SABnzbdConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Sabnzbd config flow."""
|
"""Sabnzbd config flow."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
@ -47,7 +46,7 @@ class SABnzbdConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a flow initialized by the user."""
|
"""Handle a flow initialized by the user."""
|
||||||
|
|
||||||
errors = {}
|
errors = {}
|
||||||
|
|
|
@ -11,8 +11,13 @@ import getmac
|
||||||
from samsungtvws.encrypted.authenticator import SamsungTVEncryptedWSAsyncAuthenticator
|
from samsungtvws.encrypted.authenticator import SamsungTVEncryptedWSAsyncAuthenticator
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
|
||||||
from homeassistant.components import dhcp, ssdp, zeroconf
|
from homeassistant.components import dhcp, ssdp, zeroconf
|
||||||
|
from homeassistant.config_entries import (
|
||||||
|
ConfigEntry,
|
||||||
|
ConfigEntryState,
|
||||||
|
ConfigFlow,
|
||||||
|
ConfigFlowResult,
|
||||||
|
)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_HOST,
|
CONF_HOST,
|
||||||
CONF_MAC,
|
CONF_MAC,
|
||||||
|
@ -23,7 +28,7 @@ from homeassistant.const import (
|
||||||
CONF_TOKEN,
|
CONF_TOKEN,
|
||||||
)
|
)
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.data_entry_flow import AbortFlow, FlowResult
|
from homeassistant.data_entry_flow import AbortFlow
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
from homeassistant.helpers.device_registry import format_mac
|
from homeassistant.helpers.device_registry import format_mac
|
||||||
|
|
||||||
|
@ -57,7 +62,7 @@ def _strip_uuid(udn: str) -> str:
|
||||||
|
|
||||||
|
|
||||||
def _entry_is_complete(
|
def _entry_is_complete(
|
||||||
entry: config_entries.ConfigEntry,
|
entry: ConfigEntry,
|
||||||
ssdp_rendering_control_location: str | None,
|
ssdp_rendering_control_location: str | None,
|
||||||
ssdp_main_tv_agent_location: str | None,
|
ssdp_main_tv_agent_location: str | None,
|
||||||
) -> bool:
|
) -> bool:
|
||||||
|
@ -91,14 +96,14 @@ def _mac_is_same_with_incorrect_formatting(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class SamsungTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class SamsungTVConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a Samsung TV config flow."""
|
"""Handle a Samsung TV config flow."""
|
||||||
|
|
||||||
VERSION = 2
|
VERSION = 2
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
"""Initialize flow."""
|
"""Initialize flow."""
|
||||||
self._reauth_entry: config_entries.ConfigEntry | None = None
|
self._reauth_entry: ConfigEntry | None = None
|
||||||
self._host: str = ""
|
self._host: str = ""
|
||||||
self._mac: str | None = None
|
self._mac: str | None = None
|
||||||
self._udn: str | None = None
|
self._udn: str | None = None
|
||||||
|
@ -131,7 +136,7 @@ class SamsungTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
CONF_SSDP_MAIN_TV_AGENT_LOCATION: self._ssdp_main_tv_agent_location,
|
CONF_SSDP_MAIN_TV_AGENT_LOCATION: self._ssdp_main_tv_agent_location,
|
||||||
}
|
}
|
||||||
|
|
||||||
def _get_entry_from_bridge(self) -> FlowResult:
|
def _get_entry_from_bridge(self) -> ConfigFlowResult:
|
||||||
"""Get device entry."""
|
"""Get device entry."""
|
||||||
assert self._bridge
|
assert self._bridge
|
||||||
data = self._base_config_entry()
|
data = self._base_config_entry()
|
||||||
|
@ -252,7 +257,7 @@ class SamsungTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a flow initialized by the user."""
|
"""Handle a flow initialized by the user."""
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
await self._async_set_name_host_from_input(user_input)
|
await self._async_set_name_host_from_input(user_input)
|
||||||
|
@ -270,7 +275,7 @@ class SamsungTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_pairing(
|
async def async_step_pairing(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a pairing by accepting the message on the TV."""
|
"""Handle a pairing by accepting the message on the TV."""
|
||||||
assert self._bridge is not None
|
assert self._bridge is not None
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
|
@ -292,7 +297,7 @@ class SamsungTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_encrypted_pairing(
|
async def async_step_encrypted_pairing(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a encrypted pairing."""
|
"""Handle a encrypted pairing."""
|
||||||
assert self._host is not None
|
assert self._host is not None
|
||||||
await self._async_start_encrypted_pairing(self._host)
|
await self._async_start_encrypted_pairing(self._host)
|
||||||
|
@ -326,9 +331,9 @@ class SamsungTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
@callback
|
@callback
|
||||||
def _async_get_existing_matching_entry(
|
def _async_get_existing_matching_entry(
|
||||||
self,
|
self,
|
||||||
) -> tuple[config_entries.ConfigEntry | None, bool]:
|
) -> tuple[ConfigEntry | None, bool]:
|
||||||
"""Get first existing matching entry (prefer unique id)."""
|
"""Get first existing matching entry (prefer unique id)."""
|
||||||
matching_host_entry: config_entries.ConfigEntry | None = None
|
matching_host_entry: ConfigEntry | None = None
|
||||||
for entry in self._async_current_entries(include_ignore=False):
|
for entry in self._async_current_entries(include_ignore=False):
|
||||||
if (self._mac and self._mac == entry.data.get(CONF_MAC)) or (
|
if (self._mac and self._mac == entry.data.get(CONF_MAC)) or (
|
||||||
self._upnp_udn and self._upnp_udn == entry.unique_id
|
self._upnp_udn and self._upnp_udn == entry.unique_id
|
||||||
|
@ -345,7 +350,7 @@ class SamsungTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
@callback
|
@callback
|
||||||
def _async_update_existing_matching_entry(
|
def _async_update_existing_matching_entry(
|
||||||
self,
|
self,
|
||||||
) -> config_entries.ConfigEntry | None:
|
) -> ConfigEntry | None:
|
||||||
"""Check existing entries and update them.
|
"""Check existing entries and update them.
|
||||||
|
|
||||||
Returns the existing entry if it was updated.
|
Returns the existing entry if it was updated.
|
||||||
|
@ -398,7 +403,7 @@ class SamsungTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
return None
|
return None
|
||||||
LOGGER.debug("Updating existing config entry with %s", entry_kw_args)
|
LOGGER.debug("Updating existing config entry with %s", entry_kw_args)
|
||||||
self.hass.config_entries.async_update_entry(entry, **entry_kw_args)
|
self.hass.config_entries.async_update_entry(entry, **entry_kw_args)
|
||||||
if entry.state != config_entries.ConfigEntryState.LOADED:
|
if entry.state != ConfigEntryState.LOADED:
|
||||||
# If its loaded it already has a reload listener in place
|
# If its loaded it already has a reload listener in place
|
||||||
# and we do not want to trigger multiple reloads
|
# and we do not want to trigger multiple reloads
|
||||||
self.hass.async_create_task(
|
self.hass.async_create_task(
|
||||||
|
@ -430,7 +435,9 @@ class SamsungTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
):
|
):
|
||||||
raise AbortFlow(RESULT_NOT_SUPPORTED)
|
raise AbortFlow(RESULT_NOT_SUPPORTED)
|
||||||
|
|
||||||
async def async_step_ssdp(self, discovery_info: ssdp.SsdpServiceInfo) -> FlowResult:
|
async def async_step_ssdp(
|
||||||
|
self, discovery_info: ssdp.SsdpServiceInfo
|
||||||
|
) -> ConfigFlowResult:
|
||||||
"""Handle a flow initialized by ssdp discovery."""
|
"""Handle a flow initialized by ssdp discovery."""
|
||||||
LOGGER.debug("Samsung device found via SSDP: %s", discovery_info)
|
LOGGER.debug("Samsung device found via SSDP: %s", discovery_info)
|
||||||
model_name: str = discovery_info.upnp.get(ssdp.ATTR_UPNP_MODEL_NAME) or ""
|
model_name: str = discovery_info.upnp.get(ssdp.ATTR_UPNP_MODEL_NAME) or ""
|
||||||
|
@ -475,7 +482,9 @@ class SamsungTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
self.context["title_placeholders"] = {"device": self._title}
|
self.context["title_placeholders"] = {"device": self._title}
|
||||||
return await self.async_step_confirm()
|
return await self.async_step_confirm()
|
||||||
|
|
||||||
async def async_step_dhcp(self, discovery_info: dhcp.DhcpServiceInfo) -> FlowResult:
|
async def async_step_dhcp(
|
||||||
|
self, discovery_info: dhcp.DhcpServiceInfo
|
||||||
|
) -> ConfigFlowResult:
|
||||||
"""Handle a flow initialized by dhcp discovery."""
|
"""Handle a flow initialized by dhcp discovery."""
|
||||||
LOGGER.debug("Samsung device found via DHCP: %s", discovery_info)
|
LOGGER.debug("Samsung device found via DHCP: %s", discovery_info)
|
||||||
self._mac = format_mac(discovery_info.macaddress)
|
self._mac = format_mac(discovery_info.macaddress)
|
||||||
|
@ -487,7 +496,7 @@ class SamsungTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_zeroconf(
|
async def async_step_zeroconf(
|
||||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a flow initialized by zeroconf discovery."""
|
"""Handle a flow initialized by zeroconf discovery."""
|
||||||
LOGGER.debug("Samsung device found via ZEROCONF: %s", discovery_info)
|
LOGGER.debug("Samsung device found via ZEROCONF: %s", discovery_info)
|
||||||
self._mac = format_mac(discovery_info.properties["deviceid"])
|
self._mac = format_mac(discovery_info.properties["deviceid"])
|
||||||
|
@ -499,7 +508,7 @@ class SamsungTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_confirm(
|
async def async_step_confirm(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle user-confirmation of discovered node."""
|
"""Handle user-confirmation of discovered node."""
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
await self._async_create_bridge()
|
await self._async_create_bridge()
|
||||||
|
@ -512,7 +521,9 @@ class SamsungTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
step_id="confirm", description_placeholders={"device": self._title}
|
step_id="confirm", description_placeholders={"device": self._title}
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
|
async def async_step_reauth(
|
||||||
|
self, entry_data: Mapping[str, Any]
|
||||||
|
) -> ConfigFlowResult:
|
||||||
"""Handle configuration by re-auth."""
|
"""Handle configuration by re-auth."""
|
||||||
self._reauth_entry = self.hass.config_entries.async_get_entry(
|
self._reauth_entry = self.hass.config_entries.async_get_entry(
|
||||||
self.context["entry_id"]
|
self.context["entry_id"]
|
||||||
|
@ -525,7 +536,7 @@ class SamsungTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_reauth_confirm(
|
async def async_step_reauth_confirm(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Confirm reauth."""
|
"""Confirm reauth."""
|
||||||
errors = {}
|
errors = {}
|
||||||
assert self._reauth_entry
|
assert self._reauth_entry
|
||||||
|
@ -569,7 +580,7 @@ class SamsungTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_reauth_confirm_encrypted(
|
async def async_step_reauth_confirm_encrypted(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Confirm reauth (encrypted method)."""
|
"""Confirm reauth (encrypted method)."""
|
||||||
errors = {}
|
errors = {}
|
||||||
assert self._reauth_entry
|
assert self._reauth_entry
|
||||||
|
|
|
@ -8,10 +8,8 @@ import pyschlage
|
||||||
from pyschlage.exceptions import NotAuthorizedError
|
from pyschlage.exceptions import NotAuthorizedError
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
|
|
||||||
from .const import DOMAIN, LOGGER
|
from .const import DOMAIN, LOGGER
|
||||||
|
|
||||||
|
@ -21,7 +19,7 @@ STEP_USER_DATA_SCHEMA = vol.Schema(
|
||||||
STEP_REAUTH_DATA_SCHEMA = vol.Schema({vol.Required(CONF_PASSWORD): str})
|
STEP_REAUTH_DATA_SCHEMA = vol.Schema({vol.Required(CONF_PASSWORD): str})
|
||||||
|
|
||||||
|
|
||||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class SchlageConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow for Schlage."""
|
"""Handle a config flow for Schlage."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
@ -30,7 +28,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the initial step."""
|
"""Handle the initial step."""
|
||||||
if user_input is None:
|
if user_input is None:
|
||||||
return self._show_user_form({})
|
return self._show_user_form({})
|
||||||
|
@ -45,13 +43,15 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
await self.async_set_unique_id(user_id)
|
await self.async_set_unique_id(user_id)
|
||||||
return self.async_create_entry(title=username, data=user_input)
|
return self.async_create_entry(title=username, data=user_input)
|
||||||
|
|
||||||
def _show_user_form(self, errors: dict[str, str]) -> FlowResult:
|
def _show_user_form(self, errors: dict[str, str]) -> ConfigFlowResult:
|
||||||
"""Show the user form."""
|
"""Show the user form."""
|
||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
step_id="user", data_schema=STEP_USER_DATA_SCHEMA, errors=errors
|
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 reauth upon an API authentication error."""
|
"""Handle reauth upon an API authentication error."""
|
||||||
self.reauth_entry = self.hass.config_entries.async_get_entry(
|
self.reauth_entry = self.hass.config_entries.async_get_entry(
|
||||||
self.context["entry_id"]
|
self.context["entry_id"]
|
||||||
|
@ -60,7 +60,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_reauth_confirm(
|
async def async_step_reauth_confirm(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Dialog that informs the user that reauth is required."""
|
"""Dialog that informs the user that reauth is required."""
|
||||||
assert self.reauth_entry is not None
|
assert self.reauth_entry is not None
|
||||||
if user_input is None:
|
if user_input is None:
|
||||||
|
@ -85,7 +85,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
await self.hass.config_entries.async_reload(self.reauth_entry.entry_id)
|
await self.hass.config_entries.async_reload(self.reauth_entry.entry_id)
|
||||||
return self.async_abort(reason="reauth_successful")
|
return self.async_abort(reason="reauth_successful")
|
||||||
|
|
||||||
def _show_reauth_form(self, errors: dict[str, str]) -> FlowResult:
|
def _show_reauth_form(self, errors: dict[str, str]) -> ConfigFlowResult:
|
||||||
"""Show the reauth form."""
|
"""Show the reauth form."""
|
||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
step_id="reauth_confirm",
|
step_id="reauth_confirm",
|
||||||
|
|
|
@ -9,11 +9,15 @@ from screenlogicpy.const.common import SL_GATEWAY_IP, SL_GATEWAY_NAME, SL_GATEWA
|
||||||
from screenlogicpy.requests import login
|
from screenlogicpy.requests import login
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
|
||||||
from homeassistant.components import dhcp
|
from homeassistant.components import dhcp
|
||||||
|
from homeassistant.config_entries import (
|
||||||
|
ConfigEntry,
|
||||||
|
ConfigFlow,
|
||||||
|
ConfigFlowResult,
|
||||||
|
OptionsFlow,
|
||||||
|
)
|
||||||
from homeassistant.const import CONF_IP_ADDRESS, CONF_PORT, CONF_SCAN_INTERVAL
|
from homeassistant.const import CONF_IP_ADDRESS, CONF_PORT, CONF_SCAN_INTERVAL
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.device_registry import format_mac
|
from homeassistant.helpers.device_registry import format_mac
|
||||||
|
|
||||||
|
@ -60,7 +64,7 @@ def name_for_mac(mac):
|
||||||
return f"Pentair: {short_mac(mac)}"
|
return f"Pentair: {short_mac(mac)}"
|
||||||
|
|
||||||
|
|
||||||
class ScreenlogicConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class ScreenlogicConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Config flow to setup screen logic devices."""
|
"""Config flow to setup screen logic devices."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
@ -73,17 +77,19 @@ class ScreenlogicConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@callback
|
@callback
|
||||||
def async_get_options_flow(
|
def async_get_options_flow(
|
||||||
config_entry: config_entries.ConfigEntry,
|
config_entry: ConfigEntry,
|
||||||
) -> ScreenLogicOptionsFlowHandler:
|
) -> ScreenLogicOptionsFlowHandler:
|
||||||
"""Get the options flow for ScreenLogic."""
|
"""Get the options flow for ScreenLogic."""
|
||||||
return ScreenLogicOptionsFlowHandler(config_entry)
|
return ScreenLogicOptionsFlowHandler(config_entry)
|
||||||
|
|
||||||
async def async_step_user(self, user_input=None) -> FlowResult:
|
async def async_step_user(self, user_input=None) -> ConfigFlowResult:
|
||||||
"""Handle the start of the config flow."""
|
"""Handle the start of the config flow."""
|
||||||
self.discovered_gateways = await async_discover_gateways_by_unique_id(self.hass)
|
self.discovered_gateways = await async_discover_gateways_by_unique_id(self.hass)
|
||||||
return await self.async_step_gateway_select()
|
return await self.async_step_gateway_select()
|
||||||
|
|
||||||
async def async_step_dhcp(self, discovery_info: dhcp.DhcpServiceInfo) -> FlowResult:
|
async def async_step_dhcp(
|
||||||
|
self, discovery_info: dhcp.DhcpServiceInfo
|
||||||
|
) -> ConfigFlowResult:
|
||||||
"""Handle dhcp discovery."""
|
"""Handle dhcp discovery."""
|
||||||
mac = format_mac(discovery_info.macaddress)
|
mac = format_mac(discovery_info.macaddress)
|
||||||
await self.async_set_unique_id(mac)
|
await self.async_set_unique_id(mac)
|
||||||
|
@ -94,7 +100,7 @@ class ScreenlogicConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
self.context["title_placeholders"] = {"name": discovery_info.hostname}
|
self.context["title_placeholders"] = {"name": discovery_info.hostname}
|
||||||
return await self.async_step_gateway_entry()
|
return await self.async_step_gateway_entry()
|
||||||
|
|
||||||
async def async_step_gateway_select(self, user_input=None) -> FlowResult:
|
async def async_step_gateway_select(self, user_input=None) -> ConfigFlowResult:
|
||||||
"""Handle the selection of a discovered ScreenLogic gateway."""
|
"""Handle the selection of a discovered ScreenLogic gateway."""
|
||||||
existing = self._async_current_ids()
|
existing = self._async_current_ids()
|
||||||
unconfigured_gateways = {
|
unconfigured_gateways = {
|
||||||
|
@ -141,7 +147,7 @@ class ScreenlogicConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
description_placeholders={},
|
description_placeholders={},
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_gateway_entry(self, user_input=None) -> FlowResult:
|
async def async_step_gateway_entry(self, user_input=None) -> ConfigFlowResult:
|
||||||
"""Handle the manual entry of a ScreenLogic gateway."""
|
"""Handle the manual entry of a ScreenLogic gateway."""
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
ip_address = self.discovered_ip
|
ip_address = self.discovered_ip
|
||||||
|
@ -180,14 +186,14 @@ class ScreenlogicConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class ScreenLogicOptionsFlowHandler(config_entries.OptionsFlow):
|
class ScreenLogicOptionsFlowHandler(OptionsFlow):
|
||||||
"""Handles the options for the ScreenLogic integration."""
|
"""Handles the options for the ScreenLogic integration."""
|
||||||
|
|
||||||
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
|
def __init__(self, config_entry: ConfigEntry) -> None:
|
||||||
"""Init the screen logic options flow."""
|
"""Init the screen logic options flow."""
|
||||||
self.config_entry = config_entry
|
self.config_entry = config_entry
|
||||||
|
|
||||||
async def async_step_init(self, user_input=None) -> FlowResult:
|
async def async_step_init(self, user_input=None) -> ConfigFlowResult:
|
||||||
"""Manage the options."""
|
"""Manage the options."""
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
return self.async_create_entry(
|
return self.async_create_entry(
|
||||||
|
|
|
@ -5,9 +5,8 @@ from typing import Any
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigFlow
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_TYPE
|
from homeassistant.const import CONF_TYPE
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.helpers.selector import (
|
from homeassistant.helpers.selector import (
|
||||||
SelectSelector,
|
SelectSelector,
|
||||||
SelectSelectorConfig,
|
SelectSelectorConfig,
|
||||||
|
@ -24,7 +23,7 @@ class SeasonConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a flow initialized by the user."""
|
"""Handle a flow initialized by the user."""
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
await self.async_set_unique_id(user_input[CONF_TYPE])
|
await self.async_set_unique_id(user_input[CONF_TYPE])
|
||||||
|
|
|
@ -10,9 +10,8 @@ from sense_energy import (
|
||||||
)
|
)
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_CODE, CONF_EMAIL, CONF_PASSWORD, CONF_TIMEOUT
|
from homeassistant.const import CONF_CODE, CONF_EMAIL, CONF_PASSWORD, CONF_TIMEOUT
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
|
|
||||||
from .const import ACTIVE_UPDATE_RATE, DEFAULT_TIMEOUT, DOMAIN, SENSE_CONNECT_EXCEPTIONS
|
from .const import ACTIVE_UPDATE_RATE, DEFAULT_TIMEOUT, DOMAIN, SENSE_CONNECT_EXCEPTIONS
|
||||||
|
@ -28,7 +27,7 @@ DATA_SCHEMA = vol.Schema(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class SenseConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow for Sense."""
|
"""Handle a config flow for Sense."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
@ -121,7 +120,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
step_id="user", data_schema=DATA_SCHEMA, errors=errors
|
step_id="user", data_schema=DATA_SCHEMA, errors=errors
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
|
async def async_step_reauth(
|
||||||
|
self, entry_data: Mapping[str, Any]
|
||||||
|
) -> ConfigFlowResult:
|
||||||
"""Handle configuration by re-auth."""
|
"""Handle configuration by re-auth."""
|
||||||
self._auth_data = dict(entry_data)
|
self._auth_data = dict(entry_data)
|
||||||
return await self.async_step_reauth_validate(entry_data)
|
return await self.async_step_reauth_validate(entry_data)
|
||||||
|
|
|
@ -7,9 +7,8 @@ from typing import Any
|
||||||
from pysensibo.exceptions import AuthenticationError
|
from pysensibo.exceptions import AuthenticationError
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_API_KEY
|
from homeassistant.const import CONF_API_KEY
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.helpers.selector import TextSelector
|
from homeassistant.helpers.selector import TextSelector
|
||||||
|
|
||||||
from .const import DEFAULT_NAME, DOMAIN
|
from .const import DEFAULT_NAME, DOMAIN
|
||||||
|
@ -22,14 +21,16 @@ DATA_SCHEMA = vol.Schema(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class SensiboConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class SensiboConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow for Sensibo integration."""
|
"""Handle a config flow for Sensibo integration."""
|
||||||
|
|
||||||
VERSION = 2
|
VERSION = 2
|
||||||
|
|
||||||
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 Sensibo."""
|
"""Handle re-authentication with Sensibo."""
|
||||||
|
|
||||||
self.entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
|
self.entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
|
||||||
|
@ -37,7 +38,7 @@ class SensiboConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_reauth_confirm(
|
async def async_step_reauth_confirm(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Confirm re-authentication with Sensibo."""
|
"""Confirm re-authentication with Sensibo."""
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
|
|
||||||
|
@ -74,7 +75,7 @@ class SensiboConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the initial step."""
|
"""Handle the initial step."""
|
||||||
|
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
|
|
|
@ -10,9 +10,8 @@ from homeassistant.components.bluetooth import (
|
||||||
BluetoothServiceInfoBleak,
|
BluetoothServiceInfoBleak,
|
||||||
async_discovered_service_info,
|
async_discovered_service_info,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigFlow
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_ADDRESS
|
from homeassistant.const import CONF_ADDRESS
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
|
@ -30,7 +29,7 @@ class SensirionConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_bluetooth(
|
async def async_step_bluetooth(
|
||||||
self, discovery_info: BluetoothServiceInfoBleak
|
self, discovery_info: BluetoothServiceInfoBleak
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the bluetooth discovery step."""
|
"""Handle the bluetooth discovery step."""
|
||||||
await self.async_set_unique_id(discovery_info.address)
|
await self.async_set_unique_id(discovery_info.address)
|
||||||
self._abort_if_unique_id_configured()
|
self._abort_if_unique_id_configured()
|
||||||
|
@ -43,7 +42,7 @@ class SensirionConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_bluetooth_confirm(
|
async def async_step_bluetooth_confirm(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Confirm discovery."""
|
"""Confirm discovery."""
|
||||||
assert self._discovered_device is not None
|
assert self._discovered_device is not None
|
||||||
device = self._discovered_device
|
device = self._discovered_device
|
||||||
|
@ -62,7 +61,7 @@ class SensirionConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the user step to pick discovered device."""
|
"""Handle the user step to pick discovered device."""
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
address = user_input[CONF_ADDRESS]
|
address = user_input[CONF_ADDRESS]
|
||||||
|
|
|
@ -10,9 +10,8 @@ from homeassistant.components.bluetooth import (
|
||||||
BluetoothServiceInfoBleak,
|
BluetoothServiceInfoBleak,
|
||||||
async_discovered_service_info,
|
async_discovered_service_info,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigFlow
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_ADDRESS
|
from homeassistant.const import CONF_ADDRESS
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
|
@ -30,7 +29,7 @@ class SensorProConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_bluetooth(
|
async def async_step_bluetooth(
|
||||||
self, discovery_info: BluetoothServiceInfoBleak
|
self, discovery_info: BluetoothServiceInfoBleak
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the bluetooth discovery step."""
|
"""Handle the bluetooth discovery step."""
|
||||||
await self.async_set_unique_id(discovery_info.address)
|
await self.async_set_unique_id(discovery_info.address)
|
||||||
self._abort_if_unique_id_configured()
|
self._abort_if_unique_id_configured()
|
||||||
|
@ -43,7 +42,7 @@ class SensorProConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_bluetooth_confirm(
|
async def async_step_bluetooth_confirm(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Confirm discovery."""
|
"""Confirm discovery."""
|
||||||
assert self._discovered_device is not None
|
assert self._discovered_device is not None
|
||||||
device = self._discovered_device
|
device = self._discovered_device
|
||||||
|
@ -62,7 +61,7 @@ class SensorProConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the user step to pick discovered device."""
|
"""Handle the user step to pick discovered device."""
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
address = user_input[CONF_ADDRESS]
|
address = user_input[CONF_ADDRESS]
|
||||||
|
|
|
@ -10,9 +10,8 @@ from homeassistant.components.bluetooth import (
|
||||||
BluetoothServiceInfoBleak,
|
BluetoothServiceInfoBleak,
|
||||||
async_discovered_service_info,
|
async_discovered_service_info,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigFlow
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_ADDRESS
|
from homeassistant.const import CONF_ADDRESS
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
|
@ -30,7 +29,7 @@ class SensorPushConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_bluetooth(
|
async def async_step_bluetooth(
|
||||||
self, discovery_info: BluetoothServiceInfoBleak
|
self, discovery_info: BluetoothServiceInfoBleak
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the bluetooth discovery step."""
|
"""Handle the bluetooth discovery step."""
|
||||||
await self.async_set_unique_id(discovery_info.address)
|
await self.async_set_unique_id(discovery_info.address)
|
||||||
self._abort_if_unique_id_configured()
|
self._abort_if_unique_id_configured()
|
||||||
|
@ -43,7 +42,7 @@ class SensorPushConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_bluetooth_confirm(
|
async def async_step_bluetooth_confirm(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Confirm discovery."""
|
"""Confirm discovery."""
|
||||||
assert self._discovered_device is not None
|
assert self._discovered_device is not None
|
||||||
device = self._discovered_device
|
device = self._discovered_device
|
||||||
|
@ -62,7 +61,7 @@ class SensorPushConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the user step to pick discovered device."""
|
"""Handle the user step to pick discovered device."""
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
address = user_input[CONF_ADDRESS]
|
address = user_input[CONF_ADDRESS]
|
||||||
|
|
|
@ -7,9 +7,13 @@ from typing import Any
|
||||||
from sentry_sdk.utils import BadDsn, Dsn
|
from sentry_sdk.utils import BadDsn, Dsn
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant.config_entries import (
|
||||||
|
ConfigEntry,
|
||||||
|
ConfigFlow,
|
||||||
|
ConfigFlowResult,
|
||||||
|
OptionsFlow,
|
||||||
|
)
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
CONF_DSN,
|
CONF_DSN,
|
||||||
|
@ -33,7 +37,7 @@ _LOGGER = logging.getLogger(__name__)
|
||||||
DATA_SCHEMA = vol.Schema({vol.Required(CONF_DSN): str})
|
DATA_SCHEMA = vol.Schema({vol.Required(CONF_DSN): str})
|
||||||
|
|
||||||
|
|
||||||
class SentryConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class SentryConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a Sentry config flow."""
|
"""Handle a Sentry config flow."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
@ -41,14 +45,14 @@ class SentryConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@callback
|
@callback
|
||||||
def async_get_options_flow(
|
def async_get_options_flow(
|
||||||
config_entry: config_entries.ConfigEntry,
|
config_entry: ConfigEntry,
|
||||||
) -> SentryOptionsFlow:
|
) -> SentryOptionsFlow:
|
||||||
"""Get the options flow for this handler."""
|
"""Get the options flow for this handler."""
|
||||||
return SentryOptionsFlow(config_entry)
|
return SentryOptionsFlow(config_entry)
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a user config flow."""
|
"""Handle a user config flow."""
|
||||||
if self._async_current_entries():
|
if self._async_current_entries():
|
||||||
return self.async_abort(reason="single_instance_allowed")
|
return self.async_abort(reason="single_instance_allowed")
|
||||||
|
@ -70,16 +74,16 @@ class SentryConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class SentryOptionsFlow(config_entries.OptionsFlow):
|
class SentryOptionsFlow(OptionsFlow):
|
||||||
"""Handle Sentry options."""
|
"""Handle Sentry options."""
|
||||||
|
|
||||||
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
|
def __init__(self, config_entry: ConfigEntry) -> None:
|
||||||
"""Initialize Sentry options flow."""
|
"""Initialize Sentry options flow."""
|
||||||
self.config_entry = config_entry
|
self.config_entry = config_entry
|
||||||
|
|
||||||
async def async_step_init(
|
async def async_step_init(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Manage Sentry options."""
|
"""Manage Sentry options."""
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
return self.async_create_entry(title="", data=user_input)
|
return self.async_create_entry(title="", data=user_input)
|
||||||
|
|
|
@ -8,9 +8,8 @@ from sfrbox_api.bridge import SFRBox
|
||||||
from sfrbox_api.exceptions import SFRBoxAuthenticationError, SFRBoxError
|
from sfrbox_api.exceptions import SFRBoxAuthenticationError, SFRBoxError
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry, ConfigFlow
|
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME
|
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.helpers import selector
|
from homeassistant.helpers import selector
|
||||||
from homeassistant.helpers.httpx_client import get_async_client
|
from homeassistant.helpers.httpx_client import get_async_client
|
||||||
|
|
||||||
|
@ -41,7 +40,7 @@ class SFRBoxFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, str] | None = None
|
self, user_input: dict[str, str] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a flow initialized by the user."""
|
"""Handle a flow initialized by the user."""
|
||||||
errors = {}
|
errors = {}
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
|
@ -65,7 +64,7 @@ class SFRBoxFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_choose_auth(
|
async def async_step_choose_auth(
|
||||||
self, user_input: dict[str, str] | None = None
|
self, user_input: dict[str, str] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a flow initialized by the user."""
|
"""Handle a flow initialized by the user."""
|
||||||
return self.async_show_menu(
|
return self.async_show_menu(
|
||||||
step_id="choose_auth",
|
step_id="choose_auth",
|
||||||
|
@ -74,7 +73,7 @@ class SFRBoxFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_auth(
|
async def async_step_auth(
|
||||||
self, user_input: dict[str, str] | None = None
|
self, user_input: dict[str, str] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Check authentication."""
|
"""Check authentication."""
|
||||||
errors = {}
|
errors = {}
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
|
@ -107,11 +106,13 @@ class SFRBoxFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_skip_auth(
|
async def async_step_skip_auth(
|
||||||
self, user_input: dict[str, str] | None = None
|
self, user_input: dict[str, str] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Skip authentication."""
|
"""Skip authentication."""
|
||||||
return self.async_create_entry(title="SFR Box", data=self._config)
|
return self.async_create_entry(title="SFR Box", data=self._config)
|
||||||
|
|
||||||
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
|
async def async_step_reauth(
|
||||||
|
self, entry_data: Mapping[str, Any]
|
||||||
|
) -> ConfigFlowResult:
|
||||||
"""Handle failed credentials."""
|
"""Handle failed credentials."""
|
||||||
self._reauth_entry = self.hass.config_entries.async_get_entry(
|
self._reauth_entry = self.hass.config_entries.async_get_entry(
|
||||||
self.context["entry_id"]
|
self.context["entry_id"]
|
||||||
|
|
|
@ -9,9 +9,10 @@ import aiohttp
|
||||||
from sharkiq import SharkIqAuthError, get_ayla_api
|
from sharkiq import SharkIqAuthError, get_ayla_api
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries, core, exceptions
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_PASSWORD, CONF_REGION, CONF_USERNAME
|
from homeassistant.const import CONF_PASSWORD, CONF_REGION, CONF_USERNAME
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers import selector
|
from homeassistant.helpers import selector
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
|
|
||||||
|
@ -39,7 +40,7 @@ SHARKIQ_SCHEMA = vol.Schema(
|
||||||
|
|
||||||
|
|
||||||
async def _validate_input(
|
async def _validate_input(
|
||||||
hass: core.HomeAssistant, data: Mapping[str, Any]
|
hass: HomeAssistant, data: Mapping[str, Any]
|
||||||
) -> dict[str, str]:
|
) -> dict[str, str]:
|
||||||
"""Validate the user input allows us to connect."""
|
"""Validate the user input allows us to connect."""
|
||||||
ayla_api = get_ayla_api(
|
ayla_api = get_ayla_api(
|
||||||
|
@ -74,7 +75,7 @@ async def _validate_input(
|
||||||
return {"title": data[CONF_USERNAME]}
|
return {"title": data[CONF_USERNAME]}
|
||||||
|
|
||||||
|
|
||||||
class SharkIqConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class SharkIqConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow for Shark IQ."""
|
"""Handle a config flow for Shark IQ."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
@ -99,7 +100,7 @@ class SharkIqConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, str] | None = None
|
self, user_input: dict[str, str] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the initial step."""
|
"""Handle the initial step."""
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
|
@ -113,7 +114,9 @@ class SharkIqConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
step_id="user", data_schema=SHARKIQ_SCHEMA, errors=errors
|
step_id="user", data_schema=SHARKIQ_SCHEMA, errors=errors
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_reauth(self, user_input: Mapping[str, Any]) -> FlowResult:
|
async def async_step_reauth(
|
||||||
|
self, user_input: Mapping[str, Any]
|
||||||
|
) -> ConfigFlowResult:
|
||||||
"""Handle re-auth if login is invalid."""
|
"""Handle re-auth if login is invalid."""
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
|
|
||||||
|
@ -136,13 +139,13 @@ class SharkIqConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class CannotConnect(exceptions.HomeAssistantError):
|
class CannotConnect(HomeAssistantError):
|
||||||
"""Error to indicate we cannot connect."""
|
"""Error to indicate we cannot connect."""
|
||||||
|
|
||||||
|
|
||||||
class InvalidAuth(exceptions.HomeAssistantError):
|
class InvalidAuth(HomeAssistantError):
|
||||||
"""Error to indicate there is invalid auth."""
|
"""Error to indicate there is invalid auth."""
|
||||||
|
|
||||||
|
|
||||||
class UnknownAuth(exceptions.HomeAssistantError):
|
class UnknownAuth(HomeAssistantError):
|
||||||
"""Error to indicate there is an uncaught auth error."""
|
"""Error to indicate there is an uncaught auth error."""
|
||||||
|
|
|
@ -16,10 +16,14 @@ from aioshelly.rpc_device import RpcDevice
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.zeroconf import ZeroconfServiceInfo
|
from homeassistant.components.zeroconf import ZeroconfServiceInfo
|
||||||
from homeassistant.config_entries import ConfigEntry, ConfigFlow, OptionsFlow
|
from homeassistant.config_entries import (
|
||||||
|
ConfigEntry,
|
||||||
|
ConfigFlow,
|
||||||
|
ConfigFlowResult,
|
||||||
|
OptionsFlow,
|
||||||
|
)
|
||||||
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME
|
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
from homeassistant.helpers.selector import SelectSelector, SelectSelectorConfig
|
from homeassistant.helpers.selector import SelectSelector, SelectSelectorConfig
|
||||||
|
|
||||||
|
@ -117,7 +121,7 @@ class ShellyConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the initial step."""
|
"""Handle the initial step."""
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
|
@ -166,7 +170,7 @@ class ShellyConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_credentials(
|
async def async_step_credentials(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the credentials step."""
|
"""Handle the credentials step."""
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
|
@ -239,7 +243,7 @@ class ShellyConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_zeroconf(
|
async def async_step_zeroconf(
|
||||||
self, discovery_info: ZeroconfServiceInfo
|
self, discovery_info: ZeroconfServiceInfo
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle zeroconf discovery."""
|
"""Handle zeroconf discovery."""
|
||||||
host = discovery_info.host
|
host = discovery_info.host
|
||||||
# First try to get the mac address from the name
|
# First try to get the mac address from the name
|
||||||
|
@ -280,7 +284,7 @@ class ShellyConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_confirm_discovery(
|
async def async_step_confirm_discovery(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle discovery confirm."""
|
"""Handle discovery confirm."""
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
|
|
||||||
|
@ -310,14 +314,16 @@ class ShellyConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
errors=errors,
|
errors=errors,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
|
async def async_step_reauth(
|
||||||
|
self, entry_data: Mapping[str, Any]
|
||||||
|
) -> ConfigFlowResult:
|
||||||
"""Handle configuration by re-auth."""
|
"""Handle configuration by re-auth."""
|
||||||
self.entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
|
self.entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
|
||||||
return await self.async_step_reauth_confirm()
|
return await self.async_step_reauth_confirm()
|
||||||
|
|
||||||
async def async_step_reauth_confirm(
|
async def async_step_reauth_confirm(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Dialog that informs the user that reauth is required."""
|
"""Dialog that informs the user that reauth is required."""
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
assert self.entry is not None
|
assert self.entry is not None
|
||||||
|
@ -384,7 +390,7 @@ class OptionsFlowHandler(OptionsFlow):
|
||||||
|
|
||||||
async def async_step_init(
|
async def async_step_init(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle options flow."""
|
"""Handle options flow."""
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
return self.async_create_entry(title="", data=user_input)
|
return self.async_create_entry(title="", data=user_input)
|
||||||
|
|
|
@ -3,8 +3,7 @@ from __future__ import annotations
|
||||||
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigFlow
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
|
@ -16,7 +15,7 @@ class ShoppingListFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a flow initialized by the user."""
|
"""Handle a flow initialized by the user."""
|
||||||
# Check if already configured
|
# Check if already configured
|
||||||
await self.async_set_unique_id(DOMAIN)
|
await self.async_set_unique_id(DOMAIN)
|
||||||
|
@ -31,6 +30,6 @@ class ShoppingListFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_onboarding(
|
async def async_step_onboarding(
|
||||||
self, _: dict[str, Any] | None = None
|
self, _: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a flow initialized by onboarding."""
|
"""Handle a flow initialized by onboarding."""
|
||||||
return await self.async_step_user(user_input={})
|
return await self.async_step_user(user_input={})
|
||||||
|
|
|
@ -15,10 +15,14 @@ from pysiaalarm import (
|
||||||
)
|
)
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant.config_entries import (
|
||||||
|
ConfigEntry,
|
||||||
|
ConfigFlow,
|
||||||
|
ConfigFlowResult,
|
||||||
|
OptionsFlow,
|
||||||
|
)
|
||||||
from homeassistant.const import CONF_PORT, CONF_PROTOCOL
|
from homeassistant.const import CONF_PORT, CONF_PROTOCOL
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
CONF_ACCOUNT,
|
CONF_ACCOUNT,
|
||||||
|
@ -87,7 +91,7 @@ def validate_zones(data: dict[str, Any]) -> dict[str, str] | None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
class SIAConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class SIAConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow for sia."""
|
"""Handle a config flow for sia."""
|
||||||
|
|
||||||
VERSION: int = 1
|
VERSION: int = 1
|
||||||
|
@ -95,7 +99,7 @@ class SIAConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@callback
|
@callback
|
||||||
def async_get_options_flow(
|
def async_get_options_flow(
|
||||||
config_entry: config_entries.ConfigEntry,
|
config_entry: ConfigEntry,
|
||||||
) -> SIAOptionsFlowHandler:
|
) -> SIAOptionsFlowHandler:
|
||||||
"""Get the options flow for this handler."""
|
"""Get the options flow for this handler."""
|
||||||
return SIAOptionsFlowHandler(config_entry)
|
return SIAOptionsFlowHandler(config_entry)
|
||||||
|
@ -107,7 +111,7 @@ class SIAConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the initial user step."""
|
"""Handle the initial user step."""
|
||||||
errors: dict[str, str] | None = None
|
errors: dict[str, str] | None = None
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
|
@ -120,7 +124,7 @@ class SIAConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_add_account(
|
async def async_step_add_account(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the additional accounts steps."""
|
"""Handle the additional accounts steps."""
|
||||||
errors: dict[str, str] | None = None
|
errors: dict[str, str] | None = None
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
|
@ -133,7 +137,7 @@ class SIAConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_handle_data_and_route(
|
async def async_handle_data_and_route(
|
||||||
self, user_input: dict[str, Any]
|
self, user_input: dict[str, Any]
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the user_input, check if configured and route to the right next step or create entry."""
|
"""Handle the user_input, check if configured and route to the right next step or create entry."""
|
||||||
self._update_data(user_input)
|
self._update_data(user_input)
|
||||||
|
|
||||||
|
@ -171,10 +175,10 @@ class SIAConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
self._options[CONF_ACCOUNTS][account][CONF_ZONES] = user_input[CONF_ZONES]
|
self._options[CONF_ACCOUNTS][account][CONF_ZONES] = user_input[CONF_ZONES]
|
||||||
|
|
||||||
|
|
||||||
class SIAOptionsFlowHandler(config_entries.OptionsFlow):
|
class SIAOptionsFlowHandler(OptionsFlow):
|
||||||
"""Handle SIA options."""
|
"""Handle SIA options."""
|
||||||
|
|
||||||
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
|
def __init__(self, config_entry: ConfigEntry) -> None:
|
||||||
"""Initialize SIA options flow."""
|
"""Initialize SIA options flow."""
|
||||||
self.config_entry = config_entry
|
self.config_entry = config_entry
|
||||||
self.options = deepcopy(dict(config_entry.options))
|
self.options = deepcopy(dict(config_entry.options))
|
||||||
|
@ -183,7 +187,7 @@ class SIAOptionsFlowHandler(config_entries.OptionsFlow):
|
||||||
|
|
||||||
async def async_step_init(
|
async def async_step_init(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Manage the SIA options."""
|
"""Manage the SIA options."""
|
||||||
self.hub = self.hass.data[DOMAIN][self.config_entry.entry_id]
|
self.hub = self.hass.data[DOMAIN][self.config_entry.entry_id]
|
||||||
assert self.hub is not None
|
assert self.hub is not None
|
||||||
|
@ -193,7 +197,7 @@ class SIAOptionsFlowHandler(config_entries.OptionsFlow):
|
||||||
|
|
||||||
async def async_step_options(
|
async def async_step_options(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Create the options step for a account."""
|
"""Create the options step for a account."""
|
||||||
errors: dict[str, str] | None = None
|
errors: dict[str, str] | None = None
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
|
|
|
@ -6,9 +6,8 @@ from typing import Any
|
||||||
from simplepush import UnknownError, send
|
from simplepush import UnknownError, send
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_NAME, CONF_PASSWORD
|
from homeassistant.const import CONF_NAME, CONF_PASSWORD
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
|
|
||||||
from .const import ATTR_ENCRYPTED, CONF_DEVICE_KEY, CONF_SALT, DEFAULT_NAME, DOMAIN
|
from .const import ATTR_ENCRYPTED, CONF_DEVICE_KEY, CONF_SALT, DEFAULT_NAME, DOMAIN
|
||||||
|
|
||||||
|
@ -36,12 +35,12 @@ def validate_input(entry: dict[str, str]) -> dict[str, str] | None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
class SimplePushFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
class SimplePushFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow for simplepush."""
|
"""Handle a config flow for simplepush."""
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a flow initiated by the user."""
|
"""Handle a flow initiated by the user."""
|
||||||
errors: dict[str, str] | None = None
|
errors: dict[str, str] | None = None
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
|
|
|
@ -13,11 +13,14 @@ from simplipy.util.auth import (
|
||||||
)
|
)
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant.config_entries import (
|
||||||
from homeassistant.config_entries import ConfigEntry
|
ConfigEntry,
|
||||||
|
ConfigFlow,
|
||||||
|
ConfigFlowResult,
|
||||||
|
OptionsFlow,
|
||||||
|
)
|
||||||
from homeassistant.const import CONF_CODE, CONF_TOKEN, CONF_URL, CONF_USERNAME
|
from homeassistant.const import CONF_CODE, CONF_TOKEN, CONF_URL, CONF_USERNAME
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.helpers import aiohttp_client, config_validation as cv
|
from homeassistant.helpers import aiohttp_client, config_validation as cv
|
||||||
|
|
||||||
from .const import DOMAIN, LOGGER
|
from .const import DOMAIN, LOGGER
|
||||||
|
@ -47,7 +50,7 @@ def async_get_simplisafe_oauth_values() -> SimpliSafeOAuthValues:
|
||||||
return SimpliSafeOAuthValues(auth_url, code_verifier)
|
return SimpliSafeOAuthValues(auth_url, code_verifier)
|
||||||
|
|
||||||
|
|
||||||
class SimpliSafeFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
class SimpliSafeFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a SimpliSafe config flow."""
|
"""Handle a SimpliSafe config flow."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
@ -65,14 +68,14 @@ class SimpliSafeFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
"""Define the config flow to handle options."""
|
"""Define the config flow to handle options."""
|
||||||
return SimpliSafeOptionsFlowHandler(config_entry)
|
return SimpliSafeOptionsFlowHandler(config_entry)
|
||||||
|
|
||||||
async def async_step_reauth(self, config: Mapping[str, Any]) -> FlowResult:
|
async def async_step_reauth(self, config: Mapping[str, Any]) -> ConfigFlowResult:
|
||||||
"""Handle configuration by re-auth."""
|
"""Handle configuration by re-auth."""
|
||||||
self._reauth = True
|
self._reauth = True
|
||||||
return await self.async_step_user()
|
return await self.async_step_user()
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the start of the config flow."""
|
"""Handle the start of the config flow."""
|
||||||
if user_input is None:
|
if user_input is None:
|
||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
|
@ -144,7 +147,7 @@ class SimpliSafeFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
return self.async_create_entry(title=simplisafe_user_id, data=data)
|
return self.async_create_entry(title=simplisafe_user_id, data=data)
|
||||||
|
|
||||||
|
|
||||||
class SimpliSafeOptionsFlowHandler(config_entries.OptionsFlow):
|
class SimpliSafeOptionsFlowHandler(OptionsFlow):
|
||||||
"""Handle a SimpliSafe options flow."""
|
"""Handle a SimpliSafe options flow."""
|
||||||
|
|
||||||
def __init__(self, config_entry: ConfigEntry) -> None:
|
def __init__(self, config_entry: ConfigEntry) -> None:
|
||||||
|
@ -153,7 +156,7 @@ class SimpliSafeOptionsFlowHandler(config_entries.OptionsFlow):
|
||||||
|
|
||||||
async def async_step_init(
|
async def async_step_init(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Manage the options."""
|
"""Manage the options."""
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
return self.async_create_entry(data=user_input)
|
return self.async_create_entry(data=user_input)
|
||||||
|
|
|
@ -7,27 +7,28 @@ from typing import Any
|
||||||
from aioskybell import Skybell, exceptions
|
from aioskybell import Skybell, exceptions
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD
|
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
|
|
||||||
class SkybellFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
class SkybellFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow for Skybell."""
|
"""Handle a config flow for Skybell."""
|
||||||
|
|
||||||
reauth_email: str
|
reauth_email: str
|
||||||
|
|
||||||
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
|
async def async_step_reauth(
|
||||||
|
self, entry_data: Mapping[str, Any]
|
||||||
|
) -> ConfigFlowResult:
|
||||||
"""Handle a reauthorization flow request."""
|
"""Handle a reauthorization flow request."""
|
||||||
self.reauth_email = entry_data[CONF_EMAIL]
|
self.reauth_email = entry_data[CONF_EMAIL]
|
||||||
return await self.async_step_reauth_confirm()
|
return await self.async_step_reauth_confirm()
|
||||||
|
|
||||||
async def async_step_reauth_confirm(
|
async def async_step_reauth_confirm(
|
||||||
self, user_input: dict[str, str] | None = None
|
self, user_input: dict[str, str] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle user's reauth credentials."""
|
"""Handle user's reauth credentials."""
|
||||||
errors = {}
|
errors = {}
|
||||||
if user_input:
|
if user_input:
|
||||||
|
@ -53,7 +54,7 @@ class SkybellFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a flow initiated by the user."""
|
"""Handle a flow initiated by the user."""
|
||||||
errors = {}
|
errors = {}
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,8 @@ from slack import WebClient
|
||||||
from slack.errors import SlackApiError
|
from slack.errors import SlackApiError
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_API_KEY, CONF_ICON, CONF_NAME, CONF_USERNAME
|
from homeassistant.const import CONF_API_KEY, CONF_ICON, CONF_NAME, CONF_USERNAME
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.helpers import aiohttp_client
|
from homeassistant.helpers import aiohttp_client
|
||||||
|
|
||||||
from .const import CONF_DEFAULT_CHANNEL, DOMAIN
|
from .const import CONF_DEFAULT_CHANNEL, DOMAIN
|
||||||
|
@ -26,12 +25,12 @@ CONFIG_SCHEMA = vol.Schema(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class SlackFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
class SlackFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow for Slack."""
|
"""Handle a config flow for Slack."""
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, str] | None = None
|
self, user_input: dict[str, str] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a flow initiated by the user."""
|
"""Handle a flow initiated by the user."""
|
||||||
errors = {}
|
errors = {}
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,9 @@ from typing import Any
|
||||||
from asyncsleepiq import AsyncSleepIQ, SleepIQLoginException, SleepIQTimeoutException
|
from asyncsleepiq import AsyncSleepIQ, SleepIQLoginException, SleepIQTimeoutException
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry, ConfigFlow
|
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
@ -28,7 +27,9 @@ class SleepIQFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
"""Initialize the config flow."""
|
"""Initialize the config flow."""
|
||||||
self._reauth_entry: ConfigEntry | None = None
|
self._reauth_entry: ConfigEntry | None = None
|
||||||
|
|
||||||
async def async_step_import(self, import_config: dict[str, Any]) -> FlowResult:
|
async def async_step_import(
|
||||||
|
self, import_config: dict[str, Any]
|
||||||
|
) -> ConfigFlowResult:
|
||||||
"""Import a SleepIQ account as a config entry.
|
"""Import a SleepIQ account as a config entry.
|
||||||
|
|
||||||
This flow is triggered by 'async_setup' for configured accounts.
|
This flow is triggered by 'async_setup' for configured accounts.
|
||||||
|
@ -46,7 +47,7 @@ class SleepIQFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a flow initialized by the user."""
|
"""Handle a flow initialized by the user."""
|
||||||
errors = {}
|
errors = {}
|
||||||
|
|
||||||
|
@ -80,7 +81,9 @@ class SleepIQFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
last_step=True,
|
last_step=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
|
async def async_step_reauth(
|
||||||
|
self, entry_data: Mapping[str, Any]
|
||||||
|
) -> ConfigFlowResult:
|
||||||
"""Perform reauth upon an API authentication error."""
|
"""Perform reauth upon an API authentication error."""
|
||||||
self._reauth_entry = self.hass.config_entries.async_get_entry(
|
self._reauth_entry = self.hass.config_entries.async_get_entry(
|
||||||
self.context["entry_id"]
|
self.context["entry_id"]
|
||||||
|
@ -89,7 +92,7 @@ class SleepIQFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_reauth_confirm(
|
async def async_step_reauth_confirm(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Confirm reauth."""
|
"""Confirm reauth."""
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
assert self._reauth_entry is not None
|
assert self._reauth_entry is not None
|
||||||
|
|
|
@ -4,8 +4,7 @@ from __future__ import annotations
|
||||||
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigFlow
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
|
|
||||||
from .const import DEFAULT_NAME, DOMAIN
|
from .const import DEFAULT_NAME, DOMAIN
|
||||||
|
|
||||||
|
@ -17,7 +16,7 @@ class SlimProtoConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the initial step."""
|
"""Handle the initial step."""
|
||||||
if self._async_current_entries():
|
if self._async_current_entries():
|
||||||
return self.async_abort(reason="single_instance_allowed")
|
return self.async_abort(reason="single_instance_allowed")
|
||||||
|
|
|
@ -7,9 +7,9 @@ from typing import Any
|
||||||
import pysma
|
import pysma
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries, core
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_SSL, CONF_VERIFY_SSL
|
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_SSL, CONF_VERIFY_SSL
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
|
@ -18,9 +18,7 @@ from .const import CONF_GROUP, DOMAIN, GROUPS
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
async def validate_input(
|
async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> dict[str, Any]:
|
||||||
hass: core.HomeAssistant, data: dict[str, Any]
|
|
||||||
) -> dict[str, Any]:
|
|
||||||
"""Validate the user input allows us to connect."""
|
"""Validate the user input allows us to connect."""
|
||||||
session = async_get_clientsession(hass, verify_ssl=data[CONF_VERIFY_SSL])
|
session = async_get_clientsession(hass, verify_ssl=data[CONF_VERIFY_SSL])
|
||||||
|
|
||||||
|
@ -37,7 +35,7 @@ async def validate_input(
|
||||||
return device_info
|
return device_info
|
||||||
|
|
||||||
|
|
||||||
class SmaConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class SmaConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow for SMA."""
|
"""Handle a config flow for SMA."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
@ -54,7 +52,7 @@ class SmaConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""First step in config flow."""
|
"""First step in config flow."""
|
||||||
errors = {}
|
errors = {}
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
|
|
|
@ -5,8 +5,8 @@ from pysmappee import helper, mqtt
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components import zeroconf
|
from homeassistant.components import zeroconf
|
||||||
|
from homeassistant.config_entries import ConfigFlowResult
|
||||||
from homeassistant.const import CONF_HOST, CONF_IP_ADDRESS
|
from homeassistant.const import CONF_HOST, CONF_IP_ADDRESS
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.helpers import config_entry_oauth2_flow
|
from homeassistant.helpers import config_entry_oauth2_flow
|
||||||
|
|
||||||
from . import api
|
from . import api
|
||||||
|
@ -39,7 +39,7 @@ class SmappeeFlowHandler(
|
||||||
|
|
||||||
async def async_step_zeroconf(
|
async def async_step_zeroconf(
|
||||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle zeroconf discovery."""
|
"""Handle zeroconf discovery."""
|
||||||
|
|
||||||
if not discovery_info.hostname.startswith(SUPPORTED_LOCAL_DEVICES):
|
if not discovery_info.hostname.startswith(SUPPORTED_LOCAL_DEVICES):
|
||||||
|
|
|
@ -9,8 +9,10 @@ from smart_meter_texas.exceptions import (
|
||||||
)
|
)
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries, core, exceptions
|
from homeassistant.config_entries import ConfigFlow
|
||||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers import aiohttp_client
|
from homeassistant.helpers import aiohttp_client
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
@ -22,7 +24,7 @@ DATA_SCHEMA = vol.Schema(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def validate_input(hass: core.HomeAssistant, data):
|
async def validate_input(hass: HomeAssistant, data):
|
||||||
"""Validate the user input allows us to connect.
|
"""Validate the user input allows us to connect.
|
||||||
|
|
||||||
Data has the keys from DATA_SCHEMA with values provided by the user.
|
Data has the keys from DATA_SCHEMA with values provided by the user.
|
||||||
|
@ -44,7 +46,7 @@ async def validate_input(hass: core.HomeAssistant, data):
|
||||||
return {"title": account.username}
|
return {"title": account.username}
|
||||||
|
|
||||||
|
|
||||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class SMTConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow for Smart Meter Texas."""
|
"""Handle a config flow for Smart Meter Texas."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
@ -76,9 +78,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class CannotConnect(exceptions.HomeAssistantError):
|
class CannotConnect(HomeAssistantError):
|
||||||
"""Error to indicate we cannot connect."""
|
"""Error to indicate we cannot connect."""
|
||||||
|
|
||||||
|
|
||||||
class InvalidAuth(exceptions.HomeAssistantError):
|
class InvalidAuth(HomeAssistantError):
|
||||||
"""Error to indicate there is invalid auth."""
|
"""Error to indicate there is invalid auth."""
|
||||||
|
|
|
@ -7,7 +7,7 @@ from pysmartthings import APIResponseError, AppOAuth, SmartThings
|
||||||
from pysmartthings.installedapp import format_install_url
|
from pysmartthings.installedapp import format_install_url
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant.config_entries import ConfigFlow
|
||||||
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_CLIENT_ID, CONF_CLIENT_SECRET
|
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_CLIENT_ID, CONF_CLIENT_SECRET
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ from .smartapp import (
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class SmartThingsFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
class SmartThingsFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle configuration of SmartThings integrations."""
|
"""Handle configuration of SmartThings integrations."""
|
||||||
|
|
||||||
VERSION = 2
|
VERSION = 2
|
||||||
|
|
|
@ -7,9 +7,8 @@ from typing import Any
|
||||||
from smarttub import LoginFailed
|
from smarttub import LoginFailed
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD
|
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
from .controller import SmartTubController
|
from .controller import SmartTubController
|
||||||
|
@ -19,7 +18,7 @@ DATA_SCHEMA = vol.Schema(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class SmartTubConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class SmartTubConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""SmartTub configuration flow."""
|
"""SmartTub configuration flow."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
@ -28,7 +27,7 @@ class SmartTubConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
"""Instantiate config flow."""
|
"""Instantiate config flow."""
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self._reauth_input: Mapping[str, Any] | None = None
|
self._reauth_input: Mapping[str, Any] | None = None
|
||||||
self._reauth_entry: config_entries.ConfigEntry | None = None
|
self._reauth_entry: ConfigEntry | None = None
|
||||||
|
|
||||||
async def async_step_user(self, user_input=None):
|
async def async_step_user(self, user_input=None):
|
||||||
"""Handle a flow initiated by the user."""
|
"""Handle a flow initiated by the user."""
|
||||||
|
@ -67,7 +66,9 @@ class SmartTubConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
step_id="user", data_schema=DATA_SCHEMA, errors=errors
|
step_id="user", data_schema=DATA_SCHEMA, errors=errors
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
|
async def async_step_reauth(
|
||||||
|
self, entry_data: Mapping[str, Any]
|
||||||
|
) -> ConfigFlowResult:
|
||||||
"""Get new credentials if the current ones don't work anymore."""
|
"""Get new credentials if the current ones don't work anymore."""
|
||||||
self._reauth_input = entry_data
|
self._reauth_input = entry_data
|
||||||
self._reauth_entry = self.hass.config_entries.async_get_entry(
|
self._reauth_entry = self.hass.config_entries.async_get_entry(
|
||||||
|
|
|
@ -6,10 +6,9 @@ from typing import Any
|
||||||
from smhi.smhi_lib import Smhi, SmhiForecastException
|
from smhi.smhi_lib import Smhi, SmhiForecastException
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_LATITUDE, CONF_LOCATION, CONF_LONGITUDE, CONF_NAME
|
from homeassistant.const import CONF_LATITUDE, CONF_LOCATION, CONF_LONGITUDE, CONF_NAME
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.helpers import aiohttp_client
|
from homeassistant.helpers import aiohttp_client
|
||||||
from homeassistant.helpers.selector import LocationSelector
|
from homeassistant.helpers.selector import LocationSelector
|
||||||
|
|
||||||
|
@ -30,14 +29,14 @@ async def async_check_location(
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
class SmhiFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
class SmhiFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
"""Config flow for SMHI component."""
|
"""Config flow for SMHI component."""
|
||||||
|
|
||||||
VERSION = 2
|
VERSION = 2
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a flow initialized by the user."""
|
"""Handle a flow initialized by the user."""
|
||||||
|
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
|
|
|
@ -4,8 +4,10 @@ import logging
|
||||||
import gammu
|
import gammu
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries, core, exceptions
|
from homeassistant.config_entries import ConfigFlow
|
||||||
from homeassistant.const import CONF_DEVICE
|
from homeassistant.const import CONF_DEVICE
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers import selector
|
from homeassistant.helpers import selector
|
||||||
|
|
||||||
from .const import CONF_BAUD_SPEED, DEFAULT_BAUD_SPEED, DEFAULT_BAUD_SPEEDS, DOMAIN
|
from .const import CONF_BAUD_SPEED, DEFAULT_BAUD_SPEED, DEFAULT_BAUD_SPEEDS, DOMAIN
|
||||||
|
@ -23,7 +25,7 @@ DATA_SCHEMA = vol.Schema(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def get_imei_from_config(hass: core.HomeAssistant, data):
|
async def get_imei_from_config(hass: HomeAssistant, data):
|
||||||
"""Validate the user input allows us to connect.
|
"""Validate the user input allows us to connect.
|
||||||
|
|
||||||
Data has the keys from DATA_SCHEMA with values provided by the user.
|
Data has the keys from DATA_SCHEMA with values provided by the user.
|
||||||
|
@ -48,7 +50,7 @@ async def get_imei_from_config(hass: core.HomeAssistant, data):
|
||||||
return imei
|
return imei
|
||||||
|
|
||||||
|
|
||||||
class SMSFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
class SMSFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow for SMS integration."""
|
"""Handle a config flow for SMS integration."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
@ -81,5 +83,5 @@ class SMSFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
return await self.async_step_user(user_input)
|
return await self.async_step_user(user_input)
|
||||||
|
|
||||||
|
|
||||||
class CannotConnect(exceptions.HomeAssistantError):
|
class CannotConnect(HomeAssistantError):
|
||||||
"""Error to indicate we cannot connect."""
|
"""Error to indicate we cannot connect."""
|
||||||
|
|
|
@ -9,9 +9,8 @@ import snapcast.control
|
||||||
from snapcast.control.server import CONTROL_PORT
|
from snapcast.control.server import CONTROL_PORT
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigFlow
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_HOST, CONF_PORT
|
from homeassistant.const import CONF_HOST, CONF_PORT
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
|
|
||||||
from .const import DEFAULT_TITLE, DOMAIN
|
from .const import DEFAULT_TITLE, DOMAIN
|
||||||
|
|
||||||
|
@ -28,7 +27,7 @@ SNAPCAST_SCHEMA = vol.Schema(
|
||||||
class SnapcastConfigFlow(ConfigFlow, domain=DOMAIN):
|
class SnapcastConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Snapcast config flow."""
|
"""Snapcast config flow."""
|
||||||
|
|
||||||
async def async_step_user(self, user_input=None) -> FlowResult:
|
async def async_step_user(self, user_input=None) -> ConfigFlowResult:
|
||||||
"""Handle first step."""
|
"""Handle first step."""
|
||||||
errors = {}
|
errors = {}
|
||||||
if user_input:
|
if user_input:
|
||||||
|
|
|
@ -14,9 +14,8 @@ from homeassistant.components.bluetooth import (
|
||||||
async_discovered_service_info,
|
async_discovered_service_info,
|
||||||
async_process_advertisements,
|
async_process_advertisements,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigFlow
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_ADDRESS, CONF_NAME, CONF_TOKEN
|
from homeassistant.const import CONF_ADDRESS, CONF_NAME, CONF_TOKEN
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
|
@ -45,7 +44,7 @@ class SnoozConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_bluetooth(
|
async def async_step_bluetooth(
|
||||||
self, discovery_info: BluetoothServiceInfo
|
self, discovery_info: BluetoothServiceInfo
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the bluetooth discovery step."""
|
"""Handle the bluetooth discovery step."""
|
||||||
await self.async_set_unique_id(discovery_info.address)
|
await self.async_set_unique_id(discovery_info.address)
|
||||||
self._abort_if_unique_id_configured()
|
self._abort_if_unique_id_configured()
|
||||||
|
@ -57,7 +56,7 @@ class SnoozConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_bluetooth_confirm(
|
async def async_step_bluetooth_confirm(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Confirm discovery."""
|
"""Confirm discovery."""
|
||||||
assert self._discovery is not None
|
assert self._discovery is not None
|
||||||
|
|
||||||
|
@ -77,7 +76,7 @@ class SnoozConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the user step to pick discovered device."""
|
"""Handle the user step to pick discovered device."""
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
name = user_input[CONF_NAME]
|
name = user_input[CONF_NAME]
|
||||||
|
@ -128,7 +127,7 @@ class SnoozConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_wait_for_pairing_mode(
|
async def async_step_wait_for_pairing_mode(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Wait for device to enter pairing mode."""
|
"""Wait for device to enter pairing mode."""
|
||||||
if not self._pairing_task:
|
if not self._pairing_task:
|
||||||
self._pairing_task = self.hass.async_create_task(
|
self._pairing_task = self.hass.async_create_task(
|
||||||
|
@ -153,7 +152,7 @@ class SnoozConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_pairing_complete(
|
async def async_step_pairing_complete(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Create a configuration entry for a device that entered pairing mode."""
|
"""Create a configuration entry for a device that entered pairing mode."""
|
||||||
assert self._discovery
|
assert self._discovery
|
||||||
|
|
||||||
|
@ -166,7 +165,7 @@ class SnoozConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_pairing_timeout(
|
async def async_step_pairing_timeout(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Inform the user that the device never entered pairing mode."""
|
"""Inform the user that the device never entered pairing mode."""
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
return await self.async_step_wait_for_pairing_mode()
|
return await self.async_step_wait_for_pairing_mode()
|
||||||
|
@ -174,7 +173,7 @@ class SnoozConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
self._set_confirm_only()
|
self._set_confirm_only()
|
||||||
return self.async_show_form(step_id="pairing_timeout")
|
return self.async_show_form(step_id="pairing_timeout")
|
||||||
|
|
||||||
def _create_snooz_entry(self, discovery: DiscoveredSnooz) -> FlowResult:
|
def _create_snooz_entry(self, discovery: DiscoveredSnooz) -> ConfigFlowResult:
|
||||||
assert discovery.device.display_name
|
assert discovery.device.display_name
|
||||||
return self.async_create_entry(
|
return self.async_create_entry(
|
||||||
title=discovery.device.display_name,
|
title=discovery.device.display_name,
|
||||||
|
|
|
@ -7,16 +7,15 @@ from requests.exceptions import ConnectTimeout, HTTPError
|
||||||
import solaredge
|
import solaredge
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_API_KEY, CONF_NAME
|
from homeassistant.const import CONF_API_KEY, CONF_NAME
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.util import slugify
|
from homeassistant.util import slugify
|
||||||
|
|
||||||
from .const import CONF_SITE_ID, DEFAULT_NAME, DOMAIN
|
from .const import CONF_SITE_ID, DEFAULT_NAME, DOMAIN
|
||||||
|
|
||||||
|
|
||||||
class SolarEdgeConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class SolarEdgeConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow."""
|
"""Handle a config flow."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
@ -56,7 +55,7 @@ class SolarEdgeConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Step when user initializes a integration."""
|
"""Step when user initializes a integration."""
|
||||||
self._errors = {}
|
self._errors = {}
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
|
|
|
@ -6,7 +6,7 @@ from requests.exceptions import HTTPError, Timeout
|
||||||
from sunwatcher.solarlog.solarlog import SolarLog
|
from sunwatcher.solarlog.solarlog import SolarLog
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant.config_entries import ConfigFlow
|
||||||
from homeassistant.const import CONF_HOST, CONF_NAME
|
from homeassistant.const import CONF_HOST, CONF_NAME
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.util import slugify
|
from homeassistant.util import slugify
|
||||||
|
@ -24,7 +24,7 @@ def solarlog_entries(hass: HomeAssistant):
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class SolarLogConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class SolarLogConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow for solarlog."""
|
"""Handle a config flow for solarlog."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
|
|
@ -8,9 +8,8 @@ from solax import real_time_api
|
||||||
from solax.discovery import DiscoveryError
|
from solax.discovery import DiscoveryError
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_IP_ADDRESS, CONF_PASSWORD, CONF_PORT
|
from homeassistant.const import CONF_IP_ADDRESS, CONF_PASSWORD, CONF_PORT
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
@ -39,12 +38,12 @@ async def validate_api(data) -> str:
|
||||||
return response.serial_number
|
return response.serial_number
|
||||||
|
|
||||||
|
|
||||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class SolaxConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow for Solax."""
|
"""Handle a config flow for Solax."""
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the initial step."""
|
"""Handle the initial step."""
|
||||||
errors: dict[str, Any] = {}
|
errors: dict[str, Any] = {}
|
||||||
if user_input is None:
|
if user_input is None:
|
||||||
|
|
|
@ -5,7 +5,7 @@ from api.soma_api import SomaApi
|
||||||
from requests import RequestException
|
from requests import RequestException
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant.config_entries import ConfigFlow
|
||||||
from homeassistant.const import CONF_HOST, CONF_PORT
|
from homeassistant.const import CONF_HOST, CONF_PORT
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
@ -15,7 +15,7 @@ _LOGGER = logging.getLogger(__name__)
|
||||||
DEFAULT_PORT = 3000
|
DEFAULT_PORT = 3000
|
||||||
|
|
||||||
|
|
||||||
class SomaFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
class SomaFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow."""
|
"""Handle a config flow."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
|
|
@ -7,11 +7,17 @@ import logging
|
||||||
from somfy_mylink_synergy import SomfyMyLinkSynergy
|
from somfy_mylink_synergy import SomfyMyLinkSynergy
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries, core, exceptions
|
|
||||||
from homeassistant.components import dhcp
|
from homeassistant.components import dhcp
|
||||||
|
from homeassistant.config_entries import (
|
||||||
|
ConfigEntry,
|
||||||
|
ConfigEntryState,
|
||||||
|
ConfigFlow,
|
||||||
|
ConfigFlowResult,
|
||||||
|
OptionsFlow,
|
||||||
|
)
|
||||||
from homeassistant.const import CONF_HOST, CONF_PORT
|
from homeassistant.const import CONF_HOST, CONF_PORT
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers.device_registry import format_mac
|
from homeassistant.helpers.device_registry import format_mac
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
|
@ -28,7 +34,7 @@ from .const import (
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
async def validate_input(hass: core.HomeAssistant, data):
|
async def validate_input(hass: HomeAssistant, data):
|
||||||
"""Validate the user input allows us to connect.
|
"""Validate the user input allows us to connect.
|
||||||
|
|
||||||
Data has the keys from schema with values provided by the user.
|
Data has the keys from schema with values provided by the user.
|
||||||
|
@ -49,7 +55,7 @@ async def validate_input(hass: core.HomeAssistant, data):
|
||||||
return {"title": f"MyLink {data[CONF_HOST]}"}
|
return {"title": f"MyLink {data[CONF_HOST]}"}
|
||||||
|
|
||||||
|
|
||||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class SomfyConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow for Somfy MyLink."""
|
"""Handle a config flow for Somfy MyLink."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
@ -60,7 +66,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
self.mac = None
|
self.mac = None
|
||||||
self.ip_address = None
|
self.ip_address = None
|
||||||
|
|
||||||
async def async_step_dhcp(self, discovery_info: dhcp.DhcpServiceInfo) -> FlowResult:
|
async def async_step_dhcp(
|
||||||
|
self, discovery_info: dhcp.DhcpServiceInfo
|
||||||
|
) -> ConfigFlowResult:
|
||||||
"""Handle dhcp discovery."""
|
"""Handle dhcp discovery."""
|
||||||
self._async_abort_entries_match({CONF_HOST: discovery_info.ip})
|
self._async_abort_entries_match({CONF_HOST: discovery_info.ip})
|
||||||
|
|
||||||
|
@ -112,16 +120,16 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@callback
|
@callback
|
||||||
def async_get_options_flow(
|
def async_get_options_flow(
|
||||||
config_entry: config_entries.ConfigEntry,
|
config_entry: ConfigEntry,
|
||||||
) -> OptionsFlowHandler:
|
) -> OptionsFlowHandler:
|
||||||
"""Get the options flow for this handler."""
|
"""Get the options flow for this handler."""
|
||||||
return OptionsFlowHandler(config_entry)
|
return OptionsFlowHandler(config_entry)
|
||||||
|
|
||||||
|
|
||||||
class OptionsFlowHandler(config_entries.OptionsFlow):
|
class OptionsFlowHandler(OptionsFlow):
|
||||||
"""Handle a option flow for somfy_mylink."""
|
"""Handle a option flow for somfy_mylink."""
|
||||||
|
|
||||||
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
|
def __init__(self, config_entry: ConfigEntry) -> None:
|
||||||
"""Initialize options flow."""
|
"""Initialize options flow."""
|
||||||
self.config_entry = config_entry
|
self.config_entry = config_entry
|
||||||
self.options = deepcopy(dict(config_entry.options))
|
self.options = deepcopy(dict(config_entry.options))
|
||||||
|
@ -146,7 +154,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
|
||||||
async def async_step_init(self, user_input=None):
|
async def async_step_init(self, user_input=None):
|
||||||
"""Handle options flow."""
|
"""Handle options flow."""
|
||||||
|
|
||||||
if self.config_entry.state is not config_entries.ConfigEntryState.LOADED:
|
if self.config_entry.state is not ConfigEntryState.LOADED:
|
||||||
_LOGGER.error("MyLink must be connected to manage device options")
|
_LOGGER.error("MyLink must be connected to manage device options")
|
||||||
return self.async_abort(reason="cannot_connect")
|
return self.async_abort(reason="cannot_connect")
|
||||||
|
|
||||||
|
@ -194,9 +202,9 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class CannotConnect(exceptions.HomeAssistantError):
|
class CannotConnect(HomeAssistantError):
|
||||||
"""Error to indicate we cannot connect."""
|
"""Error to indicate we cannot connect."""
|
||||||
|
|
||||||
|
|
||||||
class InvalidAuth(exceptions.HomeAssistantError):
|
class InvalidAuth(HomeAssistantError):
|
||||||
"""Error to indicate there is invalid auth."""
|
"""Error to indicate there is invalid auth."""
|
||||||
|
|
|
@ -11,10 +11,14 @@ from aiopyarr.sonarr_client import SonarrClient
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
import yarl
|
import yarl
|
||||||
|
|
||||||
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_URL, CONF_VERIFY_SSL
|
from homeassistant.const import CONF_API_KEY, CONF_URL, CONF_VERIFY_SSL
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
|
@ -63,7 +67,9 @@ class SonarrConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Get the options flow for this handler."""
|
"""Get the options flow for this handler."""
|
||||||
return SonarrOptionsFlowHandler(config_entry)
|
return SonarrOptionsFlowHandler(config_entry)
|
||||||
|
|
||||||
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
|
async def async_step_reauth(
|
||||||
|
self, entry_data: Mapping[str, Any]
|
||||||
|
) -> ConfigFlowResult:
|
||||||
"""Handle configuration by re-auth."""
|
"""Handle configuration by re-auth."""
|
||||||
self.entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
|
self.entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
|
||||||
|
|
||||||
|
@ -71,7 +77,7 @@ class SonarrConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_reauth_confirm(
|
async def async_step_reauth_confirm(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Confirm reauth dialog."""
|
"""Confirm reauth dialog."""
|
||||||
if user_input is None:
|
if user_input is None:
|
||||||
assert self.entry is not None
|
assert self.entry is not None
|
||||||
|
@ -85,7 +91,7 @@ class SonarrConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a flow initiated by the user."""
|
"""Handle a flow initiated by the user."""
|
||||||
errors = {}
|
errors = {}
|
||||||
|
|
||||||
|
@ -122,7 +128,9 @@ class SonarrConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
errors=errors,
|
errors=errors,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def _async_reauth_update_entry(self, data: dict[str, Any]) -> FlowResult:
|
async def _async_reauth_update_entry(
|
||||||
|
self, data: dict[str, Any]
|
||||||
|
) -> ConfigFlowResult:
|
||||||
"""Update existing config entry."""
|
"""Update existing config entry."""
|
||||||
assert self.entry is not None
|
assert self.entry is not None
|
||||||
self.hass.config_entries.async_update_entry(self.entry, data=data)
|
self.hass.config_entries.async_update_entry(self.entry, data=data)
|
||||||
|
@ -157,7 +165,7 @@ class SonarrOptionsFlowHandler(OptionsFlow):
|
||||||
|
|
||||||
async def async_step_init(
|
async def async_step_init(
|
||||||
self, user_input: dict[str, int] | None = None
|
self, user_input: dict[str, int] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Manage Sonarr options."""
|
"""Manage Sonarr options."""
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
return self.async_create_entry(title="", data=user_input)
|
return self.async_create_entry(title="", data=user_input)
|
||||||
|
|
|
@ -7,10 +7,9 @@ from urllib.parse import urlparse
|
||||||
from songpal import Device, SongpalException
|
from songpal import Device, SongpalException
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
|
||||||
from homeassistant.components import ssdp
|
from homeassistant.components import ssdp
|
||||||
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_HOST, CONF_NAME
|
from homeassistant.const import CONF_HOST, CONF_NAME
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
|
|
||||||
from .const import CONF_ENDPOINT, DOMAIN
|
from .const import CONF_ENDPOINT, DOMAIN
|
||||||
|
|
||||||
|
@ -27,7 +26,7 @@ class SongpalConfig:
|
||||||
self.endpoint = endpoint
|
self.endpoint = endpoint
|
||||||
|
|
||||||
|
|
||||||
class SongpalConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class SongpalConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Songpal configuration flow."""
|
"""Songpal configuration flow."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
@ -93,7 +92,9 @@ class SongpalConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
data={CONF_NAME: self.conf.name, CONF_ENDPOINT: self.conf.endpoint},
|
data={CONF_NAME: self.conf.name, CONF_ENDPOINT: self.conf.endpoint},
|
||||||
)
|
)
|
||||||
|
|
||||||
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 Songpal device."""
|
"""Handle a discovered Songpal device."""
|
||||||
await self.async_set_unique_id(discovery_info.upnp[ssdp.ATTR_UPNP_UDN])
|
await self.async_set_unique_id(discovery_info.upnp[ssdp.ATTR_UPNP_UDN])
|
||||||
self._abort_if_unique_id_configured()
|
self._abort_if_unique_id_configured()
|
||||||
|
|
|
@ -3,8 +3,8 @@ from collections.abc import Awaitable
|
||||||
import dataclasses
|
import dataclasses
|
||||||
|
|
||||||
from homeassistant.components import ssdp, zeroconf
|
from homeassistant.components import ssdp, zeroconf
|
||||||
|
from homeassistant.config_entries import ConfigFlowResult
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.helpers.config_entry_flow import DiscoveryFlowHandler
|
from homeassistant.helpers.config_entry_flow import DiscoveryFlowHandler
|
||||||
|
|
||||||
from .const import DATA_SONOS_DISCOVERY_MANAGER, DOMAIN, UPNP_ST
|
from .const import DATA_SONOS_DISCOVERY_MANAGER, DOMAIN, UPNP_ST
|
||||||
|
@ -25,7 +25,7 @@ class SonosDiscoveryFlowHandler(DiscoveryFlowHandler[Awaitable[bool]], domain=DO
|
||||||
|
|
||||||
async def async_step_zeroconf(
|
async def async_step_zeroconf(
|
||||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a flow initialized by zeroconf."""
|
"""Handle a flow initialized by zeroconf."""
|
||||||
hostname = discovery_info.hostname
|
hostname = discovery_info.hostname
|
||||||
if hostname is None or not hostname.lower().startswith("sonos"):
|
if hostname is None or not hostname.lower().startswith("sonos"):
|
||||||
|
|
|
@ -5,10 +5,9 @@ from libsoundtouch import soundtouch_device
|
||||||
from requests import RequestException
|
from requests import RequestException
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
|
||||||
from homeassistant.components.zeroconf import ZeroconfServiceInfo
|
from homeassistant.components.zeroconf import ZeroconfServiceInfo
|
||||||
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_HOST
|
from homeassistant.const import CONF_HOST
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
@ -16,7 +15,7 @@ from .const import DOMAIN
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class SoundtouchConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class SoundtouchConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow for Bose SoundTouch."""
|
"""Handle a config flow for Bose SoundTouch."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
@ -53,7 +52,7 @@ class SoundtouchConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_zeroconf(
|
async def async_step_zeroconf(
|
||||||
self, discovery_info: ZeroconfServiceInfo
|
self, discovery_info: ZeroconfServiceInfo
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a flow initiated by a zeroconf discovery."""
|
"""Handle a flow initiated by a zeroconf discovery."""
|
||||||
self.host = discovery_info.host
|
self.host = discovery_info.host
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,13 @@ from typing import Any
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant.config_entries import (
|
||||||
|
ConfigEntry,
|
||||||
|
ConfigFlow,
|
||||||
|
ConfigFlowResult,
|
||||||
|
OptionsFlow,
|
||||||
|
)
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
CONF_SERVER_ID,
|
CONF_SERVER_ID,
|
||||||
|
@ -18,7 +22,7 @@ from .const import (
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class SpeedTestFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
class SpeedTestFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle Speedtest.net config flow."""
|
"""Handle Speedtest.net config flow."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
@ -26,14 +30,14 @@ class SpeedTestFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@callback
|
@callback
|
||||||
def async_get_options_flow(
|
def async_get_options_flow(
|
||||||
config_entry: config_entries.ConfigEntry,
|
config_entry: ConfigEntry,
|
||||||
) -> SpeedTestOptionsFlowHandler:
|
) -> SpeedTestOptionsFlowHandler:
|
||||||
"""Get the options flow for this handler."""
|
"""Get the options flow for this handler."""
|
||||||
return SpeedTestOptionsFlowHandler(config_entry)
|
return SpeedTestOptionsFlowHandler(config_entry)
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a flow initialized by the user."""
|
"""Handle a flow initialized by the user."""
|
||||||
if self._async_current_entries():
|
if self._async_current_entries():
|
||||||
return self.async_abort(reason="single_instance_allowed")
|
return self.async_abort(reason="single_instance_allowed")
|
||||||
|
@ -44,17 +48,17 @@ class SpeedTestFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
return self.async_create_entry(title=DEFAULT_NAME, data=user_input)
|
return self.async_create_entry(title=DEFAULT_NAME, data=user_input)
|
||||||
|
|
||||||
|
|
||||||
class SpeedTestOptionsFlowHandler(config_entries.OptionsFlow):
|
class SpeedTestOptionsFlowHandler(OptionsFlow):
|
||||||
"""Handle SpeedTest options."""
|
"""Handle SpeedTest options."""
|
||||||
|
|
||||||
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
|
def __init__(self, config_entry: ConfigEntry) -> None:
|
||||||
"""Initialize options flow."""
|
"""Initialize options flow."""
|
||||||
self.config_entry = config_entry
|
self.config_entry = config_entry
|
||||||
self._servers: dict = {}
|
self._servers: dict = {}
|
||||||
|
|
||||||
async def async_step_init(
|
async def async_step_init(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Manage the options."""
|
"""Manage the options."""
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import logging
|
||||||
from spiderpy.spiderapi import SpiderApi, SpiderApiException, UnauthorizedException
|
from spiderpy.spiderapi import SpiderApi, SpiderApiException, UnauthorizedException
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant.config_entries import ConfigFlow
|
||||||
from homeassistant.const import CONF_PASSWORD, CONF_SCAN_INTERVAL, CONF_USERNAME
|
from homeassistant.const import CONF_PASSWORD, CONF_SCAN_INTERVAL, CONF_USERNAME
|
||||||
|
|
||||||
from .const import DEFAULT_SCAN_INTERVAL, DOMAIN
|
from .const import DEFAULT_SCAN_INTERVAL, DOMAIN
|
||||||
|
@ -20,7 +20,7 @@ RESULT_CONN_ERROR = "conn_error"
|
||||||
RESULT_SUCCESS = "success"
|
RESULT_SUCCESS = "success"
|
||||||
|
|
||||||
|
|
||||||
class SpiderConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class SpiderConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a Spider config flow."""
|
"""Handle a Spider config flow."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
|
|
@ -7,8 +7,7 @@ from typing import Any
|
||||||
|
|
||||||
from spotipy import Spotify
|
from spotipy import Spotify
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry, ConfigFlowResult
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.helpers import config_entry_oauth2_flow
|
from homeassistant.helpers import config_entry_oauth2_flow
|
||||||
|
|
||||||
from .const import DOMAIN, SPOTIFY_SCOPES
|
from .const import DOMAIN, SPOTIFY_SCOPES
|
||||||
|
@ -34,7 +33,7 @@ class SpotifyFlowHandler(
|
||||||
"""Extra data that needs to be appended to the authorize url."""
|
"""Extra data that needs to be appended to the authorize url."""
|
||||||
return {"scope": ",".join(SPOTIFY_SCOPES)}
|
return {"scope": ",".join(SPOTIFY_SCOPES)}
|
||||||
|
|
||||||
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 Spotify."""
|
"""Create an entry for Spotify."""
|
||||||
spotify = Spotify(auth=data["token"]["access_token"])
|
spotify = Spotify(auth=data["token"]["access_token"])
|
||||||
|
|
||||||
|
@ -56,7 +55,9 @@ class SpotifyFlowHandler(
|
||||||
|
|
||||||
return self.async_create_entry(title=name, data=data)
|
return self.async_create_entry(title=name, data=data)
|
||||||
|
|
||||||
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
|
async def async_step_reauth(
|
||||||
|
self, entry_data: Mapping[str, Any]
|
||||||
|
) -> ConfigFlowResult:
|
||||||
"""Perform reauth upon migration of old entries."""
|
"""Perform reauth upon migration of old entries."""
|
||||||
self.reauth_entry = self.hass.config_entries.async_get_entry(
|
self.reauth_entry = self.hass.config_entries.async_get_entry(
|
||||||
self.context["entry_id"]
|
self.context["entry_id"]
|
||||||
|
@ -66,7 +67,7 @@ class SpotifyFlowHandler(
|
||||||
|
|
||||||
async def async_step_reauth_confirm(
|
async def async_step_reauth_confirm(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Confirm reauth dialog."""
|
"""Confirm reauth dialog."""
|
||||||
if self.reauth_entry is None:
|
if self.reauth_entry is None:
|
||||||
return self.async_abort(reason="reauth_account_mismatch")
|
return self.async_abort(reason="reauth_account_mismatch")
|
||||||
|
|
|
@ -12,13 +12,18 @@ import sqlparse
|
||||||
from sqlparse.exceptions import SQLParseError
|
from sqlparse.exceptions import SQLParseError
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
|
||||||
from homeassistant.components.recorder import CONF_DB_URL, get_instance
|
from homeassistant.components.recorder import CONF_DB_URL, get_instance
|
||||||
from homeassistant.components.sensor import (
|
from homeassistant.components.sensor import (
|
||||||
CONF_STATE_CLASS,
|
CONF_STATE_CLASS,
|
||||||
SensorDeviceClass,
|
SensorDeviceClass,
|
||||||
SensorStateClass,
|
SensorStateClass,
|
||||||
)
|
)
|
||||||
|
from homeassistant.config_entries import (
|
||||||
|
ConfigEntry,
|
||||||
|
ConfigFlow,
|
||||||
|
ConfigFlowResult,
|
||||||
|
OptionsFlowWithConfigEntry,
|
||||||
|
)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_DEVICE_CLASS,
|
CONF_DEVICE_CLASS,
|
||||||
CONF_NAME,
|
CONF_NAME,
|
||||||
|
@ -26,7 +31,6 @@ from homeassistant.const import (
|
||||||
CONF_VALUE_TEMPLATE,
|
CONF_VALUE_TEMPLATE,
|
||||||
)
|
)
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.helpers import selector
|
from homeassistant.helpers import selector
|
||||||
|
|
||||||
from .const import CONF_COLUMN_NAME, CONF_QUERY, DOMAIN
|
from .const import CONF_COLUMN_NAME, CONF_QUERY, DOMAIN
|
||||||
|
@ -128,7 +132,7 @@ def validate_query(db_url: str, query: str, column: str) -> bool:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
class SQLConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class SQLConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow for SQL integration."""
|
"""Handle a config flow for SQL integration."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
@ -136,14 +140,14 @@ class SQLConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@callback
|
@callback
|
||||||
def async_get_options_flow(
|
def async_get_options_flow(
|
||||||
config_entry: config_entries.ConfigEntry,
|
config_entry: ConfigEntry,
|
||||||
) -> SQLOptionsFlowHandler:
|
) -> SQLOptionsFlowHandler:
|
||||||
"""Get the options flow for this handler."""
|
"""Get the options flow for this handler."""
|
||||||
return SQLOptionsFlowHandler(config_entry)
|
return SQLOptionsFlowHandler(config_entry)
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the user step."""
|
"""Handle the user step."""
|
||||||
errors = {}
|
errors = {}
|
||||||
description_placeholders = {}
|
description_placeholders = {}
|
||||||
|
@ -204,12 +208,12 @@ class SQLConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class SQLOptionsFlowHandler(config_entries.OptionsFlowWithConfigEntry):
|
class SQLOptionsFlowHandler(OptionsFlowWithConfigEntry):
|
||||||
"""Handle SQL options."""
|
"""Handle SQL options."""
|
||||||
|
|
||||||
async def async_step_init(
|
async def async_step_init(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Manage SQL options."""
|
"""Manage SQL options."""
|
||||||
errors = {}
|
errors = {}
|
||||||
description_placeholders = {}
|
description_placeholders = {}
|
||||||
|
|
|
@ -7,10 +7,11 @@ from typing import TYPE_CHECKING
|
||||||
from pysqueezebox import Server, async_discover
|
from pysqueezebox import Server, async_discover
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries, data_entry_flow
|
|
||||||
from homeassistant.components import dhcp
|
from homeassistant.components import dhcp
|
||||||
from homeassistant.components.media_player import DOMAIN as MP_DOMAIN
|
from homeassistant.components.media_player import DOMAIN as MP_DOMAIN
|
||||||
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT, CONF_USERNAME
|
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT, CONF_USERNAME
|
||||||
|
from homeassistant.data_entry_flow import AbortFlow
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
from homeassistant.helpers.device_registry import format_mac
|
from homeassistant.helpers.device_registry import format_mac
|
||||||
from homeassistant.helpers.entity_registry import async_get
|
from homeassistant.helpers.entity_registry import async_get
|
||||||
|
@ -61,7 +62,7 @@ def _base_schema(discovery_info=None):
|
||||||
return vol.Schema(base_schema)
|
return vol.Schema(base_schema)
|
||||||
|
|
||||||
|
|
||||||
class SqueezeboxConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class SqueezeboxConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow for Logitech Squeezebox."""
|
"""Handle a config flow for Logitech Squeezebox."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
@ -187,7 +188,7 @@ class SqueezeboxConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_dhcp(
|
async def async_step_dhcp(
|
||||||
self, discovery_info: dhcp.DhcpServiceInfo
|
self, discovery_info: dhcp.DhcpServiceInfo
|
||||||
) -> data_entry_flow.FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle dhcp discovery of a Squeezebox player."""
|
"""Handle dhcp discovery of a Squeezebox player."""
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"Reached dhcp discovery of a player with info: %s", discovery_info
|
"Reached dhcp discovery of a player with info: %s", discovery_info
|
||||||
|
@ -204,7 +205,7 @@ class SqueezeboxConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
# if we have detected this player, do nothing. if not, there must be a server out there for us to configure, so start the normal user flow (which tries to autodetect server)
|
# if we have detected this player, do nothing. if not, there must be a server out there for us to configure, so start the normal user flow (which tries to autodetect server)
|
||||||
if registry.async_get_entity_id(MP_DOMAIN, DOMAIN, self.unique_id) is not None:
|
if registry.async_get_entity_id(MP_DOMAIN, DOMAIN, self.unique_id) is not None:
|
||||||
# this player is already known, so do nothing other than mark as configured
|
# this player is already known, so do nothing other than mark as configured
|
||||||
raise data_entry_flow.AbortFlow("already_configured")
|
raise AbortFlow("already_configured")
|
||||||
|
|
||||||
# if the player is unknown, then we likely need to configure its server
|
# if the player is unknown, then we likely need to configure its server
|
||||||
return await self.async_step_user()
|
return await self.async_step_user()
|
||||||
|
|
|
@ -6,10 +6,9 @@ from typing import Any
|
||||||
from srpenergy.client import SrpEnergyClient
|
from srpenergy.client import SrpEnergyClient
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_ID, CONF_NAME, CONF_PASSWORD, CONF_USERNAME
|
from homeassistant.const import CONF_ID, CONF_NAME, CONF_PASSWORD, CONF_USERNAME
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
|
|
||||||
from .const import CONF_IS_TOU, DOMAIN, LOGGER
|
from .const import CONF_IS_TOU, DOMAIN, LOGGER
|
||||||
|
@ -35,13 +34,13 @@ async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> dict[str,
|
||||||
return is_valid
|
return is_valid
|
||||||
|
|
||||||
|
|
||||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class SRPEnergyConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle an SRP Energy config flow."""
|
"""Handle an SRP Energy config flow."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def _show_form(self, errors: dict[str, Any]) -> FlowResult:
|
def _show_form(self, errors: dict[str, Any]) -> ConfigFlowResult:
|
||||||
"""Show the form to the user."""
|
"""Show the form to the user."""
|
||||||
LOGGER.debug("Show Form")
|
LOGGER.debug("Show Form")
|
||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
|
@ -62,7 +61,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a flow initialized by the user."""
|
"""Handle a flow initialized by the user."""
|
||||||
LOGGER.debug("Config entry")
|
LOGGER.debug("Config entry")
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
|
|
|
@ -4,8 +4,9 @@ from __future__ import annotations
|
||||||
from starline import StarlineAuth
|
from starline import StarlineAuth
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries, core
|
from homeassistant.config_entries import ConfigFlow
|
||||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||||
|
from homeassistant.core import callback
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
_LOGGER,
|
_LOGGER,
|
||||||
|
@ -24,7 +25,7 @@ from .const import (
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class StarlineFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
class StarlineFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a StarLine config flow."""
|
"""Handle a StarLine config flow."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
@ -84,7 +85,7 @@ class StarlineFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
return await self._async_authenticate_user(error)
|
return await self._async_authenticate_user(error)
|
||||||
return self._async_form_auth_captcha(error)
|
return self._async_form_auth_captcha(error)
|
||||||
|
|
||||||
@core.callback
|
@callback
|
||||||
def _async_form_auth_app(self, error=None):
|
def _async_form_auth_app(self, error=None):
|
||||||
"""Authenticate application form."""
|
"""Authenticate application form."""
|
||||||
errors = {}
|
errors = {}
|
||||||
|
@ -106,7 +107,7 @@ class StarlineFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
errors=errors,
|
errors=errors,
|
||||||
)
|
)
|
||||||
|
|
||||||
@core.callback
|
@callback
|
||||||
def _async_form_auth_user(self, error=None):
|
def _async_form_auth_user(self, error=None):
|
||||||
"""Authenticate user form."""
|
"""Authenticate user form."""
|
||||||
errors = {}
|
errors = {}
|
||||||
|
@ -128,7 +129,7 @@ class StarlineFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
errors=errors,
|
errors=errors,
|
||||||
)
|
)
|
||||||
|
|
||||||
@core.callback
|
@callback
|
||||||
def _async_form_auth_mfa(self, error=None):
|
def _async_form_auth_mfa(self, error=None):
|
||||||
"""Authenticate mfa form."""
|
"""Authenticate mfa form."""
|
||||||
errors = {}
|
errors = {}
|
||||||
|
@ -148,7 +149,7 @@ class StarlineFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
description_placeholders={"phone_number": self._phone_number},
|
description_placeholders={"phone_number": self._phone_number},
|
||||||
)
|
)
|
||||||
|
|
||||||
@core.callback
|
@callback
|
||||||
def _async_form_auth_captcha(self, error=None):
|
def _async_form_auth_captcha(self, error=None):
|
||||||
"""Captcha verification form."""
|
"""Captcha verification form."""
|
||||||
errors = {}
|
errors = {}
|
||||||
|
|
|
@ -6,9 +6,8 @@ from typing import Any
|
||||||
from starlink_grpc import ChannelContext, GrpcError, get_id
|
from starlink_grpc import ChannelContext, GrpcError, get_id
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigFlow
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_IP_ADDRESS
|
from homeassistant.const import CONF_IP_ADDRESS
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
|
@ -22,7 +21,7 @@ class StarlinkConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Ask the user for a server address and a name for the system."""
|
"""Ask the user for a server address and a name for the system."""
|
||||||
errors = {}
|
errors = {}
|
||||||
if user_input:
|
if user_input:
|
||||||
|
|
|
@ -7,10 +7,15 @@ from typing import Any
|
||||||
import steam
|
import steam
|
||||||
import voluptuous as vol
|
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_API_KEY, Platform
|
from homeassistant.const import CONF_API_KEY, Platform
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.helpers import config_validation as cv, entity_registry as er
|
from homeassistant.helpers import config_validation as cv, entity_registry as er
|
||||||
|
|
||||||
from .const import CONF_ACCOUNT, CONF_ACCOUNTS, DOMAIN, LOGGER, PLACEHOLDERS
|
from .const import CONF_ACCOUNT, CONF_ACCOUNTS, DOMAIN, LOGGER, PLACEHOLDERS
|
||||||
|
@ -27,24 +32,24 @@ def validate_input(user_input: dict[str, str]) -> dict[str, str | int]:
|
||||||
return names["response"]["players"]["player"][0]
|
return names["response"]["players"]["player"][0]
|
||||||
|
|
||||||
|
|
||||||
class SteamFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
class SteamFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow for Steam."""
|
"""Handle a config flow for Steam."""
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
"""Initialize the flow."""
|
"""Initialize the flow."""
|
||||||
self.entry: config_entries.ConfigEntry | None = None
|
self.entry: ConfigEntry | None = None
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@callback
|
@callback
|
||||||
def async_get_options_flow(
|
def async_get_options_flow(
|
||||||
config_entry: config_entries.ConfigEntry,
|
config_entry: ConfigEntry,
|
||||||
) -> config_entries.OptionsFlow:
|
) -> OptionsFlow:
|
||||||
"""Get the options flow for this handler."""
|
"""Get the options flow for this handler."""
|
||||||
return SteamOptionsFlowHandler(config_entry)
|
return SteamOptionsFlowHandler(config_entry)
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a flow initiated by the user."""
|
"""Handle a flow initiated by the user."""
|
||||||
errors = {}
|
errors = {}
|
||||||
if user_input is None and self.entry:
|
if user_input is None and self.entry:
|
||||||
|
@ -65,7 +70,7 @@ class SteamFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
errors["base"] = "unknown"
|
errors["base"] = "unknown"
|
||||||
if not errors:
|
if not errors:
|
||||||
entry = await self.async_set_unique_id(user_input[CONF_ACCOUNT])
|
entry = await self.async_set_unique_id(user_input[CONF_ACCOUNT])
|
||||||
if entry and self.source == config_entries.SOURCE_REAUTH:
|
if entry and self.source == SOURCE_REAUTH:
|
||||||
self.hass.config_entries.async_update_entry(entry, data=user_input)
|
self.hass.config_entries.async_update_entry(entry, data=user_input)
|
||||||
await self.hass.config_entries.async_reload(entry.entry_id)
|
await self.hass.config_entries.async_reload(entry.entry_id)
|
||||||
return self.async_abort(reason="reauth_successful")
|
return self.async_abort(reason="reauth_successful")
|
||||||
|
@ -92,7 +97,9 @@ class SteamFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
description_placeholders=PLACEHOLDERS,
|
description_placeholders=PLACEHOLDERS,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
|
async def async_step_reauth(
|
||||||
|
self, entry_data: Mapping[str, Any]
|
||||||
|
) -> ConfigFlowResult:
|
||||||
"""Handle a reauthorization flow request."""
|
"""Handle a reauthorization flow request."""
|
||||||
self.entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
|
self.entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
|
||||||
|
|
||||||
|
@ -100,7 +107,7 @@ class SteamFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_reauth_confirm(
|
async def async_step_reauth_confirm(
|
||||||
self, user_input: dict[str, str] | None = None
|
self, user_input: dict[str, str] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Confirm reauth dialog."""
|
"""Confirm reauth dialog."""
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
return await self.async_step_user()
|
return await self.async_step_user()
|
||||||
|
@ -116,17 +123,17 @@ def _batch_ids(ids: list[str]) -> Iterator[list[str]]:
|
||||||
yield ids[i : i + MAX_IDS_TO_REQUEST]
|
yield ids[i : i + MAX_IDS_TO_REQUEST]
|
||||||
|
|
||||||
|
|
||||||
class SteamOptionsFlowHandler(config_entries.OptionsFlow):
|
class SteamOptionsFlowHandler(OptionsFlow):
|
||||||
"""Handle Steam client options."""
|
"""Handle Steam client options."""
|
||||||
|
|
||||||
def __init__(self, entry: config_entries.ConfigEntry) -> None:
|
def __init__(self, entry: ConfigEntry) -> None:
|
||||||
"""Initialize options flow."""
|
"""Initialize options flow."""
|
||||||
self.entry = entry
|
self.entry = entry
|
||||||
self.options = dict(entry.options)
|
self.options = dict(entry.options)
|
||||||
|
|
||||||
async def async_step_init(
|
async def async_step_init(
|
||||||
self, user_input: dict[str, dict[str, str]] | None = None
|
self, user_input: dict[str, dict[str, str]] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Manage Steam options."""
|
"""Manage Steam options."""
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
await self.hass.config_entries.async_unload(self.entry.entry_id)
|
await self.hass.config_entries.async_unload(self.entry.entry_id)
|
||||||
|
|
|
@ -8,11 +8,10 @@ from aiosteamist import Steamist
|
||||||
from discovery30303 import Device30303, normalize_mac
|
from discovery30303 import Device30303, normalize_mac
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
|
||||||
from homeassistant.components import dhcp
|
from homeassistant.components import dhcp
|
||||||
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_DEVICE, CONF_HOST, CONF_MODEL, CONF_NAME
|
from homeassistant.const import CONF_DEVICE, CONF_HOST, CONF_MODEL, CONF_NAME
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.helpers import device_registry as dr
|
from homeassistant.helpers import device_registry as dr
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
from homeassistant.helpers.typing import DiscoveryInfoType
|
from homeassistant.helpers.typing import DiscoveryInfoType
|
||||||
|
@ -28,7 +27,7 @@ from .discovery import (
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class SteamistConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow for Steamist."""
|
"""Handle a config flow for Steamist."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
@ -38,7 +37,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
self._discovered_devices: dict[str, Device30303] = {}
|
self._discovered_devices: dict[str, Device30303] = {}
|
||||||
self._discovered_device: Device30303 | None = None
|
self._discovered_device: Device30303 | 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 discovery via dhcp."""
|
"""Handle discovery via dhcp."""
|
||||||
self._discovered_device = Device30303(
|
self._discovered_device = Device30303(
|
||||||
ipaddress=discovery_info.ip,
|
ipaddress=discovery_info.ip,
|
||||||
|
@ -50,7 +51,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_integration_discovery(
|
async def async_step_integration_discovery(
|
||||||
self, discovery_info: DiscoveryInfoType
|
self, discovery_info: DiscoveryInfoType
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle integration discovery."""
|
"""Handle integration discovery."""
|
||||||
self._discovered_device = Device30303(
|
self._discovered_device = Device30303(
|
||||||
ipaddress=discovery_info["ipaddress"],
|
ipaddress=discovery_info["ipaddress"],
|
||||||
|
@ -60,7 +61,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
)
|
)
|
||||||
return await self._async_handle_discovery()
|
return await self._async_handle_discovery()
|
||||||
|
|
||||||
async def _async_handle_discovery(self) -> FlowResult:
|
async def _async_handle_discovery(self) -> ConfigFlowResult:
|
||||||
"""Handle any discovery."""
|
"""Handle any discovery."""
|
||||||
device = self._discovered_device
|
device = self._discovered_device
|
||||||
assert device is not None
|
assert device is not None
|
||||||
|
@ -91,7 +92,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_discovery_confirm(
|
async def async_step_discovery_confirm(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Confirm discovery."""
|
"""Confirm discovery."""
|
||||||
assert self._discovered_device is not None
|
assert self._discovered_device is not None
|
||||||
device = self._discovered_device
|
device = self._discovered_device
|
||||||
|
@ -108,7 +109,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
)
|
)
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def _async_create_entry_from_device(self, device: Device30303) -> FlowResult:
|
def _async_create_entry_from_device(self, device: Device30303) -> ConfigFlowResult:
|
||||||
"""Create a config entry from a device."""
|
"""Create a config entry from a device."""
|
||||||
self._async_abort_entries_match({CONF_HOST: device.ipaddress})
|
self._async_abort_entries_match({CONF_HOST: device.ipaddress})
|
||||||
data = {CONF_HOST: device.ipaddress, CONF_NAME: device.name}
|
data = {CONF_HOST: device.ipaddress, CONF_NAME: device.name}
|
||||||
|
@ -121,7 +122,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_pick_device(
|
async def async_step_pick_device(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the step to pick discovered device."""
|
"""Handle the step to pick discovered device."""
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
mac = user_input[CONF_DEVICE]
|
mac = user_input[CONF_DEVICE]
|
||||||
|
@ -153,7 +154,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the initial step."""
|
"""Handle the initial step."""
|
||||||
errors = {}
|
errors = {}
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,7 @@ from typing import Any
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigFlow
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
|
|
||||||
from .const import CONF_PROVINCE, DOMAIN, PROVINCES
|
from .const import CONF_PROVINCE, DOMAIN, PROVINCES
|
||||||
|
|
||||||
|
@ -18,7 +17,7 @@ class StookalertFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a flow initialized by the user."""
|
"""Handle a flow initialized by the user."""
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
await self.async_set_unique_id(user_input[CONF_PROVINCE])
|
await self.async_set_unique_id(user_input[CONF_PROVINCE])
|
||||||
|
|
|
@ -5,9 +5,8 @@ from typing import Any
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigFlow
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_LATITUDE, CONF_LOCATION, CONF_LONGITUDE
|
from homeassistant.const import CONF_LATITUDE, CONF_LOCATION, CONF_LONGITUDE
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.helpers.selector import LocationSelector
|
from homeassistant.helpers.selector import LocationSelector
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
@ -20,7 +19,7 @@ class StookwijzerFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a flow initialized by the user."""
|
"""Handle a flow initialized by the user."""
|
||||||
|
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
|
|
|
@ -6,10 +6,9 @@ from typing import Any
|
||||||
from streamlabswater.streamlabswater import StreamlabsClient
|
from streamlabswater.streamlabswater import StreamlabsClient
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigFlow
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_API_KEY
|
from homeassistant.const import CONF_API_KEY
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
|
|
||||||
from .const import DOMAIN, LOGGER
|
from .const import DOMAIN, LOGGER
|
||||||
|
@ -32,7 +31,7 @@ class StreamlabsConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the initial step."""
|
"""Handle the initial step."""
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
|
@ -57,7 +56,7 @@ class StreamlabsConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
errors=errors,
|
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:
|
||||||
"""Import the yaml config."""
|
"""Import the yaml config."""
|
||||||
self._async_abort_entries_match(user_input)
|
self._async_abort_entries_match(user_input)
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -14,7 +14,12 @@ from subarulink import (
|
||||||
from subarulink.const import COUNTRY_CAN, COUNTRY_USA
|
from subarulink.const import COUNTRY_CAN, COUNTRY_USA
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant.config_entries import (
|
||||||
|
ConfigEntry,
|
||||||
|
ConfigFlow,
|
||||||
|
ConfigFlowResult,
|
||||||
|
OptionsFlow,
|
||||||
|
)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_COUNTRY,
|
CONF_COUNTRY,
|
||||||
CONF_DEVICE_ID,
|
CONF_DEVICE_ID,
|
||||||
|
@ -23,7 +28,6 @@ from homeassistant.const import (
|
||||||
CONF_USERNAME,
|
CONF_USERNAME,
|
||||||
)
|
)
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.helpers import aiohttp_client, config_validation as cv
|
from homeassistant.helpers import aiohttp_client, config_validation as cv
|
||||||
|
|
||||||
from .const import CONF_UPDATE_ENABLED, DOMAIN
|
from .const import CONF_UPDATE_ENABLED, DOMAIN
|
||||||
|
@ -34,7 +38,7 @@ CONF_VALIDATION_CODE = "validation_code"
|
||||||
PIN_SCHEMA = vol.Schema({vol.Required(CONF_PIN): str})
|
PIN_SCHEMA = vol.Schema({vol.Required(CONF_PIN): str})
|
||||||
|
|
||||||
|
|
||||||
class SubaruConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class SubaruConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow for Subaru."""
|
"""Handle a config flow for Subaru."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
@ -46,7 +50,7 @@ class SubaruConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the start of the config flow."""
|
"""Handle the start of the config flow."""
|
||||||
error = None
|
error = None
|
||||||
|
|
||||||
|
@ -96,7 +100,7 @@ class SubaruConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@callback
|
@callback
|
||||||
def async_get_options_flow(
|
def async_get_options_flow(
|
||||||
config_entry: config_entries.ConfigEntry,
|
config_entry: ConfigEntry,
|
||||||
) -> OptionsFlowHandler:
|
) -> OptionsFlowHandler:
|
||||||
"""Get the options flow for this handler."""
|
"""Get the options flow for this handler."""
|
||||||
return OptionsFlowHandler(config_entry)
|
return OptionsFlowHandler(config_entry)
|
||||||
|
@ -129,7 +133,7 @@ class SubaruConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_two_factor(
|
async def async_step_two_factor(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Select contact method and request 2FA code from Subaru."""
|
"""Select contact method and request 2FA code from Subaru."""
|
||||||
error = None
|
error = None
|
||||||
if user_input:
|
if user_input:
|
||||||
|
@ -157,7 +161,7 @@ class SubaruConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_two_factor_validate(
|
async def async_step_two_factor_validate(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Validate received 2FA code with Subaru."""
|
"""Validate received 2FA code with Subaru."""
|
||||||
error = None
|
error = None
|
||||||
if user_input:
|
if user_input:
|
||||||
|
@ -182,7 +186,7 @@ class SubaruConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_pin(
|
async def async_step_pin(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle second part of config flow, if required."""
|
"""Handle second part of config flow, if required."""
|
||||||
error = None
|
error = None
|
||||||
if user_input and self.controller.update_saved_pin(user_input[CONF_PIN]):
|
if user_input and self.controller.update_saved_pin(user_input[CONF_PIN]):
|
||||||
|
@ -202,16 +206,16 @@ class SubaruConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
return self.async_show_form(step_id="pin", data_schema=PIN_SCHEMA, errors=error)
|
return self.async_show_form(step_id="pin", data_schema=PIN_SCHEMA, errors=error)
|
||||||
|
|
||||||
|
|
||||||
class OptionsFlowHandler(config_entries.OptionsFlow):
|
class OptionsFlowHandler(OptionsFlow):
|
||||||
"""Handle a option flow for Subaru."""
|
"""Handle a option flow for Subaru."""
|
||||||
|
|
||||||
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
|
def __init__(self, config_entry: ConfigEntry) -> None:
|
||||||
"""Initialize options flow."""
|
"""Initialize options flow."""
|
||||||
self.config_entry = config_entry
|
self.config_entry = config_entry
|
||||||
|
|
||||||
async def async_step_init(
|
async def async_step_init(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle options flow."""
|
"""Handle options flow."""
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
return self.async_create_entry(title="", data=user_input)
|
return self.async_create_entry(title="", data=user_input)
|
||||||
|
|
|
@ -8,9 +8,8 @@ from pysuez import SuezClient
|
||||||
from pysuez.client import PySuezError
|
from pysuez.client import PySuezError
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigFlow
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
|
|
||||||
from .const import CONF_COUNTER_ID, DOMAIN
|
from .const import CONF_COUNTER_ID, DOMAIN
|
||||||
|
@ -51,7 +50,7 @@ class SuezWaterConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the initial step."""
|
"""Handle the initial step."""
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
|
@ -75,7 +74,7 @@ class SuezWaterConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
step_id="user", data_schema=STEP_USER_DATA_SCHEMA, errors=errors
|
step_id="user", data_schema=STEP_USER_DATA_SCHEMA, 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:
|
||||||
"""Import the yaml config."""
|
"""Import the yaml config."""
|
||||||
await self.async_set_unique_id(user_input[CONF_USERNAME])
|
await self.async_set_unique_id(user_input[CONF_USERNAME])
|
||||||
self._abort_if_unique_id_configured()
|
self._abort_if_unique_id_configured()
|
||||||
|
|
|
@ -3,8 +3,7 @@ from __future__ import annotations
|
||||||
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigFlow
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
|
|
||||||
from .const import DEFAULT_NAME, DOMAIN
|
from .const import DEFAULT_NAME, DOMAIN
|
||||||
|
|
||||||
|
@ -16,7 +15,7 @@ class SunConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a flow initialized by the user."""
|
"""Handle a flow initialized by the user."""
|
||||||
if self._async_current_entries():
|
if self._async_current_entries():
|
||||||
return self.async_abort(reason="single_instance_allowed")
|
return self.async_abort(reason="single_instance_allowed")
|
||||||
|
@ -26,6 +25,6 @@ class SunConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
return self.async_show_form(step_id="user")
|
return self.async_show_form(step_id="user")
|
||||||
|
|
||||||
async def async_step_import(self, user_input: dict[str, Any]) -> FlowResult:
|
async def async_step_import(self, user_input: dict[str, Any]) -> ConfigFlowResult:
|
||||||
"""Handle import from configuration.yaml."""
|
"""Handle import from configuration.yaml."""
|
||||||
return await self.async_step_user(user_input)
|
return await self.async_step_user(user_input)
|
||||||
|
|
|
@ -2,15 +2,14 @@
|
||||||
from sunweg.api import APIHelper
|
from sunweg.api import APIHelper
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_NAME, CONF_PASSWORD, CONF_USERNAME
|
from homeassistant.const import CONF_NAME, CONF_PASSWORD, CONF_USERNAME
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
|
|
||||||
from .const import CONF_PLANT_ID, DOMAIN
|
from .const import CONF_PLANT_ID, DOMAIN
|
||||||
|
|
||||||
|
|
||||||
class SunWEGConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class SunWEGConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Config flow class."""
|
"""Config flow class."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
@ -21,7 +20,7 @@ class SunWEGConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
self.data: dict = {}
|
self.data: dict = {}
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def _async_show_user_form(self, errors=None) -> FlowResult:
|
def _async_show_user_form(self, errors=None) -> ConfigFlowResult:
|
||||||
"""Show the form to the user."""
|
"""Show the form to the user."""
|
||||||
data_schema = vol.Schema(
|
data_schema = vol.Schema(
|
||||||
{
|
{
|
||||||
|
@ -34,7 +33,7 @@ class SunWEGConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
step_id="user", data_schema=data_schema, errors=errors
|
step_id="user", data_schema=data_schema, errors=errors
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_user(self, user_input=None) -> FlowResult:
|
async def async_step_user(self, user_input=None) -> ConfigFlowResult:
|
||||||
"""Handle the start of the config flow."""
|
"""Handle the start of the config flow."""
|
||||||
if not user_input:
|
if not user_input:
|
||||||
return self._async_show_user_form()
|
return self._async_show_user_form()
|
||||||
|
@ -50,7 +49,7 @@ class SunWEGConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
self.data = user_input
|
self.data = user_input
|
||||||
return await self.async_step_plant()
|
return await self.async_step_plant()
|
||||||
|
|
||||||
async def async_step_plant(self, user_input=None) -> FlowResult:
|
async def async_step_plant(self, user_input=None) -> ConfigFlowResult:
|
||||||
"""Handle adding a "plant" to Home Assistant."""
|
"""Handle adding a "plant" to Home Assistant."""
|
||||||
plant_list = await self.hass.async_add_executor_job(self.api.listPlants)
|
plant_list = await self.hass.async_add_executor_job(self.api.listPlants)
|
||||||
|
|
||||||
|
|
|
@ -9,10 +9,9 @@ import surepy
|
||||||
from surepy.exceptions import SurePetcareAuthenticationError, SurePetcareError
|
from surepy.exceptions import SurePetcareAuthenticationError, SurePetcareError
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_PASSWORD, CONF_TOKEN, CONF_USERNAME
|
from homeassistant.const import CONF_PASSWORD, CONF_TOKEN, CONF_USERNAME
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
|
|
||||||
from .const import DOMAIN, SURE_API_TIMEOUT
|
from .const import DOMAIN, SURE_API_TIMEOUT
|
||||||
|
@ -42,7 +41,7 @@ async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> dict[str,
|
||||||
return {CONF_TOKEN: token}
|
return {CONF_TOKEN: token}
|
||||||
|
|
||||||
|
|
||||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class SurePetCareConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow for Sure Petcare."""
|
"""Handle a config flow for Sure Petcare."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
@ -53,7 +52,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the initial step."""
|
"""Handle the initial step."""
|
||||||
if user_input is None:
|
if user_input is None:
|
||||||
return self.async_show_form(step_id="user", data_schema=USER_DATA_SCHEMA)
|
return self.async_show_form(step_id="user", data_schema=USER_DATA_SCHEMA)
|
||||||
|
@ -83,14 +82,16 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
step_id="user", data_schema=USER_DATA_SCHEMA, errors=errors
|
step_id="user", data_schema=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 configuration by re-auth."""
|
"""Handle configuration by re-auth."""
|
||||||
self._username = entry_data[CONF_USERNAME]
|
self._username = entry_data[CONF_USERNAME]
|
||||||
return await self.async_step_reauth_confirm()
|
return await self.async_step_reauth_confirm()
|
||||||
|
|
||||||
async def async_step_reauth_confirm(
|
async def async_step_reauth_confirm(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Dialog that informs the user that reauth is required."""
|
"""Dialog that informs the user that reauth is required."""
|
||||||
errors = {}
|
errors = {}
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
|
|
|
@ -9,9 +9,8 @@ from opendata_transport.exceptions import (
|
||||||
)
|
)
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_NAME
|
from homeassistant.const import CONF_NAME
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
|
@ -27,7 +26,7 @@ DATA_SCHEMA = vol.Schema(
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class SwissPublicTransportConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class SwissPublicTransportConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Swiss public transport config flow."""
|
"""Swiss public transport config flow."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
@ -35,7 +34,7 @@ class SwissPublicTransportConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Async user step to set up the connection."""
|
"""Async user step to set up the connection."""
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
|
@ -70,7 +69,7 @@ class SwissPublicTransportConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
description_placeholders=PLACEHOLDERS,
|
description_placeholders=PLACEHOLDERS,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_import(self, import_input: dict[str, Any]) -> FlowResult:
|
async def async_step_import(self, import_input: dict[str, Any]) -> ConfigFlowResult:
|
||||||
"""Async import step to set up the connection."""
|
"""Async import step to set up the connection."""
|
||||||
await self.async_set_unique_id(
|
await self.async_set_unique_id(
|
||||||
f"{import_input[CONF_START]} {import_input[CONF_DESTINATION]}"
|
f"{import_input[CONF_START]} {import_input[CONF_DESTINATION]}"
|
||||||
|
|
|
@ -8,10 +8,9 @@ from switchbee.api.central_unit import SwitchBeeError
|
||||||
from switchbee.api.polling import CentralUnitPolling
|
from switchbee.api.polling import CentralUnitPolling
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME
|
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
@ -53,14 +52,14 @@ async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> str:
|
||||||
return format_mac(api.mac)
|
return format_mac(api.mac)
|
||||||
|
|
||||||
|
|
||||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class SwitchBeeConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow for SwitchBee Smart Home."""
|
"""Handle a config flow for SwitchBee Smart Home."""
|
||||||
|
|
||||||
VERSION = 2
|
VERSION = 2
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Show the setup form to the user."""
|
"""Show the setup form to the user."""
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,12 @@ from homeassistant.components.bluetooth import (
|
||||||
BluetoothServiceInfoBleak,
|
BluetoothServiceInfoBleak,
|
||||||
async_discovered_service_info,
|
async_discovered_service_info,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry, ConfigFlow, OptionsFlow
|
from homeassistant.config_entries import (
|
||||||
|
ConfigEntry,
|
||||||
|
ConfigFlow,
|
||||||
|
ConfigFlowResult,
|
||||||
|
OptionsFlow,
|
||||||
|
)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_ADDRESS,
|
CONF_ADDRESS,
|
||||||
CONF_PASSWORD,
|
CONF_PASSWORD,
|
||||||
|
@ -26,7 +31,7 @@ from homeassistant.const import (
|
||||||
CONF_USERNAME,
|
CONF_USERNAME,
|
||||||
)
|
)
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.data_entry_flow import AbortFlow, FlowResult
|
from homeassistant.data_entry_flow import AbortFlow
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
CONF_ENCRYPTION_KEY,
|
CONF_ENCRYPTION_KEY,
|
||||||
|
@ -78,7 +83,7 @@ class SwitchbotConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_bluetooth(
|
async def async_step_bluetooth(
|
||||||
self, discovery_info: BluetoothServiceInfoBleak
|
self, discovery_info: BluetoothServiceInfoBleak
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the bluetooth discovery step."""
|
"""Handle the bluetooth discovery step."""
|
||||||
_LOGGER.debug("Discovered bluetooth device: %s", discovery_info.as_dict())
|
_LOGGER.debug("Discovered bluetooth device: %s", discovery_info.as_dict())
|
||||||
await self.async_set_unique_id(format_unique_id(discovery_info.address))
|
await self.async_set_unique_id(format_unique_id(discovery_info.address))
|
||||||
|
@ -109,7 +114,7 @@ class SwitchbotConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def _async_create_entry_from_discovery(
|
async def _async_create_entry_from_discovery(
|
||||||
self, user_input: dict[str, Any]
|
self, user_input: dict[str, Any]
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Create an entry from a discovery."""
|
"""Create an entry from a discovery."""
|
||||||
assert self._discovered_adv is not None
|
assert self._discovered_adv is not None
|
||||||
discovery = self._discovered_adv
|
discovery = self._discovered_adv
|
||||||
|
@ -126,7 +131,7 @@ class SwitchbotConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_confirm(
|
async def async_step_confirm(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Confirm a single device."""
|
"""Confirm a single device."""
|
||||||
assert self._discovered_adv is not None
|
assert self._discovered_adv is not None
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
|
@ -143,7 +148,7 @@ class SwitchbotConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_password(
|
async def async_step_password(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the password step."""
|
"""Handle the password step."""
|
||||||
assert self._discovered_adv is not None
|
assert self._discovered_adv is not None
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
|
@ -162,7 +167,7 @@ class SwitchbotConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_lock_auth(
|
async def async_step_lock_auth(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the SwitchBot API auth step."""
|
"""Handle the SwitchBot API auth step."""
|
||||||
errors = {}
|
errors = {}
|
||||||
assert self._discovered_adv is not None
|
assert self._discovered_adv is not None
|
||||||
|
@ -204,7 +209,7 @@ class SwitchbotConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_lock_choose_method(
|
async def async_step_lock_choose_method(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the SwitchBot API chose method step."""
|
"""Handle the SwitchBot API chose method step."""
|
||||||
assert self._discovered_adv is not None
|
assert self._discovered_adv is not None
|
||||||
|
|
||||||
|
@ -218,7 +223,7 @@ class SwitchbotConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_lock_key(
|
async def async_step_lock_key(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the encryption key step."""
|
"""Handle the encryption key step."""
|
||||||
errors = {}
|
errors = {}
|
||||||
assert self._discovered_adv is not None
|
assert self._discovered_adv is not None
|
||||||
|
@ -285,7 +290,7 @@ class SwitchbotConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the user step to pick discovered device."""
|
"""Handle the user step to pick discovered device."""
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
device_adv: SwitchBotAdvertisement | None = None
|
device_adv: SwitchBotAdvertisement | None = None
|
||||||
|
@ -335,7 +340,7 @@ class SwitchbotOptionsFlowHandler(OptionsFlow):
|
||||||
|
|
||||||
async def async_step_init(
|
async def async_step_init(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Manage Switchbot options."""
|
"""Manage Switchbot options."""
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
# Update common entity options for all other entities.
|
# Update common entity options for all other entities.
|
||||||
|
|
|
@ -6,9 +6,8 @@ from typing import Any
|
||||||
from switchbot_api import CannotConnect, InvalidAuth, SwitchBotAPI
|
from switchbot_api import CannotConnect, InvalidAuth, SwitchBotAPI
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_API_KEY, CONF_API_TOKEN
|
from homeassistant.const import CONF_API_KEY, CONF_API_TOKEN
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
|
|
||||||
from .const import DOMAIN, ENTRY_TITLE
|
from .const import DOMAIN, ENTRY_TITLE
|
||||||
|
|
||||||
|
@ -22,14 +21,14 @@ STEP_USER_DATA_SCHEMA = vol.Schema(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class SwitchBotCloudConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class SwitchBotCloudConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow for SwitchBot via API."""
|
"""Handle a config flow for SwitchBot via API."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the initial step."""
|
"""Handle the initial step."""
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
|
|
|
@ -3,17 +3,18 @@ from __future__ import annotations
|
||||||
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
|
|
||||||
from .const import DATA_DISCOVERY, DOMAIN
|
from .const import DATA_DISCOVERY, DOMAIN
|
||||||
from .utils import async_discover_devices
|
from .utils import async_discover_devices
|
||||||
|
|
||||||
|
|
||||||
class SwitcherFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
class SwitcherFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle Switcher config flow."""
|
"""Handle Switcher config flow."""
|
||||||
|
|
||||||
async def async_step_import(self, import_config: dict[str, Any]) -> FlowResult:
|
async def async_step_import(
|
||||||
|
self, import_config: dict[str, Any]
|
||||||
|
) -> ConfigFlowResult:
|
||||||
"""Handle a flow initiated by import."""
|
"""Handle a flow initiated by import."""
|
||||||
if self._async_current_entries(True):
|
if self._async_current_entries(True):
|
||||||
return self.async_abort(reason="single_instance_allowed")
|
return self.async_abort(reason="single_instance_allowed")
|
||||||
|
@ -22,7 +23,7 @@ class SwitcherFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the start of the config flow."""
|
"""Handle the start of the config flow."""
|
||||||
if self._async_current_entries(True):
|
if self._async_current_entries(True):
|
||||||
return self.async_abort(reason="single_instance_allowed")
|
return self.async_abort(reason="single_instance_allowed")
|
||||||
|
@ -37,7 +38,7 @@ class SwitcherFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_confirm(
|
async def async_step_confirm(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle user-confirmation of the config flow."""
|
"""Handle user-confirmation of the config flow."""
|
||||||
discovered_devices = await self.hass.data[DOMAIN][DATA_DISCOVERY]
|
discovered_devices = await self.hass.data[DOMAIN][DATA_DISCOVERY]
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,10 @@
|
||||||
import aiosyncthing
|
import aiosyncthing
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries, core, exceptions
|
from homeassistant.config_entries import ConfigFlow
|
||||||
from homeassistant.const import CONF_TOKEN, CONF_URL, CONF_VERIFY_SSL
|
from homeassistant.const import CONF_TOKEN, CONF_URL, CONF_VERIFY_SSL
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
|
|
||||||
from .const import DEFAULT_URL, DEFAULT_VERIFY_SSL, DOMAIN
|
from .const import DEFAULT_URL, DEFAULT_VERIFY_SSL, DOMAIN
|
||||||
|
|
||||||
|
@ -16,7 +18,7 @@ DATA_SCHEMA = vol.Schema(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def validate_input(hass: core.HomeAssistant, data):
|
async def validate_input(hass: HomeAssistant, data):
|
||||||
"""Validate the user input allows us to connect."""
|
"""Validate the user input allows us to connect."""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -34,7 +36,7 @@ async def validate_input(hass: core.HomeAssistant, data):
|
||||||
raise CannotConnect from error
|
raise CannotConnect from error
|
||||||
|
|
||||||
|
|
||||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class SyncThingConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow for syncthing."""
|
"""Handle a config flow for syncthing."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
@ -60,9 +62,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class CannotConnect(exceptions.HomeAssistantError):
|
class CannotConnect(HomeAssistantError):
|
||||||
"""Error to indicate we cannot connect."""
|
"""Error to indicate we cannot connect."""
|
||||||
|
|
||||||
|
|
||||||
class InvalidAuth(exceptions.HomeAssistantError):
|
class InvalidAuth(HomeAssistantError):
|
||||||
"""Error to indicate there is invalid auth."""
|
"""Error to indicate there is invalid auth."""
|
||||||
|
|
|
@ -7,16 +7,15 @@ from pysyncthru import ConnectionMode, SyncThru, SyncThruAPINotSupported
|
||||||
from url_normalize import url_normalize
|
from url_normalize import url_normalize
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
|
||||||
from homeassistant.components import ssdp
|
from homeassistant.components import ssdp
|
||||||
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_NAME, CONF_URL
|
from homeassistant.const import CONF_NAME, CONF_URL
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.helpers import aiohttp_client
|
from homeassistant.helpers import aiohttp_client
|
||||||
|
|
||||||
from .const import DEFAULT_MODEL, DEFAULT_NAME_TEMPLATE, DOMAIN
|
from .const import DEFAULT_MODEL, DEFAULT_NAME_TEMPLATE, DOMAIN
|
||||||
|
|
||||||
|
|
||||||
class SyncThruConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class SyncThruConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Samsung SyncThru config flow."""
|
"""Samsung SyncThru config flow."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
@ -30,7 +29,9 @@ class SyncThruConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
return await self._async_show_form(step_id="user")
|
return await self._async_show_form(step_id="user")
|
||||||
return await self._async_check_and_create("user", user_input)
|
return await self._async_check_and_create("user", 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 flow."""
|
"""Handle SSDP initiated flow."""
|
||||||
await self.async_set_unique_id(discovery_info.upnp[ssdp.ATTR_UPNP_UDN])
|
await self.async_set_unique_id(discovery_info.upnp[ssdp.ATTR_UPNP_UDN])
|
||||||
self._abort_if_unique_id_configured()
|
self._abort_if_unique_id_configured()
|
||||||
|
|
|
@ -17,9 +17,13 @@ from synology_dsm.exceptions import (
|
||||||
)
|
)
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import exceptions
|
|
||||||
from homeassistant.components import ssdp, zeroconf
|
from homeassistant.components import ssdp, zeroconf
|
||||||
from homeassistant.config_entries import ConfigEntry, ConfigFlow, OptionsFlow
|
from homeassistant.config_entries import (
|
||||||
|
ConfigEntry,
|
||||||
|
ConfigFlow,
|
||||||
|
ConfigFlowResult,
|
||||||
|
OptionsFlow,
|
||||||
|
)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_DISKS,
|
CONF_DISKS,
|
||||||
CONF_HOST,
|
CONF_HOST,
|
||||||
|
@ -34,7 +38,7 @@ from homeassistant.const import (
|
||||||
CONF_VERIFY_SSL,
|
CONF_VERIFY_SSL,
|
||||||
)
|
)
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.typing import DiscoveryInfoType
|
from homeassistant.helpers.typing import DiscoveryInfoType
|
||||||
|
@ -130,7 +134,7 @@ class SynologyDSMFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
step_id: str,
|
step_id: str,
|
||||||
user_input: dict[str, Any] | None = None,
|
user_input: dict[str, Any] | None = None,
|
||||||
errors: dict[str, str] | None = None,
|
errors: dict[str, str] | None = None,
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Show the setup form to the user."""
|
"""Show the setup form to the user."""
|
||||||
if not user_input:
|
if not user_input:
|
||||||
user_input = {}
|
user_input = {}
|
||||||
|
@ -156,7 +160,7 @@ class SynologyDSMFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_validate_input_create_entry(
|
async def async_validate_input_create_entry(
|
||||||
self, user_input: dict[str, Any], step_id: str
|
self, user_input: dict[str, Any], step_id: str
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Process user input and create new or update existing config entry."""
|
"""Process user input and create new or update existing config entry."""
|
||||||
host = user_input[CONF_HOST]
|
host = user_input[CONF_HOST]
|
||||||
port = user_input.get(CONF_PORT)
|
port = user_input.get(CONF_PORT)
|
||||||
|
@ -231,7 +235,7 @@ class SynologyDSMFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a flow initiated by the user."""
|
"""Handle a flow initiated by the user."""
|
||||||
step = "user"
|
step = "user"
|
||||||
if not user_input:
|
if not user_input:
|
||||||
|
@ -240,7 +244,7 @@ class SynologyDSMFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_zeroconf(
|
async def async_step_zeroconf(
|
||||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a discovered synology_dsm via zeroconf."""
|
"""Handle a discovered synology_dsm via zeroconf."""
|
||||||
discovered_macs = [
|
discovered_macs = [
|
||||||
format_synology_mac(mac)
|
format_synology_mac(mac)
|
||||||
|
@ -253,7 +257,9 @@ class SynologyDSMFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
friendly_name = discovery_info.name.removesuffix(HTTP_SUFFIX)
|
friendly_name = discovery_info.name.removesuffix(HTTP_SUFFIX)
|
||||||
return await self._async_from_discovery(host, friendly_name, discovered_macs)
|
return await self._async_from_discovery(host, friendly_name, discovered_macs)
|
||||||
|
|
||||||
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 synology_dsm via ssdp."""
|
"""Handle a discovered synology_dsm via ssdp."""
|
||||||
parsed_url = urlparse(discovery_info.ssdp_location)
|
parsed_url = urlparse(discovery_info.ssdp_location)
|
||||||
upnp_friendly_name: str = discovery_info.upnp[ssdp.ATTR_UPNP_FRIENDLY_NAME]
|
upnp_friendly_name: str = discovery_info.upnp[ssdp.ATTR_UPNP_FRIENDLY_NAME]
|
||||||
|
@ -267,7 +273,7 @@ class SynologyDSMFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def _async_from_discovery(
|
async def _async_from_discovery(
|
||||||
self, host: str, friendly_name: str, discovered_macs: list[str]
|
self, host: str, friendly_name: str, discovered_macs: list[str]
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a discovered synology_dsm via zeroconf or ssdp."""
|
"""Handle a discovered synology_dsm via zeroconf or ssdp."""
|
||||||
existing_entry = None
|
existing_entry = None
|
||||||
for discovered_mac in discovered_macs:
|
for discovered_mac in discovered_macs:
|
||||||
|
@ -307,7 +313,7 @@ class SynologyDSMFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_link(
|
async def async_step_link(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Link a config entry from discovery."""
|
"""Link a config entry from discovery."""
|
||||||
step = "link"
|
step = "link"
|
||||||
if not user_input:
|
if not user_input:
|
||||||
|
@ -315,7 +321,9 @@ class SynologyDSMFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
user_input = {**self.discovered_conf, **user_input}
|
user_input = {**self.discovered_conf, **user_input}
|
||||||
return await self.async_validate_input_create_entry(user_input, step_id=step)
|
return await self.async_validate_input_create_entry(user_input, step_id=step)
|
||||||
|
|
||||||
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
|
async def async_step_reauth(
|
||||||
|
self, entry_data: Mapping[str, Any]
|
||||||
|
) -> ConfigFlowResult:
|
||||||
"""Perform reauth upon an API authentication error."""
|
"""Perform reauth upon an API authentication error."""
|
||||||
self.reauth_conf = entry_data
|
self.reauth_conf = entry_data
|
||||||
self.context["title_placeholders"][CONF_HOST] = entry_data[CONF_HOST]
|
self.context["title_placeholders"][CONF_HOST] = entry_data[CONF_HOST]
|
||||||
|
@ -324,7 +332,7 @@ class SynologyDSMFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_reauth_confirm(
|
async def async_step_reauth_confirm(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Perform reauth confirm upon an API authentication error."""
|
"""Perform reauth confirm upon an API authentication error."""
|
||||||
step = "reauth_confirm"
|
step = "reauth_confirm"
|
||||||
if not user_input:
|
if not user_input:
|
||||||
|
@ -334,7 +342,7 @@ class SynologyDSMFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_2sa(
|
async def async_step_2sa(
|
||||||
self, user_input: dict[str, Any], errors: dict[str, str] | None = None
|
self, user_input: dict[str, Any], errors: dict[str, str] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Enter 2SA code to anthenticate."""
|
"""Enter 2SA code to anthenticate."""
|
||||||
if not self.saved_user_input:
|
if not self.saved_user_input:
|
||||||
self.saved_user_input = user_input
|
self.saved_user_input = user_input
|
||||||
|
@ -370,7 +378,7 @@ class SynologyDSMOptionsFlowHandler(OptionsFlow):
|
||||||
|
|
||||||
async def async_step_init(
|
async def async_step_init(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle options flow."""
|
"""Handle options flow."""
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
return self.async_create_entry(title="", data=user_input)
|
return self.async_create_entry(title="", data=user_input)
|
||||||
|
@ -419,5 +427,5 @@ async def _login_and_fetch_syno_info(api: SynologyDSM, otp_code: str | None) ->
|
||||||
return api.information.serial # type: ignore[no-any-return]
|
return api.information.serial # type: ignore[no-any-return]
|
||||||
|
|
||||||
|
|
||||||
class InvalidData(exceptions.HomeAssistantError):
|
class InvalidData(HomeAssistantError):
|
||||||
"""Error to indicate we get invalid data from the nas."""
|
"""Error to indicate we get invalid data from the nas."""
|
||||||
|
|
|
@ -16,11 +16,11 @@ from systembridgemodels.get_data import GetData
|
||||||
from systembridgemodels.system import System
|
from systembridgemodels.system import System
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries, exceptions
|
|
||||||
from homeassistant.components import zeroconf
|
from homeassistant.components import zeroconf
|
||||||
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_API_KEY, CONF_HOST, CONF_PORT
|
from homeassistant.const import CONF_API_KEY, CONF_HOST, CONF_PORT
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
|
|
||||||
|
@ -107,8 +107,8 @@ async def _async_get_info(
|
||||||
return errors, None
|
return errors, None
|
||||||
|
|
||||||
|
|
||||||
class ConfigFlow(
|
class SystemBridgeConfigFlow(
|
||||||
config_entries.ConfigFlow,
|
ConfigFlow,
|
||||||
domain=DOMAIN,
|
domain=DOMAIN,
|
||||||
):
|
):
|
||||||
"""Handle a config flow for System Bridge."""
|
"""Handle a config flow for System Bridge."""
|
||||||
|
@ -123,7 +123,7 @@ class ConfigFlow(
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the initial step."""
|
"""Handle the initial step."""
|
||||||
if user_input is None:
|
if user_input is None:
|
||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
|
@ -144,7 +144,7 @@ class ConfigFlow(
|
||||||
|
|
||||||
async def async_step_authenticate(
|
async def async_step_authenticate(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle getting the api-key for authentication."""
|
"""Handle getting the api-key for authentication."""
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ class ConfigFlow(
|
||||||
|
|
||||||
async def async_step_zeroconf(
|
async def async_step_zeroconf(
|
||||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle zeroconf discovery."""
|
"""Handle zeroconf discovery."""
|
||||||
properties = discovery_info.properties
|
properties = discovery_info.properties
|
||||||
host = properties.get("ip")
|
host = properties.get("ip")
|
||||||
|
@ -198,7 +198,9 @@ class ConfigFlow(
|
||||||
|
|
||||||
return await self.async_step_authenticate()
|
return await self.async_step_authenticate()
|
||||||
|
|
||||||
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
|
async def async_step_reauth(
|
||||||
|
self, entry_data: Mapping[str, Any]
|
||||||
|
) -> ConfigFlowResult:
|
||||||
"""Perform reauth upon an API authentication error."""
|
"""Perform reauth upon an API authentication error."""
|
||||||
self._name = entry_data[CONF_HOST]
|
self._name = entry_data[CONF_HOST]
|
||||||
self._input = {
|
self._input = {
|
||||||
|
@ -209,9 +211,9 @@ class ConfigFlow(
|
||||||
return await self.async_step_authenticate()
|
return await self.async_step_authenticate()
|
||||||
|
|
||||||
|
|
||||||
class CannotConnect(exceptions.HomeAssistantError):
|
class CannotConnect(HomeAssistantError):
|
||||||
"""Error to indicate we cannot connect."""
|
"""Error to indicate we cannot connect."""
|
||||||
|
|
||||||
|
|
||||||
class InvalidAuth(exceptions.HomeAssistantError):
|
class InvalidAuth(HomeAssistantError):
|
||||||
"""Error to indicate there is invalid auth."""
|
"""Error to indicate there is invalid auth."""
|
||||||
|
|
|
@ -8,8 +8,8 @@ import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR_DOMAIN
|
from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR_DOMAIN
|
||||||
from homeassistant.components.homeassistant import DOMAIN as HOMEASSISTANT_DOMAIN
|
from homeassistant.components.homeassistant import DOMAIN as HOMEASSISTANT_DOMAIN
|
||||||
|
from homeassistant.config_entries import ConfigFlowResult
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.helpers import entity_registry as er
|
from homeassistant.helpers import entity_registry as er
|
||||||
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
|
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
|
||||||
from homeassistant.helpers.schema_config_entry_flow import (
|
from homeassistant.helpers.schema_config_entry_flow import (
|
||||||
|
@ -138,7 +138,9 @@ class SystemMonitorConfigFlowHandler(SchemaConfigFlowHandler, domain=DOMAIN):
|
||||||
return "System Monitor"
|
return "System Monitor"
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_create_entry(self, data: Mapping[str, Any], **kwargs: Any) -> FlowResult:
|
def async_create_entry(
|
||||||
|
self, data: Mapping[str, Any], **kwargs: Any
|
||||||
|
) -> ConfigFlowResult:
|
||||||
"""Finish config flow and create a config entry."""
|
"""Finish config flow and create a config entry."""
|
||||||
if self._async_current_entries():
|
if self._async_current_entries():
|
||||||
return self.async_abort(reason="already_configured")
|
return self.async_abort(reason="already_configured")
|
||||||
|
|
|
@ -9,11 +9,16 @@ from PyTado.interface import Tado
|
||||||
import requests.exceptions
|
import requests.exceptions
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries, core, exceptions
|
|
||||||
from homeassistant.components import zeroconf
|
from homeassistant.components import zeroconf
|
||||||
|
from homeassistant.config_entries import (
|
||||||
|
ConfigEntry,
|
||||||
|
ConfigFlow,
|
||||||
|
ConfigFlowResult,
|
||||||
|
OptionsFlow,
|
||||||
|
)
|
||||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
CONF_FALLBACK,
|
CONF_FALLBACK,
|
||||||
|
@ -34,9 +39,7 @@ DATA_SCHEMA = vol.Schema(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def validate_input(
|
async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> dict[str, Any]:
|
||||||
hass: core.HomeAssistant, data: dict[str, Any]
|
|
||||||
) -> dict[str, Any]:
|
|
||||||
"""Validate the user input allows us to connect.
|
"""Validate the user input allows us to connect.
|
||||||
|
|
||||||
Data has the keys from DATA_SCHEMA with values provided by the user.
|
Data has the keys from DATA_SCHEMA with values provided by the user.
|
||||||
|
@ -66,14 +69,14 @@ async def validate_input(
|
||||||
return {"title": name, UNIQUE_ID: unique_id}
|
return {"title": name, UNIQUE_ID: unique_id}
|
||||||
|
|
||||||
|
|
||||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class TadoConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow for Tado."""
|
"""Handle a config flow for Tado."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the initial step."""
|
"""Handle the initial step."""
|
||||||
errors = {}
|
errors = {}
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
|
@ -102,7 +105,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_homekit(
|
async def async_step_homekit(
|
||||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle HomeKit discovery."""
|
"""Handle HomeKit discovery."""
|
||||||
self._async_abort_entries_match()
|
self._async_abort_entries_match()
|
||||||
properties = {
|
properties = {
|
||||||
|
@ -112,7 +115,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
self._abort_if_unique_id_configured()
|
self._abort_if_unique_id_configured()
|
||||||
return await self.async_step_user()
|
return await self.async_step_user()
|
||||||
|
|
||||||
async def async_step_import(self, import_config: dict[str, Any]) -> FlowResult:
|
async def async_step_import(
|
||||||
|
self, import_config: dict[str, Any]
|
||||||
|
) -> ConfigFlowResult:
|
||||||
"""Import a config entry from configuration.yaml."""
|
"""Import a config entry from configuration.yaml."""
|
||||||
_LOGGER.debug("Importing Tado from configuration.yaml")
|
_LOGGER.debug("Importing Tado from configuration.yaml")
|
||||||
username = import_config[CONF_USERNAME]
|
username = import_config[CONF_USERNAME]
|
||||||
|
@ -135,7 +140,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
CONF_PASSWORD: password,
|
CONF_PASSWORD: password,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
except exceptions.HomeAssistantError:
|
except HomeAssistantError:
|
||||||
return self.async_abort(reason="import_failed")
|
return self.async_abort(reason="import_failed")
|
||||||
except PyTado.exceptions.TadoWrongCredentialsException:
|
except PyTado.exceptions.TadoWrongCredentialsException:
|
||||||
return self.async_abort(reason="import_failed_invalid_auth")
|
return self.async_abort(reason="import_failed_invalid_auth")
|
||||||
|
@ -156,22 +161,22 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@callback
|
@callback
|
||||||
def async_get_options_flow(
|
def async_get_options_flow(
|
||||||
config_entry: config_entries.ConfigEntry,
|
config_entry: ConfigEntry,
|
||||||
) -> OptionsFlowHandler:
|
) -> OptionsFlowHandler:
|
||||||
"""Get the options flow for this handler."""
|
"""Get the options flow for this handler."""
|
||||||
return OptionsFlowHandler(config_entry)
|
return OptionsFlowHandler(config_entry)
|
||||||
|
|
||||||
|
|
||||||
class OptionsFlowHandler(config_entries.OptionsFlow):
|
class OptionsFlowHandler(OptionsFlow):
|
||||||
"""Handle an option flow for Tado."""
|
"""Handle an option flow for Tado."""
|
||||||
|
|
||||||
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
|
def __init__(self, config_entry: ConfigEntry) -> None:
|
||||||
"""Initialize options flow."""
|
"""Initialize options flow."""
|
||||||
self.config_entry = config_entry
|
self.config_entry = config_entry
|
||||||
|
|
||||||
async def async_step_init(
|
async def async_step_init(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle options flow."""
|
"""Handle options flow."""
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
return self.async_create_entry(data=user_input)
|
return self.async_create_entry(data=user_input)
|
||||||
|
@ -189,13 +194,13 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
|
||||||
return self.async_show_form(step_id="init", data_schema=data_schema)
|
return self.async_show_form(step_id="init", data_schema=data_schema)
|
||||||
|
|
||||||
|
|
||||||
class CannotConnect(exceptions.HomeAssistantError):
|
class CannotConnect(HomeAssistantError):
|
||||||
"""Error to indicate we cannot connect."""
|
"""Error to indicate we cannot connect."""
|
||||||
|
|
||||||
|
|
||||||
class InvalidAuth(exceptions.HomeAssistantError):
|
class InvalidAuth(HomeAssistantError):
|
||||||
"""Error to indicate there is invalid auth."""
|
"""Error to indicate there is invalid auth."""
|
||||||
|
|
||||||
|
|
||||||
class NoHomes(exceptions.HomeAssistantError):
|
class NoHomes(HomeAssistantError):
|
||||||
"""Error to indicate the account has no homes."""
|
"""Error to indicate the account has no homes."""
|
||||||
|
|
|
@ -7,10 +7,9 @@ from typing import Any
|
||||||
from tailscale import Tailscale, TailscaleAuthenticationError, TailscaleError
|
from tailscale import Tailscale, TailscaleAuthenticationError, TailscaleError
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry, ConfigFlow
|
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_API_KEY
|
from homeassistant.const import CONF_API_KEY
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
|
|
||||||
from .const import CONF_TAILNET, DOMAIN
|
from .const import CONF_TAILNET, DOMAIN
|
||||||
|
@ -36,7 +35,7 @@ class TailscaleFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a flow initialized by the user."""
|
"""Handle a flow initialized by the user."""
|
||||||
errors = {}
|
errors = {}
|
||||||
|
|
||||||
|
@ -82,7 +81,9 @@ class TailscaleFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
errors=errors,
|
errors=errors,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
|
async def async_step_reauth(
|
||||||
|
self, entry_data: Mapping[str, Any]
|
||||||
|
) -> ConfigFlowResult:
|
||||||
"""Handle initiation of re-authentication with Tailscale."""
|
"""Handle initiation of re-authentication with Tailscale."""
|
||||||
self.reauth_entry = self.hass.config_entries.async_get_entry(
|
self.reauth_entry = self.hass.config_entries.async_get_entry(
|
||||||
self.context["entry_id"]
|
self.context["entry_id"]
|
||||||
|
@ -91,7 +92,7 @@ class TailscaleFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_reauth_confirm(
|
async def async_step_reauth_confirm(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle re-authentication with Tailscale."""
|
"""Handle re-authentication with Tailscale."""
|
||||||
errors = {}
|
errors = {}
|
||||||
|
|
||||||
|
|
|
@ -16,9 +16,9 @@ import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components import zeroconf
|
from homeassistant.components import zeroconf
|
||||||
from homeassistant.components.dhcp import DhcpServiceInfo
|
from homeassistant.components.dhcp import DhcpServiceInfo
|
||||||
from homeassistant.config_entries import ConfigEntry, ConfigFlow
|
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_HOST, CONF_TOKEN
|
from homeassistant.const import CONF_HOST, CONF_TOKEN
|
||||||
from homeassistant.data_entry_flow import AbortFlow, FlowResult
|
from homeassistant.data_entry_flow import AbortFlow
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
from homeassistant.helpers.device_registry import format_mac
|
from homeassistant.helpers.device_registry import format_mac
|
||||||
from homeassistant.helpers.selector import (
|
from homeassistant.helpers.selector import (
|
||||||
|
@ -44,7 +44,7 @@ class TailwindFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a flow initiated by the user."""
|
"""Handle a flow initiated by the user."""
|
||||||
errors = {}
|
errors = {}
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ class TailwindFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_zeroconf(
|
async def async_step_zeroconf(
|
||||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle zeroconf discovery of a Tailwind device."""
|
"""Handle zeroconf discovery of a Tailwind device."""
|
||||||
if not (device_id := discovery_info.properties.get("device_id")):
|
if not (device_id := discovery_info.properties.get("device_id")):
|
||||||
return self.async_abort(reason="no_device_id")
|
return self.async_abort(reason="no_device_id")
|
||||||
|
@ -112,7 +112,7 @@ class TailwindFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_zeroconf_confirm(
|
async def async_step_zeroconf_confirm(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a flow initiated by zeroconf."""
|
"""Handle a flow initiated by zeroconf."""
|
||||||
errors = {}
|
errors = {}
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ class TailwindFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
errors=errors,
|
errors=errors,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_reauth(self, _: Mapping[str, Any]) -> FlowResult:
|
async def async_step_reauth(self, _: Mapping[str, Any]) -> ConfigFlowResult:
|
||||||
"""Handle initiation of re-authentication with a Tailwind device."""
|
"""Handle initiation of re-authentication with a Tailwind device."""
|
||||||
self.reauth_entry = self.hass.config_entries.async_get_entry(
|
self.reauth_entry = self.hass.config_entries.async_get_entry(
|
||||||
self.context["entry_id"]
|
self.context["entry_id"]
|
||||||
|
@ -152,7 +152,7 @@ class TailwindFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_reauth_confirm(
|
async def async_step_reauth_confirm(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle re-authentication with a Tailwind device."""
|
"""Handle re-authentication with a Tailwind device."""
|
||||||
errors = {}
|
errors = {}
|
||||||
|
|
||||||
|
@ -183,7 +183,9 @@ class TailwindFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
errors=errors,
|
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 to update existing entries.
|
"""Handle dhcp discovery to update existing entries.
|
||||||
|
|
||||||
This flow is triggered only by DHCP discovery of known devices.
|
This flow is triggered only by DHCP discovery of known devices.
|
||||||
|
@ -196,7 +198,9 @@ class TailwindFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
# abort the flow with an unknown error.
|
# abort the flow with an unknown error.
|
||||||
return self.async_abort(reason="unknown")
|
return self.async_abort(reason="unknown")
|
||||||
|
|
||||||
async def _async_step_create_entry(self, *, host: str, token: str) -> FlowResult:
|
async def _async_step_create_entry(
|
||||||
|
self, *, host: str, token: str
|
||||||
|
) -> ConfigFlowResult:
|
||||||
"""Create entry."""
|
"""Create entry."""
|
||||||
tailwind = Tailwind(
|
tailwind = Tailwind(
|
||||||
host=host, token=token, session=async_get_clientsession(self.hass)
|
host=host, token=token, session=async_get_clientsession(self.hass)
|
||||||
|
|
|
@ -8,8 +8,7 @@ from typing import Any
|
||||||
from Tami4EdgeAPI import Tami4EdgeAPI, exceptions
|
from Tami4EdgeAPI import Tami4EdgeAPI, exceptions
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
|
@ -23,7 +22,7 @@ _STEP_OTP_CODE_SCHEMA = vol.Schema({vol.Required("otp"): cv.string})
|
||||||
_PHONE_MATCHER = re.compile(r"^(\+?972)?0?(?P<number>\d{8,9})$")
|
_PHONE_MATCHER = re.compile(r"^(\+?972)?0?(?P<number>\d{8,9})$")
|
||||||
|
|
||||||
|
|
||||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class Tami4ConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow for Tami4Edge."""
|
"""Handle a config flow for Tami4Edge."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
@ -32,7 +31,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the otp request step."""
|
"""Handle the otp request step."""
|
||||||
errors = {}
|
errors = {}
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
|
@ -62,7 +61,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_otp(
|
async def async_step_otp(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the otp submission step."""
|
"""Handle the otp submission step."""
|
||||||
errors = {}
|
errors = {}
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
|
|
|
@ -13,7 +13,12 @@ from aiotankerkoenig import (
|
||||||
)
|
)
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant.config_entries import (
|
||||||
|
ConfigEntry,
|
||||||
|
ConfigFlow,
|
||||||
|
ConfigFlowResult,
|
||||||
|
OptionsFlow,
|
||||||
|
)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_API_KEY,
|
CONF_API_KEY,
|
||||||
CONF_LATITUDE,
|
CONF_LATITUDE,
|
||||||
|
@ -25,7 +30,6 @@ from homeassistant.const import (
|
||||||
UnitOfLength,
|
UnitOfLength,
|
||||||
)
|
)
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.selector import (
|
from homeassistant.helpers.selector import (
|
||||||
|
@ -52,7 +56,7 @@ async def async_get_nearby_stations(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
class FlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow."""
|
"""Handle a config flow."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
@ -66,14 +70,14 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@callback
|
@callback
|
||||||
def async_get_options_flow(
|
def async_get_options_flow(
|
||||||
config_entry: config_entries.ConfigEntry,
|
config_entry: ConfigEntry,
|
||||||
) -> OptionsFlowHandler:
|
) -> OptionsFlowHandler:
|
||||||
"""Get the options flow for this handler."""
|
"""Get the options flow for this handler."""
|
||||||
return OptionsFlowHandler(config_entry)
|
return OptionsFlowHandler(config_entry)
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a flow initialized by the user."""
|
"""Handle a flow initialized by the user."""
|
||||||
if not user_input:
|
if not user_input:
|
||||||
return self._show_form_user()
|
return self._show_form_user()
|
||||||
|
@ -110,7 +114,7 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_select_station(
|
async def async_step_select_station(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the step select_station of a flow initialized by the user."""
|
"""Handle the step select_station of a flow initialized by the user."""
|
||||||
if not user_input:
|
if not user_input:
|
||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
|
@ -126,13 +130,15 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
options={CONF_SHOW_ON_MAP: True},
|
options={CONF_SHOW_ON_MAP: True},
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
|
async def async_step_reauth(
|
||||||
|
self, entry_data: Mapping[str, Any]
|
||||||
|
) -> ConfigFlowResult:
|
||||||
"""Perform reauth upon an API authentication error."""
|
"""Perform reauth upon an API authentication error."""
|
||||||
return await self.async_step_reauth_confirm()
|
return await self.async_step_reauth_confirm()
|
||||||
|
|
||||||
async def async_step_reauth_confirm(
|
async def async_step_reauth_confirm(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Perform reauth confirm upon an API authentication error."""
|
"""Perform reauth confirm upon an API authentication error."""
|
||||||
if not user_input:
|
if not user_input:
|
||||||
return self._show_form_reauth()
|
return self._show_form_reauth()
|
||||||
|
@ -158,7 +164,7 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
self,
|
self,
|
||||||
user_input: dict[str, Any] | None = None,
|
user_input: dict[str, Any] | None = None,
|
||||||
errors: dict[str, Any] | None = None,
|
errors: dict[str, Any] | None = None,
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
if user_input is None:
|
if user_input is None:
|
||||||
user_input = {}
|
user_input = {}
|
||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
|
@ -204,7 +210,7 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
self,
|
self,
|
||||||
user_input: dict[str, Any] | None = None,
|
user_input: dict[str, Any] | None = None,
|
||||||
errors: dict[str, Any] | None = None,
|
errors: dict[str, Any] | None = None,
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
if user_input is None:
|
if user_input is None:
|
||||||
user_input = {}
|
user_input = {}
|
||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
|
@ -221,7 +227,7 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
def _create_entry(
|
def _create_entry(
|
||||||
self, data: dict[str, Any], options: dict[str, Any]
|
self, data: dict[str, Any], options: dict[str, Any]
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
return self.async_create_entry(
|
return self.async_create_entry(
|
||||||
title=data[CONF_NAME],
|
title=data[CONF_NAME],
|
||||||
data=data,
|
data=data,
|
||||||
|
@ -229,17 +235,17 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class OptionsFlowHandler(config_entries.OptionsFlow):
|
class OptionsFlowHandler(OptionsFlow):
|
||||||
"""Handle an options flow."""
|
"""Handle an options flow."""
|
||||||
|
|
||||||
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
|
def __init__(self, config_entry: ConfigEntry) -> None:
|
||||||
"""Initialize options flow."""
|
"""Initialize options flow."""
|
||||||
self.config_entry = config_entry
|
self.config_entry = config_entry
|
||||||
self._stations: dict[str, str] = {}
|
self._stations: dict[str, str] = {}
|
||||||
|
|
||||||
async def async_step_init(
|
async def async_step_init(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle options flow."""
|
"""Handle options flow."""
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
self.hass.config_entries.async_update_entry(
|
self.hass.config_entries.async_update_entry(
|
||||||
|
|
|
@ -5,15 +5,14 @@ from typing import Any
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
|
||||||
from homeassistant.components.mqtt import valid_subscribe_topic
|
from homeassistant.components.mqtt import valid_subscribe_topic
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.helpers.service_info.mqtt import MqttServiceInfo
|
from homeassistant.helpers.service_info.mqtt import MqttServiceInfo
|
||||||
|
|
||||||
from .const import CONF_DISCOVERY_PREFIX, DEFAULT_PREFIX, DOMAIN
|
from .const import CONF_DISCOVERY_PREFIX, DEFAULT_PREFIX, DOMAIN
|
||||||
|
|
||||||
|
|
||||||
class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
class FlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow."""
|
"""Handle a config flow."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
@ -22,7 +21,9 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
"""Initialize flow."""
|
"""Initialize flow."""
|
||||||
self._prefix = DEFAULT_PREFIX
|
self._prefix = DEFAULT_PREFIX
|
||||||
|
|
||||||
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."""
|
"""Handle a flow initialized by MQTT discovery."""
|
||||||
if self._async_in_progress() or self._async_current_entries():
|
if self._async_in_progress() or self._async_current_entries():
|
||||||
return self.async_abort(reason="single_instance_allowed")
|
return self.async_abort(reason="single_instance_allowed")
|
||||||
|
@ -45,7 +46,7 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a flow initialized by the user."""
|
"""Handle a flow initialized by the user."""
|
||||||
if self._async_current_entries():
|
if self._async_current_entries():
|
||||||
return self.async_abort(reason="single_instance_allowed")
|
return self.async_abort(reason="single_instance_allowed")
|
||||||
|
@ -56,7 +57,7 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_config(
|
async def async_step_config(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Confirm the setup."""
|
"""Confirm the setup."""
|
||||||
errors = {}
|
errors = {}
|
||||||
data = {CONF_DISCOVERY_PREFIX: self._prefix}
|
data = {CONF_DISCOVERY_PREFIX: self._prefix}
|
||||||
|
@ -85,7 +86,7 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_confirm(
|
async def async_step_confirm(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Confirm the setup."""
|
"""Confirm the setup."""
|
||||||
|
|
||||||
data = {CONF_DISCOVERY_PREFIX: self._prefix}
|
data = {CONF_DISCOVERY_PREFIX: self._prefix}
|
||||||
|
|
|
@ -7,9 +7,8 @@ from typing import Any
|
||||||
from pytautulli import PyTautulli, PyTautulliException, exceptions
|
from pytautulli import PyTautulli, PyTautulliException, exceptions
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigFlow
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_API_KEY, CONF_URL, CONF_VERIFY_SSL
|
from homeassistant.const import CONF_API_KEY, CONF_URL, CONF_VERIFY_SSL
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
|
|
||||||
from .const import DEFAULT_NAME, DOMAIN
|
from .const import DEFAULT_NAME, DOMAIN
|
||||||
|
@ -22,7 +21,7 @@ class TautulliConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a flow initiated by the user."""
|
"""Handle a flow initiated by the user."""
|
||||||
errors = {}
|
errors = {}
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
|
@ -49,13 +48,15 @@ class TautulliConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
errors=errors or {},
|
errors=errors or {},
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
|
async def async_step_reauth(
|
||||||
|
self, entry_data: Mapping[str, Any]
|
||||||
|
) -> ConfigFlowResult:
|
||||||
"""Handle a reauthorization flow request."""
|
"""Handle a reauthorization flow request."""
|
||||||
return await self.async_step_reauth_confirm()
|
return await self.async_step_reauth_confirm()
|
||||||
|
|
||||||
async def async_step_reauth_confirm(
|
async def async_step_reauth_confirm(
|
||||||
self, user_input: dict[str, str] | None = None
|
self, user_input: dict[str, str] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Confirm reauth dialog."""
|
"""Confirm reauth dialog."""
|
||||||
errors = {}
|
errors = {}
|
||||||
if user_input is not None and (
|
if user_input is not None and (
|
||||||
|
|
|
@ -6,9 +6,8 @@ from technove import Station as TechnoVEStation, TechnoVE, TechnoVEConnectionErr
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components import onboarding, zeroconf
|
from homeassistant.components import onboarding, zeroconf
|
||||||
from homeassistant.config_entries import ConfigFlow
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_HOST, CONF_MAC
|
from homeassistant.const import CONF_HOST, CONF_MAC
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
@ -23,7 +22,7 @@ class TechnoVEConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a flow initiated by the user."""
|
"""Handle a flow initiated by the user."""
|
||||||
errors = {}
|
errors = {}
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
|
@ -51,7 +50,7 @@ class TechnoVEConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_zeroconf(
|
async def async_step_zeroconf(
|
||||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle zeroconf discovery."""
|
"""Handle zeroconf discovery."""
|
||||||
# Abort quick if the device with provided mac is already configured
|
# Abort quick if the device with provided mac is already configured
|
||||||
if mac := discovery_info.properties.get(CONF_MAC):
|
if mac := discovery_info.properties.get(CONF_MAC):
|
||||||
|
@ -78,7 +77,7 @@ class TechnoVEConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_zeroconf_confirm(
|
async def async_step_zeroconf_confirm(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a flow initiated by zeroconf."""
|
"""Handle a flow initiated by zeroconf."""
|
||||||
if user_input is not None or not onboarding.async_is_onboarded(self.hass):
|
if user_input is not None or not onboarding.async_is_onboarded(self.hass):
|
||||||
return self.async_create_entry(
|
return self.async_create_entry(
|
||||||
|
|
|
@ -12,9 +12,8 @@ from pytedee_async import (
|
||||||
)
|
)
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry, ConfigFlow
|
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_HOST
|
from homeassistant.const import CONF_HOST
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
|
|
||||||
from .const import CONF_LOCAL_ACCESS_TOKEN, DOMAIN, NAME
|
from .const import CONF_LOCAL_ACCESS_TOKEN, DOMAIN, NAME
|
||||||
|
@ -27,7 +26,7 @@ class TedeeConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the initial step."""
|
"""Handle the initial step."""
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
|
|
||||||
|
@ -79,7 +78,9 @@ class TedeeConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
errors=errors,
|
errors=errors,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
|
async def async_step_reauth(
|
||||||
|
self, entry_data: Mapping[str, Any]
|
||||||
|
) -> ConfigFlowResult:
|
||||||
"""Perform reauth upon an API authentication error."""
|
"""Perform reauth upon an API authentication error."""
|
||||||
self.reauth_entry = self.hass.config_entries.async_get_entry(
|
self.reauth_entry = self.hass.config_entries.async_get_entry(
|
||||||
self.context["entry_id"]
|
self.context["entry_id"]
|
||||||
|
@ -88,7 +89,7 @@ class TedeeConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_reauth_confirm(
|
async def async_step_reauth_confirm(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Dialog that informs the user that reauth is required."""
|
"""Dialog that informs the user that reauth is required."""
|
||||||
assert self.reauth_entry
|
assert self.reauth_entry
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ import os
|
||||||
from tellduslive import Session, supports_local_api
|
from tellduslive import Session, supports_local_api
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant.config_entries import ConfigFlow
|
||||||
from homeassistant.const import CONF_HOST
|
from homeassistant.const import CONF_HOST
|
||||||
from homeassistant.util.json import load_json_object
|
from homeassistant.util.json import load_json_object
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ KEY_TOKEN_SECRET = "token_secret"
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
class FlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow."""
|
"""Handle a config flow."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
|
|
@ -8,11 +8,10 @@ from tesla_wall_connector import WallConnector
|
||||||
from tesla_wall_connector.exceptions import WallConnectorError
|
from tesla_wall_connector.exceptions import WallConnectorError
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
|
||||||
from homeassistant.components import dhcp
|
from homeassistant.components import dhcp
|
||||||
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_HOST
|
from homeassistant.const import CONF_HOST
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
|
|
||||||
from .const import DOMAIN, WALLCONNECTOR_DEVICE_NAME, WALLCONNECTOR_SERIAL_NUMBER
|
from .const import DOMAIN, WALLCONNECTOR_DEVICE_NAME, WALLCONNECTOR_SERIAL_NUMBER
|
||||||
|
@ -37,7 +36,7 @@ async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> dict[str,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class TeslaWallConnectorConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow for Tesla Wall Connector."""
|
"""Handle a config flow for Tesla Wall Connector."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
@ -48,7 +47,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
self.ip_address: str | None = None
|
self.ip_address: str | None = None
|
||||||
self.serial_number = None
|
self.serial_number = None
|
||||||
|
|
||||||
async def async_step_dhcp(self, discovery_info: dhcp.DhcpServiceInfo) -> FlowResult:
|
async def async_step_dhcp(
|
||||||
|
self, discovery_info: dhcp.DhcpServiceInfo
|
||||||
|
) -> ConfigFlowResult:
|
||||||
"""Handle dhcp discovery."""
|
"""Handle dhcp discovery."""
|
||||||
self.ip_address = discovery_info.ip
|
self.ip_address = discovery_info.ip
|
||||||
_LOGGER.debug("Discovered Tesla Wall Connector at [%s]", self.ip_address)
|
_LOGGER.debug("Discovered Tesla Wall Connector at [%s]", self.ip_address)
|
||||||
|
@ -89,7 +90,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the initial step."""
|
"""Handle the initial step."""
|
||||||
data_schema = vol.Schema(
|
data_schema = vol.Schema(
|
||||||
{vol.Required(CONF_HOST, default=self.ip_address): str}
|
{vol.Required(CONF_HOST, default=self.ip_address): str}
|
||||||
|
|
|
@ -11,7 +11,6 @@ import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
from homeassistant.const import CONF_ACCESS_TOKEN
|
from homeassistant.const import CONF_ACCESS_TOKEN
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
|
|
||||||
from .const import DOMAIN, LOGGER
|
from .const import DOMAIN, LOGGER
|
||||||
|
@ -30,7 +29,7 @@ class TeslemetryConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: Mapping[str, Any] | None = None
|
self, user_input: Mapping[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> config_entries.ConfigFlowResult:
|
||||||
"""Get configuration from the user."""
|
"""Get configuration from the user."""
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
if user_input:
|
if user_input:
|
||||||
|
|
|
@ -9,10 +9,8 @@ from aiohttp import ClientConnectionError, ClientResponseError
|
||||||
from tessie_api import get_state_of_all_vehicles
|
from tessie_api import get_state_of_all_vehicles
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.const import CONF_ACCESS_TOKEN
|
from homeassistant.const import CONF_ACCESS_TOKEN
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
@ -23,7 +21,7 @@ DESCRIPTION_PLACEHOLDERS = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class TessieConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class TessieConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Config Tessie API connection."""
|
"""Config Tessie API connection."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
@ -34,7 +32,7 @@ class TessieConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: Mapping[str, Any] | None = None
|
self, user_input: Mapping[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Get configuration from the user."""
|
"""Get configuration from the user."""
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
if user_input:
|
if user_input:
|
||||||
|
@ -64,7 +62,9 @@ class TessieConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
errors=errors,
|
errors=errors,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_reauth(self, user_input: Mapping[str, Any]) -> FlowResult:
|
async def async_step_reauth(
|
||||||
|
self, user_input: Mapping[str, Any]
|
||||||
|
) -> ConfigFlowResult:
|
||||||
"""Handle re-auth."""
|
"""Handle re-auth."""
|
||||||
self._reauth_entry = self.hass.config_entries.async_get_entry(
|
self._reauth_entry = self.hass.config_entries.async_get_entry(
|
||||||
self.context["entry_id"]
|
self.context["entry_id"]
|
||||||
|
@ -73,7 +73,7 @@ class TessieConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_reauth_confirm(
|
async def async_step_reauth_confirm(
|
||||||
self, user_input: Mapping[str, Any] | None = None
|
self, user_input: Mapping[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Get update API Key from the user."""
|
"""Get update API Key from the user."""
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
assert self._reauth_entry
|
assert self._reauth_entry
|
||||||
|
|
|
@ -10,9 +10,8 @@ from homeassistant.components.bluetooth import (
|
||||||
BluetoothServiceInfoBleak,
|
BluetoothServiceInfoBleak,
|
||||||
async_discovered_service_info,
|
async_discovered_service_info,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigFlow
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_ADDRESS
|
from homeassistant.const import CONF_ADDRESS
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
|
@ -30,7 +29,7 @@ class ThermoBeaconConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_bluetooth(
|
async def async_step_bluetooth(
|
||||||
self, discovery_info: BluetoothServiceInfoBleak
|
self, discovery_info: BluetoothServiceInfoBleak
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the bluetooth discovery step."""
|
"""Handle the bluetooth discovery step."""
|
||||||
await self.async_set_unique_id(discovery_info.address)
|
await self.async_set_unique_id(discovery_info.address)
|
||||||
self._abort_if_unique_id_configured()
|
self._abort_if_unique_id_configured()
|
||||||
|
@ -43,7 +42,7 @@ class ThermoBeaconConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_bluetooth_confirm(
|
async def async_step_bluetooth_confirm(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Confirm discovery."""
|
"""Confirm discovery."""
|
||||||
assert self._discovered_device is not None
|
assert self._discovered_device is not None
|
||||||
device = self._discovered_device
|
device = self._discovered_device
|
||||||
|
@ -62,7 +61,7 @@ class ThermoBeaconConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the user step to pick discovered device."""
|
"""Handle the user step to pick discovered device."""
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
address = user_input[CONF_ADDRESS]
|
address = user_input[CONF_ADDRESS]
|
||||||
|
|
|
@ -10,9 +10,8 @@ from homeassistant.components.bluetooth import (
|
||||||
BluetoothServiceInfoBleak,
|
BluetoothServiceInfoBleak,
|
||||||
async_discovered_service_info,
|
async_discovered_service_info,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigFlow
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_ADDRESS
|
from homeassistant.const import CONF_ADDRESS
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
|
@ -30,7 +29,7 @@ class ThermoProConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_bluetooth(
|
async def async_step_bluetooth(
|
||||||
self, discovery_info: BluetoothServiceInfoBleak
|
self, discovery_info: BluetoothServiceInfoBleak
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the bluetooth discovery step."""
|
"""Handle the bluetooth discovery step."""
|
||||||
await self.async_set_unique_id(discovery_info.address)
|
await self.async_set_unique_id(discovery_info.address)
|
||||||
self._abort_if_unique_id_configured()
|
self._abort_if_unique_id_configured()
|
||||||
|
@ -43,7 +42,7 @@ class ThermoProConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_bluetooth_confirm(
|
async def async_step_bluetooth_confirm(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Confirm discovery."""
|
"""Confirm discovery."""
|
||||||
assert self._discovered_device is not None
|
assert self._discovered_device is not None
|
||||||
device = self._discovered_device
|
device = self._discovered_device
|
||||||
|
@ -62,7 +61,7 @@ class ThermoProConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the user step to pick discovered device."""
|
"""Handle the user step to pick discovered device."""
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
address = user_input[CONF_ADDRESS]
|
address = user_input[CONF_ADDRESS]
|
||||||
|
|
|
@ -4,8 +4,7 @@ from __future__ import annotations
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from homeassistant.components import onboarding, zeroconf
|
from homeassistant.components import onboarding, zeroconf
|
||||||
from homeassistant.config_entries import ConfigFlow
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
|
@ -17,28 +16,28 @@ class ThreadConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_import(
|
async def async_step_import(
|
||||||
self, import_data: dict[str, str] | None = None
|
self, import_data: dict[str, str] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Set up by import from async_setup."""
|
"""Set up by import from async_setup."""
|
||||||
await self._async_handle_discovery_without_unique_id()
|
await self._async_handle_discovery_without_unique_id()
|
||||||
return self.async_create_entry(title="Thread", data={})
|
return self.async_create_entry(title="Thread", data={})
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, str] | None = None
|
self, user_input: dict[str, str] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Set up by import from async_setup."""
|
"""Set up by import from async_setup."""
|
||||||
await self._async_handle_discovery_without_unique_id()
|
await self._async_handle_discovery_without_unique_id()
|
||||||
return self.async_create_entry(title="Thread", data={})
|
return self.async_create_entry(title="Thread", data={})
|
||||||
|
|
||||||
async def async_step_zeroconf(
|
async def async_step_zeroconf(
|
||||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Set up because the user has border routers."""
|
"""Set up because the user has border routers."""
|
||||||
await self._async_handle_discovery_without_unique_id()
|
await self._async_handle_discovery_without_unique_id()
|
||||||
return await self.async_step_confirm()
|
return await self.async_step_confirm()
|
||||||
|
|
||||||
async def async_step_confirm(
|
async def async_step_confirm(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Confirm the setup."""
|
"""Confirm the setup."""
|
||||||
if user_input is not None or not onboarding.async_is_onboarded(self.hass):
|
if user_input is not None or not onboarding.async_is_onboarded(self.hass):
|
||||||
return self.async_create_entry(title="Thread", data={})
|
return self.async_create_entry(title="Thread", data={})
|
||||||
|
|
|
@ -7,9 +7,8 @@ import aiohttp
|
||||||
import tibber
|
import tibber
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_ACCESS_TOKEN
|
from homeassistant.const import CONF_ACCESS_TOKEN
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
@ -21,14 +20,14 @@ ERR_TOKEN = "invalid_access_token"
|
||||||
TOKEN_URL = "https://developer.tibber.com/settings/access-token"
|
TOKEN_URL = "https://developer.tibber.com/settings/access-token"
|
||||||
|
|
||||||
|
|
||||||
class TibberConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class TibberConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow for Tibber integration."""
|
"""Handle a config flow for Tibber integration."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the initial step."""
|
"""Handle the initial step."""
|
||||||
|
|
||||||
self._async_abort_entries_match()
|
self._async_abort_entries_match()
|
||||||
|
|
|
@ -8,9 +8,8 @@ from pytile import async_login
|
||||||
from pytile.errors import InvalidAuthError, TileError
|
from pytile.errors import InvalidAuthError, TileError
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.helpers import aiohttp_client
|
from homeassistant.helpers import aiohttp_client
|
||||||
|
|
||||||
from .const import DOMAIN, LOGGER
|
from .const import DOMAIN, LOGGER
|
||||||
|
@ -29,7 +28,7 @@ STEP_USER_SCHEMA = vol.Schema(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class TileFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
class TileFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a Tile config flow."""
|
"""Handle a Tile config flow."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
@ -39,7 +38,7 @@ class TileFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
self._password: str | None = None
|
self._password: str | None = None
|
||||||
self._username: str | None = None
|
self._username: str | None = None
|
||||||
|
|
||||||
async def _async_verify(self, step_id: str, schema: vol.Schema) -> FlowResult:
|
async def _async_verify(self, step_id: str, schema: vol.Schema) -> ConfigFlowResult:
|
||||||
"""Attempt to authenticate the provided credentials."""
|
"""Attempt to authenticate the provided credentials."""
|
||||||
assert self._username
|
assert self._username
|
||||||
assert self._password
|
assert self._password
|
||||||
|
@ -71,18 +70,22 @@ class TileFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
return self.async_create_entry(title=self._username, data=data)
|
return self.async_create_entry(title=self._username, data=data)
|
||||||
|
|
||||||
async def async_step_import(self, import_config: dict[str, Any]) -> FlowResult:
|
async def async_step_import(
|
||||||
|
self, import_config: dict[str, Any]
|
||||||
|
) -> ConfigFlowResult:
|
||||||
"""Import a config entry from configuration.yaml."""
|
"""Import a config entry from configuration.yaml."""
|
||||||
return await self.async_step_user(import_config)
|
return await self.async_step_user(import_config)
|
||||||
|
|
||||||
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
|
async def async_step_reauth(
|
||||||
|
self, entry_data: Mapping[str, Any]
|
||||||
|
) -> ConfigFlowResult:
|
||||||
"""Handle configuration by re-auth."""
|
"""Handle configuration by re-auth."""
|
||||||
self._username = entry_data[CONF_USERNAME]
|
self._username = entry_data[CONF_USERNAME]
|
||||||
return await self.async_step_reauth_confirm()
|
return await self.async_step_reauth_confirm()
|
||||||
|
|
||||||
async def async_step_reauth_confirm(
|
async def async_step_reauth_confirm(
|
||||||
self, user_input: dict[str, str] | None = None
|
self, user_input: dict[str, str] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle re-auth completion."""
|
"""Handle re-auth completion."""
|
||||||
if not user_input:
|
if not user_input:
|
||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
|
@ -95,7 +98,7 @@ class TileFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the start of the config flow."""
|
"""Handle the start of the config flow."""
|
||||||
if not user_input:
|
if not user_input:
|
||||||
return self.async_show_form(step_id="user", data_schema=STEP_USER_SCHEMA)
|
return self.async_show_form(step_id="user", data_schema=STEP_USER_SCHEMA)
|
||||||
|
|
|
@ -10,9 +10,8 @@ from homeassistant.components.bluetooth import (
|
||||||
BluetoothServiceInfoBleak,
|
BluetoothServiceInfoBleak,
|
||||||
async_discovered_service_info,
|
async_discovered_service_info,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigFlow
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_ADDRESS
|
from homeassistant.const import CONF_ADDRESS
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
|
@ -30,7 +29,7 @@ class TiltConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_bluetooth(
|
async def async_step_bluetooth(
|
||||||
self, discovery_info: BluetoothServiceInfoBleak
|
self, discovery_info: BluetoothServiceInfoBleak
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the bluetooth discovery step."""
|
"""Handle the bluetooth discovery step."""
|
||||||
await self.async_set_unique_id(discovery_info.address)
|
await self.async_set_unique_id(discovery_info.address)
|
||||||
self._abort_if_unique_id_configured()
|
self._abort_if_unique_id_configured()
|
||||||
|
@ -43,7 +42,7 @@ class TiltConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_bluetooth_confirm(
|
async def async_step_bluetooth_confirm(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Confirm discovery."""
|
"""Confirm discovery."""
|
||||||
assert self._discovered_device is not None
|
assert self._discovered_device is not None
|
||||||
device = self._discovered_device
|
device = self._discovered_device
|
||||||
|
@ -62,7 +61,7 @@ class TiltConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the user step to pick discovered device."""
|
"""Handle the user step to pick discovered device."""
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
address = user_input[CONF_ADDRESS]
|
address = user_input[CONF_ADDRESS]
|
||||||
|
|
|
@ -8,9 +8,8 @@ from requests.exceptions import HTTPError
|
||||||
from todoist_api_python.api_async import TodoistAPIAsync
|
from todoist_api_python.api_async import TodoistAPIAsync
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_TOKEN
|
from homeassistant.const import CONF_TOKEN
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
|
@ -25,14 +24,14 @@ STEP_USER_DATA_SCHEMA = vol.Schema(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class TodoistConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow for todoist."""
|
"""Handle a config flow for todoist."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the initial step."""
|
"""Handle the initial step."""
|
||||||
if self._async_current_entries():
|
if self._async_current_entries():
|
||||||
return self.async_abort(reason="single_instance_allowed")
|
return self.async_abort(reason="single_instance_allowed")
|
||||||
|
|
|
@ -10,9 +10,8 @@ from tololib.errors import ResponseTimedOutError
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components import dhcp
|
from homeassistant.components import dhcp
|
||||||
from homeassistant.config_entries import ConfigFlow
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_HOST
|
from homeassistant.const import CONF_HOST
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.helpers.device_registry import format_mac
|
from homeassistant.helpers.device_registry import format_mac
|
||||||
|
|
||||||
from .const import DEFAULT_NAME, DEFAULT_RETRY_COUNT, DEFAULT_RETRY_TIMEOUT, DOMAIN
|
from .const import DEFAULT_NAME, DEFAULT_RETRY_COUNT, DEFAULT_RETRY_TIMEOUT, DOMAIN
|
||||||
|
@ -40,7 +39,7 @@ class ToloSaunaConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a flow initialized by the user."""
|
"""Handle a flow initialized by the user."""
|
||||||
errors = {}
|
errors = {}
|
||||||
|
|
||||||
|
@ -64,7 +63,9 @@ class ToloSaunaConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
errors=errors,
|
errors=errors,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_dhcp(self, discovery_info: dhcp.DhcpServiceInfo) -> FlowResult:
|
async def async_step_dhcp(
|
||||||
|
self, discovery_info: dhcp.DhcpServiceInfo
|
||||||
|
) -> ConfigFlowResult:
|
||||||
"""Handle a flow initialized by discovery."""
|
"""Handle a flow initialized by discovery."""
|
||||||
await self.async_set_unique_id(format_mac(discovery_info.macaddress))
|
await self.async_set_unique_id(format_mac(discovery_info.macaddress))
|
||||||
self._abort_if_unique_id_configured({CONF_HOST: discovery_info.ip})
|
self._abort_if_unique_id_configured({CONF_HOST: discovery_info.ip})
|
||||||
|
@ -81,7 +82,7 @@ class ToloSaunaConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_confirm(
|
async def async_step_confirm(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle user-confirmation of discovered node."""
|
"""Handle user-confirmation of discovered node."""
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
self._async_abort_entries_match({CONF_HOST: self._discovered_host})
|
self._async_abort_entries_match({CONF_HOST: self._discovered_host})
|
||||||
|
|
|
@ -13,8 +13,13 @@ from pytomorrowio.exceptions import (
|
||||||
from pytomorrowio.pytomorrowio import TomorrowioV4
|
from pytomorrowio.pytomorrowio import TomorrowioV4
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries, core
|
|
||||||
from homeassistant.components.zone import async_active_zone
|
from homeassistant.components.zone import async_active_zone
|
||||||
|
from homeassistant.config_entries import (
|
||||||
|
ConfigEntry,
|
||||||
|
ConfigFlow,
|
||||||
|
ConfigFlowResult,
|
||||||
|
OptionsFlow,
|
||||||
|
)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_API_KEY,
|
CONF_API_KEY,
|
||||||
CONF_FRIENDLY_NAME,
|
CONF_FRIENDLY_NAME,
|
||||||
|
@ -24,7 +29,6 @@ from homeassistant.const import (
|
||||||
CONF_NAME,
|
CONF_NAME,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
from homeassistant.helpers.selector import LocationSelector, LocationSelectorConfig
|
from homeassistant.helpers.selector import LocationSelector, LocationSelectorConfig
|
||||||
|
|
||||||
|
@ -40,7 +44,7 @@ _LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def _get_config_schema(
|
def _get_config_schema(
|
||||||
hass: core.HomeAssistant,
|
hass: HomeAssistant,
|
||||||
source: str | None,
|
source: str | None,
|
||||||
input_dict: dict[str, Any] | None = None,
|
input_dict: dict[str, Any] | None = None,
|
||||||
) -> vol.Schema:
|
) -> vol.Schema:
|
||||||
|
@ -83,16 +87,16 @@ def _get_unique_id(hass: HomeAssistant, input_dict: dict[str, Any]):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class TomorrowioOptionsConfigFlow(config_entries.OptionsFlow):
|
class TomorrowioOptionsConfigFlow(OptionsFlow):
|
||||||
"""Handle Tomorrow.io options."""
|
"""Handle Tomorrow.io options."""
|
||||||
|
|
||||||
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
|
def __init__(self, config_entry: ConfigEntry) -> None:
|
||||||
"""Initialize Tomorrow.io options flow."""
|
"""Initialize Tomorrow.io options flow."""
|
||||||
self._config_entry = config_entry
|
self._config_entry = config_entry
|
||||||
|
|
||||||
async def async_step_init(
|
async def async_step_init(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Manage the Tomorrow.io options."""
|
"""Manage the Tomorrow.io options."""
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
return self.async_create_entry(title="", data=user_input)
|
return self.async_create_entry(title="", data=user_input)
|
||||||
|
@ -109,7 +113,7 @@ class TomorrowioOptionsConfigFlow(config_entries.OptionsFlow):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class TomorrowioConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class TomorrowioConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow for Tomorrow.io Weather API."""
|
"""Handle a config flow for Tomorrow.io Weather API."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
@ -117,14 +121,14 @@ class TomorrowioConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@callback
|
@callback
|
||||||
def async_get_options_flow(
|
def async_get_options_flow(
|
||||||
config_entry: config_entries.ConfigEntry,
|
config_entry: ConfigEntry,
|
||||||
) -> TomorrowioOptionsConfigFlow:
|
) -> TomorrowioOptionsConfigFlow:
|
||||||
"""Get the options flow for this handler."""
|
"""Get the options flow for this handler."""
|
||||||
return TomorrowioOptionsConfigFlow(config_entry)
|
return TomorrowioOptionsConfigFlow(config_entry)
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the initial step."""
|
"""Handle the initial step."""
|
||||||
errors = {}
|
errors = {}
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
|
|
|
@ -7,7 +7,7 @@ from typing import Any
|
||||||
from toonapi import Agreement, Toon, ToonError
|
from toonapi import Agreement, Toon, ToonError
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
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.aiohttp_client import async_get_clientsession
|
||||||
from homeassistant.helpers.config_entry_oauth2_flow import AbstractOAuth2FlowHandler
|
from homeassistant.helpers.config_entry_oauth2_flow import AbstractOAuth2FlowHandler
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ class ToonFlowHandler(AbstractOAuth2FlowHandler, domain=DOMAIN):
|
||||||
"""Return logger."""
|
"""Return logger."""
|
||||||
return logging.getLogger(__name__)
|
return logging.getLogger(__name__)
|
||||||
|
|
||||||
async def async_oauth_create_entry(self, data: dict[str, Any]) -> FlowResult:
|
async def async_oauth_create_entry(self, data: dict[str, Any]) -> ConfigFlowResult:
|
||||||
"""Test connection and load up agreements."""
|
"""Test connection and load up agreements."""
|
||||||
self.data = data
|
self.data = data
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ class ToonFlowHandler(AbstractOAuth2FlowHandler, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_import(
|
async def async_step_import(
|
||||||
self, config: dict[str, Any] | None = None
|
self, config: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Start a configuration flow based on imported data.
|
"""Start a configuration flow based on imported data.
|
||||||
|
|
||||||
This step is merely here to trigger "discovery" when the `toon`
|
This step is merely here to trigger "discovery" when the `toon`
|
||||||
|
@ -65,7 +65,7 @@ class ToonFlowHandler(AbstractOAuth2FlowHandler, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_agreement(
|
async def async_step_agreement(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Select Toon agreement to add."""
|
"""Select Toon agreement to add."""
|
||||||
if len(self.agreements) == 1:
|
if len(self.agreements) == 1:
|
||||||
return await self._create_entry(self.agreements[0])
|
return await self._create_entry(self.agreements[0])
|
||||||
|
@ -86,7 +86,7 @@ class ToonFlowHandler(AbstractOAuth2FlowHandler, domain=DOMAIN):
|
||||||
agreement_index = agreements_list.index(user_input[CONF_AGREEMENT])
|
agreement_index = agreements_list.index(user_input[CONF_AGREEMENT])
|
||||||
return await self._create_entry(self.agreements[agreement_index])
|
return await self._create_entry(self.agreements[agreement_index])
|
||||||
|
|
||||||
async def _create_entry(self, agreement: Agreement) -> FlowResult:
|
async def _create_entry(self, agreement: Agreement) -> ConfigFlowResult:
|
||||||
if CONF_MIGRATE in self.context:
|
if CONF_MIGRATE in self.context:
|
||||||
await self.hass.config_entries.async_remove(self.context[CONF_MIGRATE])
|
await self.hass.config_entries.async_remove(self.context[CONF_MIGRATE])
|
||||||
|
|
||||||
|
|
|
@ -8,17 +8,21 @@ from total_connect_client.client import TotalConnectClient
|
||||||
from total_connect_client.exceptions import AuthenticationError
|
from total_connect_client.exceptions import AuthenticationError
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant.config_entries import (
|
||||||
|
ConfigEntry,
|
||||||
|
ConfigFlow,
|
||||||
|
ConfigFlowResult,
|
||||||
|
OptionsFlow,
|
||||||
|
)
|
||||||
from homeassistant.const import CONF_LOCATION, CONF_PASSWORD, CONF_USERNAME
|
from homeassistant.const import CONF_LOCATION, CONF_PASSWORD, CONF_USERNAME
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
|
|
||||||
from .const import AUTO_BYPASS, CONF_USERCODES, DOMAIN
|
from .const import AUTO_BYPASS, CONF_USERCODES, DOMAIN
|
||||||
|
|
||||||
PASSWORD_DATA_SCHEMA = vol.Schema({vol.Required(CONF_PASSWORD): str})
|
PASSWORD_DATA_SCHEMA = vol.Schema({vol.Required(CONF_PASSWORD): str})
|
||||||
|
|
||||||
|
|
||||||
class TotalConnectConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class TotalConnectConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Total Connect config flow."""
|
"""Total Connect config flow."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
@ -125,7 +129,9 @@ class TotalConnectConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
description_placeholders={"location_id": location_for_user},
|
description_placeholders={"location_id": location_for_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:
|
||||||
"""Perform reauth upon an authentication error or no usercode."""
|
"""Perform reauth upon an authentication error or no usercode."""
|
||||||
self.username = entry_data[CONF_USERNAME]
|
self.username = entry_data[CONF_USERNAME]
|
||||||
self.usercodes = entry_data[CONF_USERCODES]
|
self.usercodes = entry_data[CONF_USERCODES]
|
||||||
|
@ -173,16 +179,16 @@ class TotalConnectConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@callback
|
@callback
|
||||||
def async_get_options_flow(
|
def async_get_options_flow(
|
||||||
config_entry: config_entries.ConfigEntry,
|
config_entry: ConfigEntry,
|
||||||
) -> TotalConnectOptionsFlowHandler:
|
) -> TotalConnectOptionsFlowHandler:
|
||||||
"""Get options flow."""
|
"""Get options flow."""
|
||||||
return TotalConnectOptionsFlowHandler(config_entry)
|
return TotalConnectOptionsFlowHandler(config_entry)
|
||||||
|
|
||||||
|
|
||||||
class TotalConnectOptionsFlowHandler(config_entries.OptionsFlow):
|
class TotalConnectOptionsFlowHandler(OptionsFlow):
|
||||||
"""TotalConnect options flow handler."""
|
"""TotalConnect options flow handler."""
|
||||||
|
|
||||||
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
|
def __init__(self, config_entry: ConfigEntry) -> None:
|
||||||
"""Initialize options flow."""
|
"""Initialize options flow."""
|
||||||
self.config_entry = config_entry
|
self.config_entry = config_entry
|
||||||
|
|
||||||
|
|
|
@ -15,9 +15,14 @@ from kasa import (
|
||||||
)
|
)
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
|
||||||
from homeassistant.components import dhcp
|
from homeassistant.components import dhcp
|
||||||
from homeassistant.config_entries import SOURCE_REAUTH, ConfigEntry, ConfigEntryState
|
from homeassistant.config_entries import (
|
||||||
|
SOURCE_REAUTH,
|
||||||
|
ConfigEntry,
|
||||||
|
ConfigEntryState,
|
||||||
|
ConfigFlow,
|
||||||
|
ConfigFlowResult,
|
||||||
|
)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_ALIAS,
|
CONF_ALIAS,
|
||||||
CONF_DEVICE,
|
CONF_DEVICE,
|
||||||
|
@ -28,7 +33,6 @@ from homeassistant.const import (
|
||||||
CONF_USERNAME,
|
CONF_USERNAME,
|
||||||
)
|
)
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.helpers import device_registry as dr
|
from homeassistant.helpers import device_registry as dr
|
||||||
from homeassistant.helpers.typing import DiscoveryInfoType
|
from homeassistant.helpers.typing import DiscoveryInfoType
|
||||||
|
|
||||||
|
@ -46,7 +50,7 @@ STEP_AUTH_DATA_SCHEMA = vol.Schema(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class TPLinkConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow for tplink."""
|
"""Handle a config flow for tplink."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
@ -58,7 +62,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
self._discovered_devices: dict[str, SmartDevice] = {}
|
self._discovered_devices: dict[str, SmartDevice] = {}
|
||||||
self._discovered_device: SmartDevice | None = None
|
self._discovered_device: SmartDevice | 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 discovery via dhcp."""
|
"""Handle discovery via dhcp."""
|
||||||
return await self._async_handle_discovery(
|
return await self._async_handle_discovery(
|
||||||
discovery_info.ip, dr.format_mac(discovery_info.macaddress)
|
discovery_info.ip, dr.format_mac(discovery_info.macaddress)
|
||||||
|
@ -66,7 +72,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_integration_discovery(
|
async def async_step_integration_discovery(
|
||||||
self, discovery_info: DiscoveryInfoType
|
self, discovery_info: DiscoveryInfoType
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle integration discovery."""
|
"""Handle integration discovery."""
|
||||||
return await self._async_handle_discovery(
|
return await self._async_handle_discovery(
|
||||||
discovery_info[CONF_HOST],
|
discovery_info[CONF_HOST],
|
||||||
|
@ -77,7 +83,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
@callback
|
@callback
|
||||||
def _update_config_if_entry_in_setup_error(
|
def _update_config_if_entry_in_setup_error(
|
||||||
self, entry: ConfigEntry, host: str, config: dict
|
self, entry: ConfigEntry, host: str, config: dict
|
||||||
) -> FlowResult | None:
|
) -> ConfigFlowResult | None:
|
||||||
"""If discovery encounters a device that is in SETUP_ERROR or SETUP_RETRY update the device config."""
|
"""If discovery encounters a device that is in SETUP_ERROR or SETUP_RETRY update the device config."""
|
||||||
if entry.state not in (
|
if entry.state not in (
|
||||||
ConfigEntryState.SETUP_ERROR,
|
ConfigEntryState.SETUP_ERROR,
|
||||||
|
@ -96,7 +102,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def _async_handle_discovery(
|
async def _async_handle_discovery(
|
||||||
self, host: str, formatted_mac: str, config: dict | None = None
|
self, host: str, formatted_mac: str, config: dict | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle any discovery."""
|
"""Handle any discovery."""
|
||||||
current_entry = await self.async_set_unique_id(
|
current_entry = await self.async_set_unique_id(
|
||||||
formatted_mac, raise_on_progress=False
|
formatted_mac, raise_on_progress=False
|
||||||
|
@ -131,7 +137,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_discovery_auth_confirm(
|
async def async_step_discovery_auth_confirm(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Dialog that informs the user that auth is required."""
|
"""Dialog that informs the user that auth is required."""
|
||||||
assert self._discovered_device is not None
|
assert self._discovered_device is not None
|
||||||
errors = {}
|
errors = {}
|
||||||
|
@ -190,7 +196,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_discovery_confirm(
|
async def async_step_discovery_confirm(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Confirm discovery."""
|
"""Confirm discovery."""
|
||||||
assert self._discovered_device is not None
|
assert self._discovered_device is not None
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
|
@ -205,7 +211,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the initial step."""
|
"""Handle the initial step."""
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
placeholders: dict[str, str] = {}
|
placeholders: dict[str, str] = {}
|
||||||
|
@ -237,7 +243,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user_auth_confirm(
|
async def async_step_user_auth_confirm(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Dialog that informs the user that auth is required."""
|
"""Dialog that informs the user that auth is required."""
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
host = self.context[CONF_HOST]
|
host = self.context[CONF_HOST]
|
||||||
|
@ -272,7 +278,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_pick_device(
|
async def async_step_pick_device(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the step to pick discovered device."""
|
"""Handle the step to pick discovered device."""
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
mac = user_input[CONF_DEVICE]
|
mac = user_input[CONF_DEVICE]
|
||||||
|
@ -332,7 +338,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
_config_entries.flow.async_abort(flow["flow_id"])
|
_config_entries.flow.async_abort(flow["flow_id"])
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def _async_create_entry_from_device(self, device: SmartDevice) -> FlowResult:
|
def _async_create_entry_from_device(self, device: SmartDevice) -> ConfigFlowResult:
|
||||||
"""Create a config entry from a smart device."""
|
"""Create a config entry from a smart device."""
|
||||||
self._abort_if_unique_id_configured(updates={CONF_HOST: device.host})
|
self._abort_if_unique_id_configured(updates={CONF_HOST: device.host})
|
||||||
return self.async_create_entry(
|
return self.async_create_entry(
|
||||||
|
@ -401,7 +407,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
)
|
)
|
||||||
return self._discovered_device
|
return self._discovered_device
|
||||||
|
|
||||||
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
|
async def async_step_reauth(
|
||||||
|
self, entry_data: Mapping[str, Any]
|
||||||
|
) -> ConfigFlowResult:
|
||||||
"""Start the reauthentication flow if the device needs updated credentials."""
|
"""Start the reauthentication flow if the device needs updated credentials."""
|
||||||
self.reauth_entry = self.hass.config_entries.async_get_entry(
|
self.reauth_entry = self.hass.config_entries.async_get_entry(
|
||||||
self.context["entry_id"]
|
self.context["entry_id"]
|
||||||
|
@ -410,7 +418,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_reauth_confirm(
|
async def async_step_reauth_confirm(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Dialog that informs the user that reauth is required."""
|
"""Dialog that informs the user that reauth is required."""
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
placeholders: dict[str, str] = {}
|
placeholders: dict[str, str] = {}
|
||||||
|
|
|
@ -18,10 +18,9 @@ from tplink_omada_client.exceptions import (
|
||||||
)
|
)
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME, CONF_VERIFY_SSL
|
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME, CONF_VERIFY_SSL
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.helpers import selector
|
from homeassistant.helpers import selector
|
||||||
from homeassistant.helpers.aiohttp_client import (
|
from homeassistant.helpers.aiohttp_client import (
|
||||||
async_create_clientsession,
|
async_create_clientsession,
|
||||||
|
@ -92,7 +91,7 @@ async def _validate_input(hass: HomeAssistant, data: dict[str, Any]) -> HubInfo:
|
||||||
return HubInfo(controller_id, name, sites)
|
return HubInfo(controller_id, name, sites)
|
||||||
|
|
||||||
|
|
||||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class TpLinkOmadaConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow for TP-Link Omada."""
|
"""Handle a config flow for TP-Link Omada."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
@ -105,7 +104,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the initial step."""
|
"""Handle the initial step."""
|
||||||
|
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
|
@ -130,7 +129,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_site(
|
async def async_step_site(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle step to select site to manage."""
|
"""Handle step to select site to manage."""
|
||||||
|
|
||||||
if user_input is None:
|
if user_input is None:
|
||||||
|
@ -159,14 +158,16 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
return self.async_create_entry(title=display_name, data=self._omada_opts)
|
return self.async_create_entry(title=display_name, data=self._omada_opts)
|
||||||
|
|
||||||
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
|
async def async_step_reauth(
|
||||||
|
self, entry_data: Mapping[str, Any]
|
||||||
|
) -> ConfigFlowResult:
|
||||||
"""Perform reauth upon an API authentication error."""
|
"""Perform reauth upon an API authentication error."""
|
||||||
self._omada_opts = dict(entry_data)
|
self._omada_opts = dict(entry_data)
|
||||||
return await self.async_step_reauth_confirm()
|
return await self.async_step_reauth_confirm()
|
||||||
|
|
||||||
async def async_step_reauth_confirm(
|
async def async_step_reauth_confirm(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Dialog that informs the user that reauth is required."""
|
"""Dialog that informs the user that reauth is required."""
|
||||||
|
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
|
|
|
@ -17,7 +17,6 @@ from homeassistant.const import (
|
||||||
CONF_VERIFY_SSL,
|
CONF_VERIFY_SSL,
|
||||||
)
|
)
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
from homeassistant.helpers.schema_config_entry_flow import (
|
from homeassistant.helpers.schema_config_entry_flow import (
|
||||||
SchemaFlowFormStep,
|
SchemaFlowFormStep,
|
||||||
|
@ -130,7 +129,7 @@ class TraccarServerConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self,
|
self,
|
||||||
user_input: dict[str, Any] | None = None,
|
user_input: dict[str, Any] | None = None,
|
||||||
) -> FlowResult:
|
) -> config_entries.ConfigFlowResult:
|
||||||
"""Handle the initial step."""
|
"""Handle the initial step."""
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
|
@ -160,7 +159,9 @@ class TraccarServerConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
errors=errors,
|
errors=errors,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_import(self, import_info: Mapping[str, Any]) -> FlowResult:
|
async def async_step_import(
|
||||||
|
self, import_info: Mapping[str, Any]
|
||||||
|
) -> config_entries.ConfigFlowResult:
|
||||||
"""Import an entry."""
|
"""Import an entry."""
|
||||||
configured_port = str(import_info[CONF_PORT])
|
configured_port = str(import_info[CONF_PORT])
|
||||||
self._async_abort_entries_match(
|
self._async_abort_entries_match(
|
||||||
|
|
|
@ -8,10 +8,9 @@ from typing import Any
|
||||||
import aiotractive
|
import aiotractive
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD
|
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
@ -40,14 +39,14 @@ async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> dict[str,
|
||||||
return {"title": data[CONF_EMAIL], "user_id": user_id}
|
return {"title": data[CONF_EMAIL], "user_id": user_id}
|
||||||
|
|
||||||
|
|
||||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class TractiveConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow for tractive."""
|
"""Handle a config flow for tractive."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the initial step."""
|
"""Handle the initial step."""
|
||||||
if user_input is None:
|
if user_input is None:
|
||||||
return self.async_show_form(step_id="user", data_schema=USER_DATA_SCHEMA)
|
return self.async_show_form(step_id="user", data_schema=USER_DATA_SCHEMA)
|
||||||
|
@ -70,13 +69,15 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
step_id="user", data_schema=USER_DATA_SCHEMA, errors=errors
|
step_id="user", data_schema=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 configuration by re-auth."""
|
"""Handle configuration by re-auth."""
|
||||||
return await self.async_step_reauth_confirm()
|
return await self.async_step_reauth_confirm()
|
||||||
|
|
||||||
async def async_step_reauth_confirm(
|
async def async_step_reauth_confirm(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Dialog that informs the user that reauth is required."""
|
"""Dialog that informs the user that reauth is required."""
|
||||||
|
|
||||||
errors = {}
|
errors = {}
|
||||||
|
|
|
@ -9,11 +9,10 @@ from pytradfri import Gateway, RequestError
|
||||||
from pytradfri.api.aiocoap_api import APIFactory
|
from pytradfri.api.aiocoap_api import APIFactory
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
|
||||||
from homeassistant.components import zeroconf
|
from homeassistant.components import zeroconf
|
||||||
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_HOST
|
from homeassistant.const import CONF_HOST
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
|
|
||||||
from .const import CONF_GATEWAY_ID, CONF_IDENTITY, CONF_KEY, DOMAIN
|
from .const import CONF_GATEWAY_ID, CONF_IDENTITY, CONF_KEY, DOMAIN
|
||||||
|
|
||||||
|
@ -29,7 +28,7 @@ class AuthError(Exception):
|
||||||
self.code = code
|
self.code = code
|
||||||
|
|
||||||
|
|
||||||
class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
class FlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow."""
|
"""Handle a config flow."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
@ -40,13 +39,13 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a flow initialized by the user."""
|
"""Handle a flow initialized by the user."""
|
||||||
return await self.async_step_auth()
|
return await self.async_step_auth()
|
||||||
|
|
||||||
async def async_step_auth(
|
async def async_step_auth(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the authentication with a gateway."""
|
"""Handle the authentication with a gateway."""
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
|
|
||||||
|
@ -82,7 +81,7 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_homekit(
|
async def async_step_homekit(
|
||||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle homekit discovery."""
|
"""Handle homekit discovery."""
|
||||||
await self.async_set_unique_id(
|
await self.async_set_unique_id(
|
||||||
discovery_info.properties[zeroconf.ATTR_PROPERTIES_ID]
|
discovery_info.properties[zeroconf.ATTR_PROPERTIES_ID]
|
||||||
|
@ -107,7 +106,7 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
self._host = host
|
self._host = host
|
||||||
return await self.async_step_auth()
|
return await self.async_step_auth()
|
||||||
|
|
||||||
async def _entry_from_data(self, data: dict[str, Any]) -> FlowResult:
|
async def _entry_from_data(self, data: dict[str, Any]) -> ConfigFlowResult:
|
||||||
"""Create an entry from data."""
|
"""Create an entry from data."""
|
||||||
host = data[CONF_HOST]
|
host = data[CONF_HOST]
|
||||||
gateway_id = data[CONF_GATEWAY_ID]
|
gateway_id = data[CONF_GATEWAY_ID]
|
||||||
|
|
|
@ -8,9 +8,8 @@ from pytrafikverket.exceptions import InvalidAuthentication, NoCameraFound, Unkn
|
||||||
from pytrafikverket.trafikverket_camera import CameraInfo, TrafikverketCamera
|
from pytrafikverket.trafikverket_camera import CameraInfo, TrafikverketCamera
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_API_KEY, CONF_ID, CONF_LOCATION
|
from homeassistant.const import CONF_API_KEY, CONF_ID, CONF_LOCATION
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
from homeassistant.helpers.selector import (
|
from homeassistant.helpers.selector import (
|
||||||
SelectOptionDict,
|
SelectOptionDict,
|
||||||
|
@ -23,12 +22,12 @@ from homeassistant.helpers.selector import (
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
|
|
||||||
class TVCameraConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class TVCameraConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow for Trafikverket Camera integration."""
|
"""Handle a config flow for Trafikverket Camera integration."""
|
||||||
|
|
||||||
VERSION = 3
|
VERSION = 3
|
||||||
|
|
||||||
entry: config_entries.ConfigEntry | None
|
entry: ConfigEntry | None
|
||||||
cameras: list[CameraInfo]
|
cameras: list[CameraInfo]
|
||||||
api_key: str
|
api_key: str
|
||||||
|
|
||||||
|
@ -52,7 +51,9 @@ class TVCameraConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
return (errors, cameras)
|
return (errors, cameras)
|
||||||
|
|
||||||
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 Trafikverket."""
|
"""Handle re-authentication with Trafikverket."""
|
||||||
|
|
||||||
self.entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
|
self.entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
|
||||||
|
@ -60,7 +61,7 @@ class TVCameraConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_reauth_confirm(
|
async def async_step_reauth_confirm(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Confirm re-authentication with Trafikverket."""
|
"""Confirm re-authentication with Trafikverket."""
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
|
|
||||||
|
@ -93,7 +94,7 @@ class TVCameraConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, str] | None = None
|
self, user_input: dict[str, str] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the initial step."""
|
"""Handle the initial step."""
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
|
|
||||||
|
@ -128,7 +129,7 @@ class TVCameraConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_multiple_cameras(
|
async def async_step_multiple_cameras(
|
||||||
self, user_input: dict[str, str] | None = None
|
self, user_input: dict[str, str] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle when multiple cameras."""
|
"""Handle when multiple cameras."""
|
||||||
|
|
||||||
if user_input:
|
if user_input:
|
||||||
|
|
|
@ -8,9 +8,8 @@ from pytrafikverket import TrafikverketFerry
|
||||||
from pytrafikverket.exceptions import InvalidAuthentication, NoFerryFound
|
from pytrafikverket.exceptions import InvalidAuthentication, NoFerryFound
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_API_KEY, CONF_NAME, CONF_WEEKDAY, WEEKDAYS
|
from homeassistant.const import CONF_API_KEY, CONF_NAME, CONF_WEEKDAY, WEEKDAYS
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.helpers import selector
|
from homeassistant.helpers import selector
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
|
|
||||||
|
@ -44,12 +43,12 @@ DATA_SCHEMA_REAUTH = vol.Schema(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class TVFerryConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class TVFerryConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow for Trafikverket Ferry integration."""
|
"""Handle a config flow for Trafikverket Ferry integration."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
|
||||||
entry: config_entries.ConfigEntry | None
|
entry: ConfigEntry | None
|
||||||
|
|
||||||
async def validate_input(
|
async def validate_input(
|
||||||
self, api_key: str, ferry_from: str, ferry_to: str
|
self, api_key: str, ferry_from: str, ferry_to: str
|
||||||
|
@ -59,7 +58,9 @@ class TVFerryConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
ferry_api = TrafikverketFerry(web_session, api_key)
|
ferry_api = TrafikverketFerry(web_session, api_key)
|
||||||
await ferry_api.async_get_next_ferry_stop(ferry_from, ferry_to)
|
await ferry_api.async_get_next_ferry_stop(ferry_from, ferry_to)
|
||||||
|
|
||||||
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 Trafikverket."""
|
"""Handle re-authentication with Trafikverket."""
|
||||||
|
|
||||||
self.entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
|
self.entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
|
||||||
|
@ -67,7 +68,7 @@ class TVFerryConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_reauth_confirm(
|
async def async_step_reauth_confirm(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Confirm re-authentication with Trafikverket."""
|
"""Confirm re-authentication with Trafikverket."""
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
|
|
||||||
|
@ -104,7 +105,7 @@ class TVFerryConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the user step."""
|
"""Handle the user step."""
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
|
|
||||||
|
|
|
@ -16,10 +16,14 @@ from pytrafikverket.exceptions import (
|
||||||
)
|
)
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant.config_entries import (
|
||||||
|
ConfigEntry,
|
||||||
|
ConfigFlow,
|
||||||
|
ConfigFlowResult,
|
||||||
|
OptionsFlowWithConfigEntry,
|
||||||
|
)
|
||||||
from homeassistant.const import CONF_API_KEY, CONF_NAME, CONF_WEEKDAY, WEEKDAYS
|
from homeassistant.const import CONF_API_KEY, CONF_NAME, CONF_WEEKDAY, WEEKDAYS
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.selector import (
|
from homeassistant.helpers.selector import (
|
||||||
|
@ -116,22 +120,24 @@ async def validate_input(
|
||||||
return errors
|
return errors
|
||||||
|
|
||||||
|
|
||||||
class TVTrainConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class TVTrainConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow for Trafikverket Train integration."""
|
"""Handle a config flow for Trafikverket Train integration."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
|
||||||
entry: config_entries.ConfigEntry | None
|
entry: ConfigEntry | None
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@callback
|
@callback
|
||||||
def async_get_options_flow(
|
def async_get_options_flow(
|
||||||
config_entry: config_entries.ConfigEntry,
|
config_entry: ConfigEntry,
|
||||||
) -> TVTrainOptionsFlowHandler:
|
) -> TVTrainOptionsFlowHandler:
|
||||||
"""Get the options flow for this handler."""
|
"""Get the options flow for this handler."""
|
||||||
return TVTrainOptionsFlowHandler(config_entry)
|
return TVTrainOptionsFlowHandler(config_entry)
|
||||||
|
|
||||||
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
|
async def async_step_reauth(
|
||||||
|
self, entry_data: Mapping[str, Any]
|
||||||
|
) -> ConfigFlowResult:
|
||||||
"""Handle re-authentication with Trafikverket."""
|
"""Handle re-authentication with Trafikverket."""
|
||||||
|
|
||||||
self.entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
|
self.entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
|
||||||
|
@ -139,7 +145,7 @@ class TVTrainConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_reauth_confirm(
|
async def async_step_reauth_confirm(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Confirm re-authentication with Trafikverket."""
|
"""Confirm re-authentication with Trafikverket."""
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
|
|
||||||
|
@ -175,7 +181,7 @@ class TVTrainConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the user step."""
|
"""Handle the user step."""
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
|
|
||||||
|
@ -231,12 +237,12 @@ class TVTrainConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class TVTrainOptionsFlowHandler(config_entries.OptionsFlowWithConfigEntry):
|
class TVTrainOptionsFlowHandler(OptionsFlowWithConfigEntry):
|
||||||
"""Handle Trafikverket Train options."""
|
"""Handle Trafikverket Train options."""
|
||||||
|
|
||||||
async def async_step_init(
|
async def async_step_init(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Manage Trafikverket Train options."""
|
"""Manage Trafikverket Train options."""
|
||||||
errors: dict[str, Any] = {}
|
errors: dict[str, Any] = {}
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue