Adjust async_step_zeroconf signature for strict typing (#59503)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
5cc594682f
commit
b3ffc1e183
26 changed files with 85 additions and 66 deletions
|
@ -15,7 +15,6 @@ from homeassistant.core import callback
|
||||||
from homeassistant.data_entry_flow import AbortFlow, FlowResult
|
from homeassistant.data_entry_flow import AbortFlow, FlowResult
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
from homeassistant.helpers.typing import DiscoveryInfoType
|
|
||||||
|
|
||||||
from .const import CONF_CREDENTIALS, CONF_IDENTIFIER, CONF_START_OFF, DOMAIN
|
from .const import CONF_CREDENTIALS, CONF_IDENTIFIER, CONF_START_OFF, DOMAIN
|
||||||
|
|
||||||
|
@ -145,7 +144,7 @@ class AppleTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_zeroconf(
|
async def async_step_zeroconf(
|
||||||
self, discovery_info: DiscoveryInfoType
|
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||||
) -> FlowResult:
|
) -> FlowResult:
|
||||||
"""Handle device found via zeroconf."""
|
"""Handle device found via zeroconf."""
|
||||||
service_type = discovery_info[zeroconf.ATTR_TYPE]
|
service_type = discovery_info[zeroconf.ATTR_TYPE]
|
||||||
|
|
|
@ -20,7 +20,6 @@ from homeassistant.const import (
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
from homeassistant.data_entry_flow import FlowResult
|
||||||
from homeassistant.helpers.device_registry import format_mac
|
from homeassistant.helpers.device_registry import format_mac
|
||||||
from homeassistant.helpers.typing import DiscoveryInfoType
|
|
||||||
from homeassistant.util.network import is_link_local
|
from homeassistant.util.network import is_link_local
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
|
@ -178,7 +177,7 @@ class AxisFlowHandler(config_entries.ConfigFlow, domain=AXIS_DOMAIN):
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_zeroconf(
|
async def async_step_zeroconf(
|
||||||
self, discovery_info: DiscoveryInfoType
|
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||||
) -> FlowResult:
|
) -> FlowResult:
|
||||||
"""Prepare configuration for a Zeroconf discovered Axis device."""
|
"""Prepare configuration for a Zeroconf discovered Axis device."""
|
||||||
return await self._process_discovered_device(
|
return await self._process_discovered_device(
|
||||||
|
|
|
@ -16,7 +16,6 @@ from homeassistant.const import CONF_ACCESS_TOKEN, CONF_HOST, CONF_NAME
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.data_entry_flow import AbortFlow, FlowResult
|
from homeassistant.data_entry_flow import AbortFlow, FlowResult
|
||||||
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 .const import DOMAIN
|
from .const import DOMAIN
|
||||||
from .utils import BondHub
|
from .utils import BondHub
|
||||||
|
@ -92,7 +91,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
self._discovered[CONF_NAME] = hub_name
|
self._discovered[CONF_NAME] = hub_name
|
||||||
|
|
||||||
async def async_step_zeroconf(
|
async def async_step_zeroconf(
|
||||||
self, discovery_info: DiscoveryInfoType
|
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||||
) -> FlowResult:
|
) -> FlowResult:
|
||||||
"""Handle a flow initialized by zeroconf discovery."""
|
"""Handle a flow initialized by zeroconf discovery."""
|
||||||
name: str = discovery_info[zeroconf.ATTR_NAME]
|
name: str = discovery_info[zeroconf.ATTR_NAME]
|
||||||
|
|
|
@ -12,7 +12,6 @@ from homeassistant import config_entries, exceptions
|
||||||
from homeassistant.components import zeroconf
|
from homeassistant.components import zeroconf
|
||||||
from homeassistant.const import CONF_HOST, CONF_TYPE
|
from homeassistant.const import CONF_HOST, CONF_TYPE
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
from homeassistant.data_entry_flow import FlowResult
|
||||||
from homeassistant.helpers.typing import DiscoveryInfoType
|
|
||||||
|
|
||||||
from .const import DOMAIN, PRINTER_TYPES
|
from .const import DOMAIN, PRINTER_TYPES
|
||||||
from .utils import get_snmp_engine
|
from .utils import get_snmp_engine
|
||||||
|
@ -81,7 +80,7 @@ class BrotherConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_zeroconf(
|
async def async_step_zeroconf(
|
||||||
self, discovery_info: DiscoveryInfoType
|
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||||
) -> FlowResult:
|
) -> FlowResult:
|
||||||
"""Handle zeroconf discovery."""
|
"""Handle zeroconf discovery."""
|
||||||
# Hostname is format: brother.local.
|
# Hostname is format: brother.local.
|
||||||
|
@ -91,7 +90,7 @@ class BrotherConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
self._async_abort_entries_match({CONF_HOST: self.host})
|
self._async_abort_entries_match({CONF_HOST: self.host})
|
||||||
|
|
||||||
snmp_engine = get_snmp_engine(self.hass)
|
snmp_engine = get_snmp_engine(self.hass)
|
||||||
model = discovery_info.get(zeroconf.ATTR_PROPERTIES, {}).get("product")
|
model = discovery_info[zeroconf.ATTR_PROPERTIES].get("product")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.brother = Brother(self.host, snmp_engine=snmp_engine, model=model)
|
self.brother = Brother(self.host, snmp_engine=snmp_engine, model=model)
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
|
from homeassistant.components import zeroconf
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
from homeassistant.data_entry_flow import FlowResult
|
||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
from homeassistant.helpers.typing import DiscoveryInfoType
|
|
||||||
|
|
||||||
from .const import CONF_IGNORE_CEC, CONF_KNOWN_HOSTS, CONF_UUID, DOMAIN
|
from .const import CONF_IGNORE_CEC, CONF_KNOWN_HOSTS, CONF_UUID, DOMAIN
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
return await self.async_step_config()
|
return await self.async_step_config()
|
||||||
|
|
||||||
async def async_step_zeroconf(
|
async def async_step_zeroconf(
|
||||||
self, discovery_info: DiscoveryInfoType
|
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||||
) -> FlowResult:
|
) -> FlowResult:
|
||||||
"""Handle a flow initialized by zeroconf discovery."""
|
"""Handle a flow initialized by zeroconf discovery."""
|
||||||
if self._async_in_progress() or self._async_current_entries():
|
if self._async_in_progress() or self._async_current_entries():
|
||||||
|
|
|
@ -13,7 +13,6 @@ from homeassistant import config_entries
|
||||||
from homeassistant.components import zeroconf
|
from homeassistant.components import zeroconf
|
||||||
from homeassistant.const import CONF_API_KEY, CONF_HOST, CONF_PASSWORD
|
from homeassistant.const import CONF_API_KEY, CONF_HOST, CONF_PASSWORD
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
from homeassistant.data_entry_flow import FlowResult
|
||||||
from homeassistant.helpers.typing import DiscoveryInfoType
|
|
||||||
|
|
||||||
from .const import CONF_UUID, DOMAIN, KEY_MAC, TIMEOUT
|
from .const import CONF_UUID, DOMAIN, KEY_MAC, TIMEOUT
|
||||||
|
|
||||||
|
@ -127,7 +126,7 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_zeroconf(
|
async def async_step_zeroconf(
|
||||||
self, discovery_info: DiscoveryInfoType
|
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||||
) -> FlowResult:
|
) -> FlowResult:
|
||||||
"""Prepare configuration for a discovered Daikin device."""
|
"""Prepare configuration for a discovered Daikin device."""
|
||||||
_LOGGER.debug("Zeroconf user_input: %s", discovery_info)
|
_LOGGER.debug("Zeroconf user_input: %s", discovery_info)
|
||||||
|
|
|
@ -11,7 +11,6 @@ from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
from homeassistant.data_entry_flow import FlowResult
|
||||||
from homeassistant.helpers.typing import DiscoveryInfoType
|
|
||||||
|
|
||||||
from . import configure_mydevolo
|
from . import configure_mydevolo
|
||||||
from .const import CONF_MYDEVOLO, DEFAULT_MYDEVOLO, DOMAIN, SUPPORTED_MODEL_TYPES
|
from .const import CONF_MYDEVOLO, DEFAULT_MYDEVOLO, DOMAIN, SUPPORTED_MODEL_TYPES
|
||||||
|
@ -46,14 +45,11 @@ class DevoloHomeControlFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
return self._show_form(step_id="user", errors={"base": "invalid_auth"})
|
return self._show_form(step_id="user", errors={"base": "invalid_auth"})
|
||||||
|
|
||||||
async def async_step_zeroconf(
|
async def async_step_zeroconf(
|
||||||
self, discovery_info: DiscoveryInfoType
|
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||||
) -> FlowResult:
|
) -> FlowResult:
|
||||||
"""Handle zeroconf discovery."""
|
"""Handle zeroconf discovery."""
|
||||||
# Check if it is a gateway
|
# Check if it is a gateway
|
||||||
if (
|
if discovery_info[zeroconf.ATTR_PROPERTIES].get("MT") in SUPPORTED_MODEL_TYPES:
|
||||||
discovery_info.get(zeroconf.ATTR_PROPERTIES, {}).get("MT")
|
|
||||||
in SUPPORTED_MODEL_TYPES
|
|
||||||
):
|
|
||||||
await self._async_handle_discovery_without_unique_id()
|
await self._async_handle_discovery_without_unique_id()
|
||||||
return await self.async_step_zeroconf_confirm()
|
return await self.async_step_zeroconf_confirm()
|
||||||
return self.async_abort(reason="Not a devolo Home Control gateway.")
|
return self.async_abort(reason="Not a devolo Home Control gateway.")
|
||||||
|
|
|
@ -13,7 +13,7 @@ from homeassistant.components import zeroconf
|
||||||
from homeassistant.const import CONF_HOST, CONF_IP_ADDRESS, CONF_NAME
|
from homeassistant.const import CONF_HOST, CONF_IP_ADDRESS, CONF_NAME
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
from homeassistant.data_entry_flow import FlowResult
|
||||||
from homeassistant.helpers.httpx_client import get_async_client
|
from homeassistant.helpers.httpx_client import get_async_client
|
||||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
|
|
||||||
from .const import DOMAIN, PRODUCT, SERIAL_NUMBER, TITLE
|
from .const import DOMAIN, PRODUCT, SERIAL_NUMBER, TITLE
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_zeroconf(
|
async def async_step_zeroconf(
|
||||||
self, discovery_info: DiscoveryInfoType
|
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||||
) -> FlowResult:
|
) -> FlowResult:
|
||||||
"""Handle zerooconf discovery."""
|
"""Handle zerooconf discovery."""
|
||||||
if discovery_info[zeroconf.ATTR_PROPERTIES]["MT"] in ["2600", "2601"]:
|
if discovery_info[zeroconf.ATTR_PROPERTIES]["MT"] in ["2600", "2601"]:
|
||||||
|
|
|
@ -6,6 +6,7 @@ from typing import Any
|
||||||
from elgato import Elgato, ElgatoError
|
from elgato import Elgato, ElgatoError
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
|
from homeassistant.components import zeroconf
|
||||||
from homeassistant.config_entries import ConfigFlow
|
from homeassistant.config_entries import ConfigFlow
|
||||||
from homeassistant.const import CONF_HOST, CONF_PORT
|
from homeassistant.const import CONF_HOST, CONF_PORT
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
|
@ -41,10 +42,12 @@ class ElgatoFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
return self._async_create_entry()
|
return self._async_create_entry()
|
||||||
|
|
||||||
async def async_step_zeroconf(self, discovery_info: dict[str, Any]) -> FlowResult:
|
async def async_step_zeroconf(
|
||||||
|
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||||
|
) -> FlowResult:
|
||||||
"""Handle zeroconf discovery."""
|
"""Handle zeroconf discovery."""
|
||||||
self.host = discovery_info[CONF_HOST]
|
self.host = discovery_info[CONF_HOST]
|
||||||
self.port = discovery_info[CONF_PORT]
|
self.port = discovery_info[CONF_PORT] or 9123
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await self._get_elgato_serial_number()
|
await self._get_elgato_serial_number()
|
||||||
|
|
|
@ -20,7 +20,6 @@ from homeassistant.config_entries import ConfigFlow
|
||||||
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PASSWORD, CONF_PORT
|
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PASSWORD, CONF_PORT
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
from homeassistant.data_entry_flow import FlowResult
|
||||||
from homeassistant.helpers.typing import DiscoveryInfoType
|
|
||||||
|
|
||||||
from . import CONF_NOISE_PSK, DOMAIN, DomainData
|
from . import CONF_NOISE_PSK, DOMAIN, DomainData
|
||||||
|
|
||||||
|
@ -139,7 +138,7 @@ class EsphomeFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_zeroconf(
|
async def async_step_zeroconf(
|
||||||
self, discovery_info: DiscoveryInfoType
|
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||||
) -> FlowResult:
|
) -> FlowResult:
|
||||||
"""Handle zeroconf discovery."""
|
"""Handle zeroconf discovery."""
|
||||||
# Hostname is format: livingroom.local.
|
# Hostname is format: livingroom.local.
|
||||||
|
|
|
@ -8,6 +8,7 @@ from aioguardian.errors import GuardianError
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
|
from homeassistant.components import zeroconf
|
||||||
from homeassistant.components.dhcp import IP_ADDRESS
|
from homeassistant.components.dhcp import IP_ADDRESS
|
||||||
from homeassistant.const import CONF_IP_ADDRESS, CONF_PORT
|
from homeassistant.const import CONF_IP_ADDRESS, CONF_PORT
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
|
@ -107,7 +108,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
return await self._async_handle_discovery()
|
return await self._async_handle_discovery()
|
||||||
|
|
||||||
async def async_step_zeroconf(
|
async def async_step_zeroconf(
|
||||||
self, discovery_info: DiscoveryInfoType
|
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||||
) -> FlowResult:
|
) -> FlowResult:
|
||||||
"""Handle the configuration via zeroconf."""
|
"""Handle the configuration via zeroconf."""
|
||||||
self.discovery_info = {
|
self.discovery_info = {
|
||||||
|
|
|
@ -16,7 +16,6 @@ from homeassistant.const import CONF_HOST, CONF_USERNAME
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
from homeassistant.data_entry_flow import FlowResult
|
||||||
from homeassistant.helpers import aiohttp_client
|
from homeassistant.helpers import aiohttp_client
|
||||||
from homeassistant.helpers.typing import DiscoveryInfoType
|
|
||||||
|
|
||||||
from .bridge import authenticate_bridge
|
from .bridge import authenticate_bridge
|
||||||
from .const import (
|
from .const import (
|
||||||
|
@ -209,7 +208,7 @@ class HueFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
return await self.async_step_link()
|
return await self.async_step_link()
|
||||||
|
|
||||||
async def async_step_zeroconf(
|
async def async_step_zeroconf(
|
||||||
self, discovery_info: DiscoveryInfoType
|
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||||
) -> FlowResult:
|
) -> FlowResult:
|
||||||
"""Handle a discovered Hue bridge.
|
"""Handle a discovered Hue bridge.
|
||||||
|
|
||||||
|
|
|
@ -9,10 +9,10 @@ from aiolookin import Device, LookInHttpProtocol, NoUsableService
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
|
from homeassistant.components import zeroconf
|
||||||
from homeassistant.const import CONF_HOST
|
from homeassistant.const import CONF_HOST
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
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.typing import DiscoveryInfoType
|
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ class LookinFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
self._name: str | None = None
|
self._name: str | None = None
|
||||||
|
|
||||||
async def async_step_zeroconf(
|
async def async_step_zeroconf(
|
||||||
self, discovery_info: DiscoveryInfoType
|
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||||
) -> FlowResult:
|
) -> FlowResult:
|
||||||
"""Start a discovery flow from zeroconf."""
|
"""Start a discovery flow from zeroconf."""
|
||||||
uid: str = discovery_info["hostname"][: -len(".local.")]
|
uid: str = discovery_info["hostname"][: -len(".local.")]
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
"""Config flow for Modern Forms."""
|
"""Config flow for Modern Forms."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Any
|
from typing import Any, cast
|
||||||
|
|
||||||
from aiomodernforms import ModernFormsConnectionError, ModernFormsDevice
|
from aiomodernforms import ModernFormsConnectionError, ModernFormsDevice
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
|
from homeassistant.components import zeroconf
|
||||||
from homeassistant.config_entries import SOURCE_ZEROCONF, ConfigFlow
|
from homeassistant.config_entries import SOURCE_ZEROCONF, ConfigFlow
|
||||||
from homeassistant.const import CONF_HOST, CONF_MAC, CONF_NAME
|
from homeassistant.const import CONF_HOST, CONF_MAC, CONF_NAME
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
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.typing import DiscoveryInfoType
|
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ class ModernFormsFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
return await self._handle_config_flow(user_input)
|
return await self._handle_config_flow(user_input)
|
||||||
|
|
||||||
async def async_step_zeroconf(
|
async def async_step_zeroconf(
|
||||||
self, discovery_info: DiscoveryInfoType
|
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||||
) -> FlowResult:
|
) -> FlowResult:
|
||||||
"""Handle zeroconf discovery."""
|
"""Handle zeroconf discovery."""
|
||||||
host = discovery_info["hostname"].rstrip(".")
|
host = discovery_info["hostname"].rstrip(".")
|
||||||
|
@ -43,7 +43,7 @@ class ModernFormsFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
)
|
)
|
||||||
|
|
||||||
# Prepare configuration flow
|
# Prepare configuration flow
|
||||||
return await self._handle_config_flow(discovery_info, True)
|
return await self._handle_config_flow(cast(dict, discovery_info), True)
|
||||||
|
|
||||||
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
|
||||||
|
|
|
@ -11,11 +11,11 @@ from nettigo_air_monitor import ApiError, CannotGetMac, NettigoAirMonitor
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
|
from homeassistant.components import zeroconf
|
||||||
from homeassistant.const import ATTR_NAME, CONF_HOST
|
from homeassistant.const import ATTR_NAME, CONF_HOST
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
from homeassistant.data_entry_flow import FlowResult
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
from homeassistant.helpers.device_registry import format_mac
|
from homeassistant.helpers.device_registry import format_mac
|
||||||
from homeassistant.helpers.typing import DiscoveryInfoType
|
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ class NAMFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_zeroconf(
|
async def async_step_zeroconf(
|
||||||
self, discovery_info: DiscoveryInfoType
|
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||||
) -> FlowResult:
|
) -> FlowResult:
|
||||||
"""Handle zeroconf discovery."""
|
"""Handle zeroconf discovery."""
|
||||||
self.host = discovery_info[CONF_HOST]
|
self.host = discovery_info[CONF_HOST]
|
||||||
|
@ -78,7 +78,7 @@ class NAMFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
self._async_abort_entries_match({CONF_HOST: self.host})
|
self._async_abort_entries_match({CONF_HOST: self.host})
|
||||||
|
|
||||||
try:
|
try:
|
||||||
mac = await self._async_get_mac(cast(str, self.host))
|
mac = await self._async_get_mac(self.host)
|
||||||
except (ApiError, ClientConnectorError, asyncio.TimeoutError):
|
except (ApiError, ClientConnectorError, asyncio.TimeoutError):
|
||||||
return self.async_abort(reason="cannot_connect")
|
return self.async_abort(reason="cannot_connect")
|
||||||
except CannotGetMac:
|
except CannotGetMac:
|
||||||
|
|
|
@ -9,6 +9,7 @@ from aionanoleaf import InvalidToken, Nanoleaf, Unauthorized, Unavailable
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
|
from homeassistant.components import zeroconf
|
||||||
from homeassistant.const import CONF_HOST, CONF_TOKEN
|
from homeassistant.const import CONF_HOST, CONF_TOKEN
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
from homeassistant.data_entry_flow import FlowResult
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
|
@ -88,11 +89,13 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
return await self.async_step_link()
|
return await self.async_step_link()
|
||||||
|
|
||||||
async def async_step_zeroconf(
|
async def async_step_zeroconf(
|
||||||
self, discovery_info: DiscoveryInfoType
|
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||||
) -> FlowResult:
|
) -> FlowResult:
|
||||||
"""Handle Nanoleaf Zeroconf discovery."""
|
"""Handle Nanoleaf Zeroconf discovery."""
|
||||||
_LOGGER.debug("Zeroconf discovered: %s", discovery_info)
|
_LOGGER.debug("Zeroconf discovered: %s", discovery_info)
|
||||||
return await self._async_homekit_zeroconf_discovery_handler(discovery_info)
|
return await self._async_homekit_zeroconf_discovery_handler(
|
||||||
|
cast(dict, discovery_info)
|
||||||
|
)
|
||||||
|
|
||||||
async def async_step_homekit(self, discovery_info: DiscoveryInfoType) -> FlowResult:
|
async def async_step_homekit(self, discovery_info: DiscoveryInfoType) -> FlowResult:
|
||||||
"""Handle Nanoleaf Homekit discovery."""
|
"""Handle Nanoleaf Homekit discovery."""
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
"""Config flow to configure the RainMachine component."""
|
"""Config flow to configure the RainMachine component."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Any
|
from typing import Any, cast
|
||||||
|
|
||||||
from regenmaschine import Client
|
from regenmaschine import Client
|
||||||
from regenmaschine.controller import Controller
|
from regenmaschine.controller import Controller
|
||||||
|
@ -9,6 +9,7 @@ from regenmaschine.errors import RainMachineError
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
|
from homeassistant.components import zeroconf
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import CONF_IP_ADDRESS, CONF_PASSWORD, CONF_PORT, CONF_SSL
|
from homeassistant.const import CONF_IP_ADDRESS, CONF_PASSWORD, CONF_PORT, CONF_SSL
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
|
@ -56,9 +57,15 @@ class RainMachineFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
async def async_step_homekit(self, discovery_info: DiscoveryInfoType) -> FlowResult:
|
async def async_step_homekit(self, discovery_info: DiscoveryInfoType) -> FlowResult:
|
||||||
"""Handle a flow initialized by homekit discovery."""
|
"""Handle a flow initialized by homekit discovery."""
|
||||||
return await self.async_step_zeroconf(discovery_info)
|
return await self.async_step_homekit_zeroconf(discovery_info)
|
||||||
|
|
||||||
async def async_step_zeroconf(
|
async def async_step_zeroconf(
|
||||||
|
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||||
|
) -> FlowResult:
|
||||||
|
"""Handle discovery via zeroconf."""
|
||||||
|
return await self.async_step_homekit_zeroconf(cast(dict, discovery_info))
|
||||||
|
|
||||||
|
async def async_step_homekit_zeroconf(
|
||||||
self, discovery_info: DiscoveryInfoType
|
self, discovery_info: DiscoveryInfoType
|
||||||
) -> FlowResult:
|
) -> FlowResult:
|
||||||
"""Handle discovery via zeroconf."""
|
"""Handle discovery via zeroconf."""
|
||||||
|
|
|
@ -10,6 +10,7 @@ import getmac
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries, data_entry_flow
|
from homeassistant import config_entries, data_entry_flow
|
||||||
|
from homeassistant.components import zeroconf
|
||||||
from homeassistant.components.dhcp import IP_ADDRESS, MAC_ADDRESS
|
from homeassistant.components.dhcp import IP_ADDRESS, MAC_ADDRESS
|
||||||
from homeassistant.components.ssdp import (
|
from homeassistant.components.ssdp import (
|
||||||
ATTR_SSDP_LOCATION,
|
ATTR_SSDP_LOCATION,
|
||||||
|
@ -37,7 +38,6 @@ from .bridge import (
|
||||||
mac_from_device_info,
|
mac_from_device_info,
|
||||||
)
|
)
|
||||||
from .const import (
|
from .const import (
|
||||||
ATTR_PROPERTIES,
|
|
||||||
CONF_MANUFACTURER,
|
CONF_MANUFACTURER,
|
||||||
CONF_MODEL,
|
CONF_MODEL,
|
||||||
DEFAULT_MANUFACTURER,
|
DEFAULT_MANUFACTURER,
|
||||||
|
@ -297,12 +297,12 @@ class SamsungTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
return await self.async_step_confirm()
|
return await self.async_step_confirm()
|
||||||
|
|
||||||
async def async_step_zeroconf(
|
async def async_step_zeroconf(
|
||||||
self, discovery_info: DiscoveryInfoType
|
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||||
) -> data_entry_flow.FlowResult:
|
) -> data_entry_flow.FlowResult:
|
||||||
"""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[ATTR_PROPERTIES]["deviceid"])
|
self._mac = format_mac(discovery_info[zeroconf.ATTR_PROPERTIES]["deviceid"])
|
||||||
self._host = discovery_info[CONF_HOST]
|
self._host = discovery_info[zeroconf.ATTR_HOST]
|
||||||
await self._async_start_discovery_with_mac_address()
|
await self._async_start_discovery_with_mac_address()
|
||||||
await self._async_set_device_unique_id()
|
await self._async_set_device_unique_id()
|
||||||
self.context["title_placeholders"] = {"device": self._title}
|
self.context["title_placeholders"] = {"device": self._title}
|
||||||
|
|
|
@ -14,11 +14,11 @@ import async_timeout
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
|
from homeassistant.components import zeroconf
|
||||||
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.data_entry_flow import FlowResult
|
||||||
from homeassistant.helpers import aiohttp_client
|
from homeassistant.helpers import aiohttp_client
|
||||||
from homeassistant.helpers.typing import DiscoveryInfoType
|
|
||||||
|
|
||||||
from .const import AIOSHELLY_DEVICE_TIMEOUT_SEC, CONF_SLEEP_PERIOD, DOMAIN
|
from .const import AIOSHELLY_DEVICE_TIMEOUT_SEC, CONF_SLEEP_PERIOD, DOMAIN
|
||||||
from .utils import (
|
from .utils import (
|
||||||
|
@ -186,7 +186,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_zeroconf(
|
async def async_step_zeroconf(
|
||||||
self, discovery_info: DiscoveryInfoType
|
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||||
) -> FlowResult:
|
) -> FlowResult:
|
||||||
"""Handle zeroconf discovery."""
|
"""Handle zeroconf discovery."""
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
"""Config flow for SONOS."""
|
"""Config flow for SONOS."""
|
||||||
|
from typing import cast
|
||||||
|
|
||||||
import soco
|
import soco
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
|
from homeassistant.components import zeroconf
|
||||||
from homeassistant.const import CONF_HOST, CONF_NAME
|
from homeassistant.const import CONF_HOST, CONF_NAME
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
from homeassistant.data_entry_flow import FlowResult
|
||||||
from homeassistant.helpers.config_entry_flow import DiscoveryFlowHandler
|
from homeassistant.helpers.config_entry_flow import DiscoveryFlowHandler
|
||||||
from homeassistant.helpers.typing import DiscoveryInfoType
|
|
||||||
|
|
||||||
from .const import DATA_SONOS_DISCOVERY_MANAGER, DOMAIN
|
from .const import DATA_SONOS_DISCOVERY_MANAGER, DOMAIN
|
||||||
from .helpers import hostname_to_uid
|
from .helpers import hostname_to_uid
|
||||||
|
@ -26,7 +28,7 @@ class SonosDiscoveryFlowHandler(DiscoveryFlowHandler):
|
||||||
super().__init__(DOMAIN, "Sonos", _async_has_devices)
|
super().__init__(DOMAIN, "Sonos", _async_has_devices)
|
||||||
|
|
||||||
async def async_step_zeroconf(
|
async def async_step_zeroconf(
|
||||||
self, discovery_info: DiscoveryInfoType
|
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||||
) -> FlowResult:
|
) -> FlowResult:
|
||||||
"""Handle a flow initialized by zeroconf."""
|
"""Handle a flow initialized by zeroconf."""
|
||||||
hostname = discovery_info["hostname"]
|
hostname = discovery_info["hostname"]
|
||||||
|
@ -43,7 +45,7 @@ class SonosDiscoveryFlowHandler(DiscoveryFlowHandler):
|
||||||
discovery_manager.async_discovered_player(
|
discovery_manager.async_discovered_player(
|
||||||
"Zeroconf", properties, host, uid, boot_seqnum, model, mdns_name
|
"Zeroconf", properties, host, uid, boot_seqnum, model, mdns_name
|
||||||
)
|
)
|
||||||
return await self.async_step_discovery(discovery_info)
|
return await self.async_step_discovery(cast(dict, discovery_info))
|
||||||
|
|
||||||
|
|
||||||
config_entries.HANDLERS.register(DOMAIN)(SonosDiscoveryFlowHandler)
|
config_entries.HANDLERS.register(DOMAIN)(SonosDiscoveryFlowHandler)
|
||||||
|
|
|
@ -11,11 +11,11 @@ from systembridge.exceptions import BridgeAuthenticationException
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries, exceptions
|
from homeassistant import config_entries, exceptions
|
||||||
|
from homeassistant.components import zeroconf
|
||||||
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.data_entry_flow import FlowResult
|
||||||
from homeassistant.helpers import aiohttp_client, config_validation as cv
|
from homeassistant.helpers import aiohttp_client, config_validation as cv
|
||||||
from homeassistant.helpers.typing import DiscoveryInfoType
|
|
||||||
|
|
||||||
from .const import BRIDGE_CONNECTION_ERRORS, DOMAIN
|
from .const import BRIDGE_CONNECTION_ERRORS, DOMAIN
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_zeroconf(
|
async def async_step_zeroconf(
|
||||||
self, discovery_info: DiscoveryInfoType
|
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||||
) -> FlowResult:
|
) -> FlowResult:
|
||||||
"""Handle zeroconf discovery."""
|
"""Handle zeroconf discovery."""
|
||||||
host = discovery_info["properties"].get("ip")
|
host = discovery_info["properties"].get("ip")
|
||||||
|
|
|
@ -7,10 +7,10 @@ from pyvolumio import CannotConnectError, Volumio
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries, exceptions
|
from homeassistant import config_entries, exceptions
|
||||||
|
from homeassistant.components import zeroconf
|
||||||
from homeassistant.const import CONF_HOST, CONF_ID, CONF_NAME, CONF_PORT
|
from homeassistant.const import CONF_HOST, CONF_ID, CONF_NAME, CONF_PORT
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
from homeassistant.helpers.typing import DiscoveryInfoType
|
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
|
@ -93,10 +93,10 @@ 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_zeroconf(self, discovery_info: DiscoveryInfoType):
|
async def async_step_zeroconf(self, discovery_info: zeroconf.ZeroconfServiceInfo):
|
||||||
"""Handle zeroconf discovery."""
|
"""Handle zeroconf discovery."""
|
||||||
self._host = discovery_info["host"]
|
self._host = discovery_info["host"]
|
||||||
self._port = int(discovery_info["port"])
|
self._port = discovery_info["port"]
|
||||||
self._name = discovery_info["properties"]["volumioName"]
|
self._name = discovery_info["properties"]["volumioName"]
|
||||||
self._uuid = discovery_info["properties"]["UUID"]
|
self._uuid = discovery_info["properties"]["UUID"]
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
"""Config flow to configure the WLED integration."""
|
"""Config flow to configure the WLED integration."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Any
|
from typing import Any, cast
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
from wled import WLED, WLEDConnectionError
|
from wled import WLED, WLEDConnectionError
|
||||||
|
|
||||||
|
from homeassistant.components import zeroconf
|
||||||
from homeassistant.config_entries import (
|
from homeassistant.config_entries import (
|
||||||
SOURCE_ZEROCONF,
|
SOURCE_ZEROCONF,
|
||||||
ConfigEntry,
|
ConfigEntry,
|
||||||
|
@ -16,7 +17,6 @@ from homeassistant.const import CONF_HOST, CONF_MAC, CONF_NAME
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
from homeassistant.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.typing import DiscoveryInfoType
|
|
||||||
|
|
||||||
from .const import CONF_KEEP_MASTER_LIGHT, DEFAULT_KEEP_MASTER_LIGHT, DOMAIN
|
from .const import CONF_KEEP_MASTER_LIGHT, DEFAULT_KEEP_MASTER_LIGHT, DOMAIN
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ class WLEDFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
return await self._handle_config_flow(user_input)
|
return await self._handle_config_flow(user_input)
|
||||||
|
|
||||||
async def async_step_zeroconf(
|
async def async_step_zeroconf(
|
||||||
self, discovery_info: DiscoveryInfoType
|
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||||
) -> FlowResult:
|
) -> FlowResult:
|
||||||
"""Handle zeroconf discovery."""
|
"""Handle zeroconf discovery."""
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ class WLEDFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
)
|
)
|
||||||
|
|
||||||
# Prepare configuration flow
|
# Prepare configuration flow
|
||||||
return await self._handle_config_flow(discovery_info, True)
|
return await self._handle_config_flow(cast(dict, discovery_info), True)
|
||||||
|
|
||||||
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
|
||||||
|
|
|
@ -8,7 +8,7 @@ from enum import Enum
|
||||||
import functools
|
import functools
|
||||||
import logging
|
import logging
|
||||||
from types import MappingProxyType, MethodType
|
from types import MappingProxyType, MethodType
|
||||||
from typing import Any, Callable, Optional, cast
|
from typing import TYPE_CHECKING, Any, Callable, Optional, cast
|
||||||
import weakref
|
import weakref
|
||||||
|
|
||||||
from homeassistant import data_entry_flow, loader
|
from homeassistant import data_entry_flow, loader
|
||||||
|
@ -31,6 +31,9 @@ from homeassistant.setup import async_process_deps_reqs, async_setup_component
|
||||||
from homeassistant.util.decorator import Registry
|
from homeassistant.util.decorator import Registry
|
||||||
import homeassistant.util.uuid as uuid_util
|
import homeassistant.util.uuid as uuid_util
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from homeassistant.components.zeroconf import ZeroconfServiceInfo
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
SOURCE_DISCOVERY = "discovery"
|
SOURCE_DISCOVERY = "discovery"
|
||||||
|
@ -1369,10 +1372,10 @@ class ConfigFlow(data_entry_flow.FlowHandler):
|
||||||
return await self.async_step_discovery(discovery_info)
|
return await self.async_step_discovery(discovery_info)
|
||||||
|
|
||||||
async def async_step_zeroconf(
|
async def async_step_zeroconf(
|
||||||
self, discovery_info: DiscoveryInfoType
|
self, discovery_info: ZeroconfServiceInfo
|
||||||
) -> data_entry_flow.FlowResult:
|
) -> data_entry_flow.FlowResult:
|
||||||
"""Handle a flow initialized by Zeroconf discovery."""
|
"""Handle a flow initialized by Zeroconf discovery."""
|
||||||
return await self.async_step_discovery(discovery_info)
|
return await self.async_step_discovery(cast(dict, discovery_info))
|
||||||
|
|
||||||
async def async_step_dhcp(
|
async def async_step_dhcp(
|
||||||
self, discovery_info: DiscoveryInfoType
|
self, discovery_info: DiscoveryInfoType
|
||||||
|
|
|
@ -5,6 +5,7 @@ import logging
|
||||||
from typing import Any, Awaitable, Callable, Union
|
from typing import Any, Awaitable, Callable, Union
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
|
from homeassistant.components import zeroconf
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
from homeassistant.data_entry_flow import FlowResult
|
||||||
from homeassistant.helpers.typing import UNDEFINED, DiscoveryInfoType, UndefinedType
|
from homeassistant.helpers.typing import UNDEFINED, DiscoveryInfoType, UndefinedType
|
||||||
|
@ -81,7 +82,17 @@ class DiscoveryFlowHandler(config_entries.ConfigFlow):
|
||||||
|
|
||||||
return await self.async_step_confirm()
|
return await self.async_step_confirm()
|
||||||
|
|
||||||
async_step_zeroconf = async_step_discovery
|
async def async_step_zeroconf(
|
||||||
|
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||||
|
) -> FlowResult:
|
||||||
|
"""Handle a flow initialized by Zeroconf discovery."""
|
||||||
|
if self._async_in_progress() or self._async_current_entries():
|
||||||
|
return self.async_abort(reason="single_instance_allowed")
|
||||||
|
|
||||||
|
await self.async_set_unique_id(self._domain)
|
||||||
|
|
||||||
|
return await self.async_step_confirm()
|
||||||
|
|
||||||
async_step_ssdp = async_step_discovery
|
async_step_ssdp = async_step_discovery
|
||||||
async_step_mqtt = async_step_discovery
|
async_step_mqtt = async_step_discovery
|
||||||
async_step_homekit = async_step_discovery
|
async_step_homekit = async_step_discovery
|
||||||
|
|
|
@ -145,7 +145,7 @@ async def test_zeroconf_snmp_error(hass):
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": SOURCE_ZEROCONF},
|
context={"source": SOURCE_ZEROCONF},
|
||||||
data=zeroconf.ZeroconfServiceInfo(
|
data=zeroconf.ZeroconfServiceInfo(
|
||||||
hostname="example.local.", name="Brother Printer"
|
hostname="example.local.", name="Brother Printer", properties={}
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ async def test_zeroconf_device_exists_abort(hass):
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": SOURCE_ZEROCONF},
|
context={"source": SOURCE_ZEROCONF},
|
||||||
data=zeroconf.ZeroconfServiceInfo(
|
data=zeroconf.ZeroconfServiceInfo(
|
||||||
hostname="example.local.", name="Brother Printer"
|
hostname="example.local.", name="Brother Printer", properties={}
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -223,7 +223,7 @@ async def test_zeroconf_confirm_create_entry(hass):
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": SOURCE_ZEROCONF},
|
context={"source": SOURCE_ZEROCONF},
|
||||||
data=zeroconf.ZeroconfServiceInfo(
|
data=zeroconf.ZeroconfServiceInfo(
|
||||||
hostname="example.local.", name="Brother Printer"
|
hostname="example.local.", name="Brother Printer", properties={}
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue