mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 01:08:12 +00:00
Switch config flows use newer zeroconf methods to check IP Addresses (#100568)
This commit is contained in:
parent
1d5905b591
commit
6c095a963d
@ -26,7 +26,6 @@ from homeassistant.helpers.schema_config_entry_flow import (
|
||||
SchemaFlowFormStep,
|
||||
SchemaOptionsFlowHandler,
|
||||
)
|
||||
from homeassistant.util.network import is_ipv6_address
|
||||
|
||||
from .const import CONF_CREDENTIALS, CONF_IDENTIFIERS, CONF_START_OFF, DOMAIN
|
||||
|
||||
@ -184,9 +183,9 @@ class AppleTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||
) -> FlowResult:
|
||||
"""Handle device found via zeroconf."""
|
||||
host = discovery_info.host
|
||||
if is_ipv6_address(host):
|
||||
if discovery_info.ip_address.version == 6:
|
||||
return self.async_abort(reason="ipv6_not_supported")
|
||||
host = discovery_info.host
|
||||
self._async_abort_entries_match({CONF_ADDRESS: host})
|
||||
service_type = discovery_info.type[:-1] # Remove leading .
|
||||
name = discovery_info.name.replace(f".{service_type}.", "")
|
||||
|
@ -14,7 +14,6 @@ from homeassistant import config_entries
|
||||
from homeassistant.components import zeroconf
|
||||
from homeassistant.const import CONF_IP_ADDRESS
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.util.network import is_ipv6_address
|
||||
|
||||
from .const import DOMAIN, RUN_TIMEOUT
|
||||
from .models import BAFDiscovery
|
||||
@ -49,10 +48,10 @@ class BAFFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||
) -> FlowResult:
|
||||
"""Handle zeroconf discovery."""
|
||||
if discovery_info.ip_address.version == 6:
|
||||
return self.async_abort(reason="ipv6_not_supported")
|
||||
properties = discovery_info.properties
|
||||
ip_address = discovery_info.host
|
||||
if is_ipv6_address(ip_address):
|
||||
return self.async_abort(reason="ipv6_not_supported")
|
||||
uuid = properties["uuid"]
|
||||
model = properties["model"]
|
||||
name = properties["name"]
|
||||
|
@ -22,7 +22,6 @@ from homeassistant.helpers import (
|
||||
config_validation as cv,
|
||||
device_registry as dr,
|
||||
)
|
||||
from homeassistant.util.network import is_ipv6_address
|
||||
|
||||
from .const import (
|
||||
CONF_ALLOW_HUE_GROUPS,
|
||||
@ -219,7 +218,7 @@ class HueFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
host is already configured and delegate to the import step if not.
|
||||
"""
|
||||
# Ignore if host is IPv6
|
||||
if is_ipv6_address(discovery_info.host):
|
||||
if discovery_info.ip_address.version == 6:
|
||||
return self.async_abort(reason="invalid_host")
|
||||
|
||||
# abort if we already have exactly this bridge id/host
|
||||
|
Loading…
x
Reference in New Issue
Block a user