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
10 changes: 5 additions & 5 deletions homeassistant/components/nanoleaf/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,17 @@ async def async_step_zeroconf(
) -> FlowResult:
"""Handle Nanoleaf Zeroconf discovery."""
_LOGGER.debug("Zeroconf discovered: %s", discovery_info)
return await self._async_homekit_zeroconf_discovery_handler(
cast(dict, discovery_info)
)
return await self._async_homekit_zeroconf_discovery_handler(discovery_info)

async def async_step_homekit(self, discovery_info: DiscoveryInfoType) -> FlowResult:
async def async_step_homekit(
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
"""Handle Nanoleaf Homekit discovery."""
_LOGGER.debug("Homekit discovered: %s", discovery_info)
return await self._async_homekit_zeroconf_discovery_handler(discovery_info)

async def _async_homekit_zeroconf_discovery_handler(
self, discovery_info: DiscoveryInfoType
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
"""Handle Nanoleaf Homekit and Zeroconf discovery."""
return await self._async_discovery_handler(
Expand Down
11 changes: 6 additions & 5 deletions homeassistant/components/rainmachine/config_flow.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Config flow to configure the RainMachine component."""
from __future__ import annotations

from typing import Any, cast
from typing import Any

from regenmaschine import Client
from regenmaschine.controller import Controller
Expand All @@ -15,7 +15,6 @@
from homeassistant.core import HomeAssistant, callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import aiohttp_client, config_validation as cv
from homeassistant.helpers.typing import DiscoveryInfoType

from .const import CONF_ZONE_RUN_TIME, DEFAULT_PORT, DEFAULT_ZONE_RUN, DOMAIN

Expand Down Expand Up @@ -55,18 +54,20 @@ def async_get_options_flow(
"""Define the config flow to handle options."""
return RainMachineOptionsFlowHandler(config_entry)

async def async_step_homekit(self, discovery_info: DiscoveryInfoType) -> FlowResult:
async def async_step_homekit(
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
"""Handle a flow initialized by homekit discovery."""
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))
return await self.async_step_homekit_zeroconf(discovery_info)

async def async_step_homekit_zeroconf(
self, discovery_info: DiscoveryInfoType
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
"""Handle discovery via zeroconf."""
ip_address = discovery_info["host"]
Expand Down
8 changes: 5 additions & 3 deletions homeassistant/components/tradfri/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
import voluptuous as vol

from homeassistant import config_entries
from homeassistant.components import zeroconf
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.typing import DiscoveryInfoType

from .const import (
CONF_GATEWAY_ID,
Expand Down Expand Up @@ -42,7 +42,7 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):

def __init__(self) -> None:
"""Initialize flow."""
self._host = None
self._host: str | None = None
self._import_groups = False

async def async_step_user(
Expand Down Expand Up @@ -92,7 +92,9 @@ async def async_step_auth(
step_id="auth", data_schema=vol.Schema(fields), errors=errors
)

async def async_step_homekit(self, discovery_info: DiscoveryInfoType) -> FlowResult:
async def async_step_homekit(
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
"""Handle homekit discovery."""
await self.async_set_unique_id(discovery_info["properties"]["id"])
self._abort_if_unique_id_configured({CONF_HOST: discovery_info["host"]})
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/config_entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -1354,10 +1354,10 @@ async def async_step_hassio(
return await self.async_step_discovery(discovery_info)

async def async_step_homekit(
self, discovery_info: DiscoveryInfoType
self, discovery_info: ZeroconfServiceInfo
) -> data_entry_flow.FlowResult:
"""Handle a flow initialized by Homekit discovery."""
return await self.async_step_discovery(discovery_info)
return await self.async_step_discovery(cast(dict, discovery_info))

async def async_step_mqtt(
self, discovery_info: DiscoveryInfoType
Expand Down
12 changes: 11 additions & 1 deletion homeassistant/helpers/config_entry_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,17 @@ async def async_step_discovery(

return await self.async_step_confirm()

async def async_step_homekit(
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
"""Handle a flow initialized by Homekit 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 def async_step_zeroconf(
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
Expand All @@ -95,7 +106,6 @@ async def async_step_zeroconf(

async_step_ssdp = async_step_discovery
async_step_mqtt = async_step_discovery
async_step_homekit = async_step_discovery
async_step_dhcp = async_step_discovery

async def async_step_import(self, _: dict[str, Any] | None) -> FlowResult:
Expand Down