Skip to content

Commit 4b7817f

Browse files
authored
Filter out IPv6 addresses in Govee Light Local (home-assistant#151540)
1 parent 180f898 commit 4b7817f

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

homeassistant/components/govee_light_local/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import asyncio
66
from contextlib import suppress
77
from errno import EADDRINUSE
8+
from ipaddress import IPv4Address
89
import logging
910

1011
from govee_local_api.controller import LISTENING_PORT
@@ -30,7 +31,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: GoveeLocalConfigEntry) -
3031
_LOGGER.debug("Enabled source IPs: %s", source_ips)
3132

3233
coordinator: GoveeLocalApiCoordinator = GoveeLocalApiCoordinator(
33-
hass=hass, config_entry=entry, source_ips=source_ips
34+
hass=hass,
35+
config_entry=entry,
36+
source_ips=[
37+
source_ip for source_ip in source_ips if isinstance(source_ip, IPv4Address)
38+
],
3439
)
3540

3641
async def await_cleanup():

homeassistant/components/govee_light_local/config_flow.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import asyncio
66
from contextlib import suppress
7-
from ipaddress import IPv4Address, IPv6Address
7+
from ipaddress import IPv4Address
88
import logging
99

1010
from govee_local_api import GoveeController
@@ -24,9 +24,7 @@
2424
_LOGGER = logging.getLogger(__name__)
2525

2626

27-
async def _async_discover(
28-
hass: HomeAssistant, adapter_ip: IPv4Address | IPv6Address
29-
) -> bool:
27+
async def _async_discover(hass: HomeAssistant, adapter_ip: IPv4Address) -> bool:
3028
controller: GoveeController = GoveeController(
3129
loop=hass.loop,
3230
logger=_LOGGER,
@@ -74,7 +72,9 @@ async def _async_has_devices(hass: HomeAssistant) -> bool:
7472
_LOGGER.debug("Enabled source IPs: %s", source_ips)
7573

7674
# Run discovery on every IPv4 address and gather results
77-
results = await asyncio.gather(*[_async_discover(hass, ip) for ip in source_ips])
75+
results = await asyncio.gather(
76+
*[_async_discover(hass, ip) for ip in source_ips if isinstance(ip, IPv4Address)]
77+
)
7878

7979
return any(results)
8080

homeassistant/components/govee_light_local/coordinator.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import asyncio
44
from collections.abc import Callable
5-
from ipaddress import IPv4Address, IPv6Address
5+
from ipaddress import IPv4Address
66
import logging
77

88
from govee_local_api import GoveeController, GoveeDevice
@@ -30,7 +30,7 @@ def __init__(
3030
self,
3131
hass: HomeAssistant,
3232
config_entry: GoveeLocalConfigEntry,
33-
source_ips: list[IPv4Address | IPv6Address],
33+
source_ips: list[IPv4Address],
3434
) -> None:
3535
"""Initialize my coordinator."""
3636
super().__init__(
@@ -114,5 +114,4 @@ def devices(self) -> list[GoveeDevice]:
114114
async def _async_update_data(self) -> list[GoveeDevice]:
115115
for controller in self._controllers:
116116
controller.send_update_message()
117-
118117
return self.devices

0 commit comments

Comments
 (0)