mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 12:47:08 +00:00
Adjust async_step_homekit signature for strict typing (#59745)
* Use ZeroconfServiceInfo in async_step_homekit * Update DiscoveryFlowHandler * Update components
This commit is contained in:
parent
c0a8cea6fb
commit
4d96ca3ddb
@ -93,17 +93,17 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
) -> 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(
|
return await self._async_homekit_zeroconf_discovery_handler(discovery_info)
|
||||||
cast(dict, 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."""
|
"""Handle Nanoleaf Homekit discovery."""
|
||||||
_LOGGER.debug("Homekit discovered: %s", discovery_info)
|
_LOGGER.debug("Homekit discovered: %s", discovery_info)
|
||||||
return await self._async_homekit_zeroconf_discovery_handler(discovery_info)
|
return await self._async_homekit_zeroconf_discovery_handler(discovery_info)
|
||||||
|
|
||||||
async def _async_homekit_zeroconf_discovery_handler(
|
async def _async_homekit_zeroconf_discovery_handler(
|
||||||
self, discovery_info: DiscoveryInfoType
|
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||||
) -> FlowResult:
|
) -> FlowResult:
|
||||||
"""Handle Nanoleaf Homekit and Zeroconf discovery."""
|
"""Handle Nanoleaf Homekit and Zeroconf discovery."""
|
||||||
return await self._async_discovery_handler(
|
return await self._async_discovery_handler(
|
||||||
|
@ -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, cast
|
from typing import Any
|
||||||
|
|
||||||
from regenmaschine import Client
|
from regenmaschine import Client
|
||||||
from regenmaschine.controller import Controller
|
from regenmaschine.controller import Controller
|
||||||
@ -15,7 +15,6 @@ from homeassistant.const import CONF_IP_ADDRESS, CONF_PASSWORD, CONF_PORT, CONF_
|
|||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
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 CONF_ZONE_RUN_TIME, DEFAULT_PORT, DEFAULT_ZONE_RUN, DOMAIN
|
from .const import CONF_ZONE_RUN_TIME, DEFAULT_PORT, DEFAULT_ZONE_RUN, DOMAIN
|
||||||
|
|
||||||
@ -55,7 +54,9 @@ class RainMachineFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
"""Define the config flow to handle options."""
|
"""Define the config flow to handle options."""
|
||||||
return RainMachineOptionsFlowHandler(config_entry)
|
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."""
|
"""Handle a flow initialized by homekit discovery."""
|
||||||
return await self.async_step_homekit_zeroconf(discovery_info)
|
return await self.async_step_homekit_zeroconf(discovery_info)
|
||||||
|
|
||||||
@ -63,10 +64,10 @@ class RainMachineFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||||
) -> FlowResult:
|
) -> FlowResult:
|
||||||
"""Handle discovery via zeroconf."""
|
"""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(
|
async def async_step_homekit_zeroconf(
|
||||||
self, discovery_info: DiscoveryInfoType
|
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||||
) -> FlowResult:
|
) -> FlowResult:
|
||||||
"""Handle discovery via zeroconf."""
|
"""Handle discovery via zeroconf."""
|
||||||
ip_address = discovery_info["host"]
|
ip_address = discovery_info["host"]
|
||||||
|
@ -11,9 +11,9 @@ from pytradfri.api.aiocoap_api import APIFactory
|
|||||||
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.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 DiscoveryInfoType
|
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
CONF_GATEWAY_ID,
|
CONF_GATEWAY_ID,
|
||||||
@ -42,7 +42,7 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
"""Initialize flow."""
|
"""Initialize flow."""
|
||||||
self._host = None
|
self._host: str | None = None
|
||||||
self._import_groups = False
|
self._import_groups = False
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
@ -92,7 +92,9 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
step_id="auth", data_schema=vol.Schema(fields), errors=errors
|
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."""
|
"""Handle homekit discovery."""
|
||||||
await self.async_set_unique_id(discovery_info["properties"]["id"])
|
await self.async_set_unique_id(discovery_info["properties"]["id"])
|
||||||
self._abort_if_unique_id_configured({CONF_HOST: discovery_info["host"]})
|
self._abort_if_unique_id_configured({CONF_HOST: discovery_info["host"]})
|
||||||
|
@ -1354,10 +1354,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_homekit(
|
async def async_step_homekit(
|
||||||
self, discovery_info: DiscoveryInfoType
|
self, discovery_info: ZeroconfServiceInfo
|
||||||
) -> data_entry_flow.FlowResult:
|
) -> data_entry_flow.FlowResult:
|
||||||
"""Handle a flow initialized by Homekit discovery."""
|
"""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(
|
async def async_step_mqtt(
|
||||||
self, discovery_info: DiscoveryInfoType
|
self, discovery_info: DiscoveryInfoType
|
||||||
|
@ -82,6 +82,17 @@ class DiscoveryFlowHandler(config_entries.ConfigFlow):
|
|||||||
|
|
||||||
return await self.async_step_confirm()
|
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(
|
async def async_step_zeroconf(
|
||||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||||
) -> FlowResult:
|
) -> FlowResult:
|
||||||
@ -95,7 +106,6 @@ class DiscoveryFlowHandler(config_entries.ConfigFlow):
|
|||||||
|
|
||||||
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_dhcp = async_step_discovery
|
async_step_dhcp = async_step_discovery
|
||||||
|
|
||||||
async def async_step_import(self, _: dict[str, Any] | None) -> FlowResult:
|
async def async_step_import(self, _: dict[str, Any] | None) -> FlowResult:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user