From 6c095a963dd1b914f5b0aca0d7a7a7dfbc3904d7 Mon Sep 17 00:00:00 2001
From: "J. Nick Koston" <nick@koston.org>
Date: Wed, 20 Sep 2023 01:08:58 +0200
Subject: [PATCH] Switch config flows use newer zeroconf methods to check IP
 Addresses (#100568)

---
 homeassistant/components/apple_tv/config_flow.py | 5 ++---
 homeassistant/components/baf/config_flow.py      | 5 ++---
 homeassistant/components/hue/config_flow.py      | 3 +--
 3 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/homeassistant/components/apple_tv/config_flow.py b/homeassistant/components/apple_tv/config_flow.py
index 8a2130faca0..6a85ea1d1a8 100644
--- a/homeassistant/components/apple_tv/config_flow.py
+++ b/homeassistant/components/apple_tv/config_flow.py
@@ -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}.", "")
diff --git a/homeassistant/components/baf/config_flow.py b/homeassistant/components/baf/config_flow.py
index bbae3914533..9edb23abcf8 100644
--- a/homeassistant/components/baf/config_flow.py
+++ b/homeassistant/components/baf/config_flow.py
@@ -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"]
diff --git a/homeassistant/components/hue/config_flow.py b/homeassistant/components/hue/config_flow.py
index 9c8dda94c94..0957329abb0 100644
--- a/homeassistant/components/hue/config_flow.py
+++ b/homeassistant/components/hue/config_flow.py
@@ -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
-- 
GitLab