Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions homeassistant/components/apple_tv/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from homeassistant.data_entry_flow import AbortFlow, FlowResult
from homeassistant.exceptions import HomeAssistantError
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

Expand Down Expand Up @@ -145,7 +144,7 @@ async def async_step_user(self, user_input=None):
)

async def async_step_zeroconf(
self, discovery_info: DiscoveryInfoType
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
"""Handle device found via zeroconf."""
service_type = discovery_info[zeroconf.ATTR_TYPE]
Expand Down
3 changes: 1 addition & 2 deletions homeassistant/components/axis/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.device_registry import format_mac
from homeassistant.helpers.typing import DiscoveryInfoType
from homeassistant.util.network import is_link_local

from .const import (
Expand Down Expand Up @@ -178,7 +177,7 @@ async def async_step_ssdp(self, discovery_info: dict):
)

async def async_step_zeroconf(
self, discovery_info: DiscoveryInfoType
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
"""Prepare configuration for a Zeroconf discovered Axis device."""
return await self._process_discovered_device(
Expand Down
3 changes: 1 addition & 2 deletions homeassistant/components/bond/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import AbortFlow, FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.typing import DiscoveryInfoType

from .const import DOMAIN
from .utils import BondHub
Expand Down Expand Up @@ -92,7 +91,7 @@ async def _async_try_automatic_configure(self) -> None:
self._discovered[CONF_NAME] = hub_name

async def async_step_zeroconf(
self, discovery_info: DiscoveryInfoType
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
"""Handle a flow initialized by zeroconf discovery."""
name: str = discovery_info[zeroconf.ATTR_NAME]
Expand Down
5 changes: 2 additions & 3 deletions homeassistant/components/brother/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from homeassistant.components import zeroconf
from homeassistant.const import CONF_HOST, CONF_TYPE
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.typing import DiscoveryInfoType

from .const import DOMAIN, PRINTER_TYPES
from .utils import get_snmp_engine
Expand Down Expand Up @@ -81,7 +80,7 @@ async def async_step_user(
)

async def async_step_zeroconf(
self, discovery_info: DiscoveryInfoType
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
"""Handle zeroconf discovery."""
# Hostname is format: brother.local.
Expand All @@ -91,7 +90,7 @@ async def async_step_zeroconf(
self._async_abort_entries_match({CONF_HOST: self.host})

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:
self.brother = Brother(self.host, snmp_engine=snmp_engine, model=model)
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/cast/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import voluptuous as vol

from homeassistant import config_entries
from homeassistant.components import zeroconf
from homeassistant.data_entry_flow import FlowResult
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

Expand Down Expand Up @@ -52,7 +52,7 @@ async def async_step_user(self, user_input=None):
return await self.async_step_config()

async def async_step_zeroconf(
self, discovery_info: DiscoveryInfoType
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
"""Handle a flow initialized by zeroconf discovery."""
if self._async_in_progress() or self._async_current_entries():
Expand Down
3 changes: 1 addition & 2 deletions homeassistant/components/daikin/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from homeassistant.components import zeroconf
from homeassistant.const import CONF_API_KEY, CONF_HOST, CONF_PASSWORD
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.typing import DiscoveryInfoType

from .const import CONF_UUID, DOMAIN, KEY_MAC, TIMEOUT

Expand Down Expand Up @@ -127,7 +126,7 @@ async def async_step_user(self, user_input=None):
)

async def async_step_zeroconf(
self, discovery_info: DiscoveryInfoType
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
"""Prepare configuration for a discovered Daikin device."""
_LOGGER.debug("Zeroconf user_input: %s", discovery_info)
Expand Down
8 changes: 2 additions & 6 deletions homeassistant/components/devolo_home_control/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.typing import DiscoveryInfoType

from . import configure_mydevolo
from .const import CONF_MYDEVOLO, DEFAULT_MYDEVOLO, DOMAIN, SUPPORTED_MODEL_TYPES
Expand Down Expand Up @@ -46,14 +45,11 @@ async def async_step_user(
return self._show_form(step_id="user", errors={"base": "invalid_auth"})

async def async_step_zeroconf(
self, discovery_info: DiscoveryInfoType
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
"""Handle zeroconf discovery."""
# Check if it is a gateway
if (
discovery_info.get(zeroconf.ATTR_PROPERTIES, {}).get("MT")
in SUPPORTED_MODEL_TYPES
):
if discovery_info[zeroconf.ATTR_PROPERTIES].get("MT") in SUPPORTED_MODEL_TYPES:
await self._async_handle_discovery_without_unique_id()
return await self.async_step_zeroconf_confirm()
return self.async_abort(reason="Not a devolo Home Control gateway.")
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/devolo_home_network/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from homeassistant.const import CONF_HOST, CONF_IP_ADDRESS, CONF_NAME
from homeassistant.data_entry_flow import FlowResult
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

Expand Down Expand Up @@ -74,7 +74,7 @@ async def async_step_user(self, user_input: ConfigType | None = None) -> FlowRes
)

async def async_step_zeroconf(
self, discovery_info: DiscoveryInfoType
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
"""Handle zerooconf discovery."""
if discovery_info[zeroconf.ATTR_PROPERTIES]["MT"] in ["2600", "2601"]:
Expand Down
7 changes: 5 additions & 2 deletions homeassistant/components/elgato/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from elgato import Elgato, ElgatoError
import voluptuous as vol

from homeassistant.components import zeroconf
from homeassistant.config_entries import ConfigFlow
from homeassistant.const import CONF_HOST, CONF_PORT
from homeassistant.core import callback
Expand Down Expand Up @@ -41,10 +42,12 @@ async def async_step_user(

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."""
self.host = discovery_info[CONF_HOST]
self.port = discovery_info[CONF_PORT]
self.port = discovery_info[CONF_PORT] or 9123

try:
await self._get_elgato_serial_number()
Expand Down
3 changes: 1 addition & 2 deletions homeassistant/components/esphome/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PASSWORD, CONF_PORT
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.typing import DiscoveryInfoType

from . import CONF_NOISE_PSK, DOMAIN, DomainData

Expand Down Expand Up @@ -139,7 +138,7 @@ async def async_step_discovery_confirm(
)

async def async_step_zeroconf(
self, discovery_info: DiscoveryInfoType
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
"""Handle zeroconf discovery."""
# Hostname is format: livingroom.local.
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/guardian/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import voluptuous as vol

from homeassistant import config_entries
from homeassistant.components import zeroconf
from homeassistant.components.dhcp import IP_ADDRESS
from homeassistant.const import CONF_IP_ADDRESS, CONF_PORT
from homeassistant.core import HomeAssistant, callback
Expand Down Expand Up @@ -107,7 +108,7 @@ async def async_step_dhcp(self, discovery_info: DiscoveryInfoType) -> FlowResult
return await self._async_handle_discovery()

async def async_step_zeroconf(
self, discovery_info: DiscoveryInfoType
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
"""Handle the configuration via zeroconf."""
self.discovery_info = {
Expand Down
3 changes: 1 addition & 2 deletions homeassistant/components/hue/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import aiohttp_client
from homeassistant.helpers.typing import DiscoveryInfoType

from .bridge import authenticate_bridge
from .const import (
Expand Down Expand Up @@ -209,7 +208,7 @@ async def async_step_ssdp(self, discovery_info):
return await self.async_step_link()

async def async_step_zeroconf(
self, discovery_info: DiscoveryInfoType
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
"""Handle a discovered Hue bridge.

Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/lookin/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
import voluptuous as vol

from homeassistant import config_entries
from homeassistant.components import zeroconf
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.typing import DiscoveryInfoType

from .const import DOMAIN

Expand All @@ -28,7 +28,7 @@ def __init__(self) -> None:
self._name: str | None = None

async def async_step_zeroconf(
self, discovery_info: DiscoveryInfoType
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
"""Start a discovery flow from zeroconf."""
uid: str = discovery_info["hostname"][: -len(".local.")]
Expand Down
8 changes: 4 additions & 4 deletions homeassistant/components/modern_forms/config_flow.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
"""Config flow for Modern Forms."""
from __future__ import annotations

from typing import Any
from typing import Any, cast

from aiomodernforms import ModernFormsConnectionError, ModernFormsDevice
import voluptuous as vol

from homeassistant.components import zeroconf
from homeassistant.config_entries import SOURCE_ZEROCONF, ConfigFlow
from homeassistant.const import CONF_HOST, CONF_MAC, CONF_NAME
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.typing import DiscoveryInfoType

from .const import DOMAIN

Expand All @@ -27,7 +27,7 @@ async def async_step_user(
return await self._handle_config_flow(user_input)

async def async_step_zeroconf(
self, discovery_info: DiscoveryInfoType
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
"""Handle zeroconf discovery."""
host = discovery_info["hostname"].rstrip(".")
Expand All @@ -43,7 +43,7 @@ async def async_step_zeroconf(
)

# 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(
self, user_input: dict[str, Any] | None = None
Expand Down
6 changes: 3 additions & 3 deletions homeassistant/components/nam/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
import voluptuous as vol

from homeassistant import config_entries
from homeassistant.components import zeroconf
from homeassistant.const import ATTR_NAME, CONF_HOST
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.device_registry import format_mac
from homeassistant.helpers.typing import DiscoveryInfoType

from .const import DOMAIN

Expand Down Expand Up @@ -69,7 +69,7 @@ async def async_step_user(
)

async def async_step_zeroconf(
self, discovery_info: DiscoveryInfoType
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
"""Handle zeroconf discovery."""
self.host = discovery_info[CONF_HOST]
Expand All @@ -78,7 +78,7 @@ async def async_step_zeroconf(
self._async_abort_entries_match({CONF_HOST: self.host})

try:
mac = await self._async_get_mac(cast(str, self.host))
mac = await self._async_get_mac(self.host)
except (ApiError, ClientConnectorError, asyncio.TimeoutError):
return self.async_abort(reason="cannot_connect")
except CannotGetMac:
Expand Down
7 changes: 5 additions & 2 deletions homeassistant/components/nanoleaf/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import voluptuous as vol

from homeassistant import config_entries
from homeassistant.components import zeroconf
from homeassistant.const import CONF_HOST, CONF_TOKEN
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
Expand Down Expand Up @@ -88,11 +89,13 @@ async def async_step_reauth(self, data: dict[str, str]) -> FlowResult:
return await self.async_step_link()

async def async_step_zeroconf(
self, discovery_info: DiscoveryInfoType
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
"""Handle Nanoleaf Zeroconf discovery."""
_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:
"""Handle Nanoleaf Homekit discovery."""
Expand Down
11 changes: 9 additions & 2 deletions homeassistant/components/rainmachine/config_flow.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
"""Config flow to configure the RainMachine component."""
from __future__ import annotations

from typing import Any
from typing import Any, cast

from regenmaschine import Client
from regenmaschine.controller import Controller
from regenmaschine.errors import RainMachineError
import voluptuous as vol

from homeassistant import config_entries
from homeassistant.components import zeroconf
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_IP_ADDRESS, CONF_PASSWORD, CONF_PORT, CONF_SSL
from homeassistant.core import HomeAssistant, callback
Expand Down Expand Up @@ -56,9 +57,15 @@ def async_get_options_flow(

async def async_step_homekit(self, discovery_info: DiscoveryInfoType) -> FlowResult:
"""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(
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
) -> FlowResult:
"""Handle discovery via zeroconf."""
Expand Down
Loading