Fix homekit creating executor jobs to resolve default listen ips (#112522)
This commit is contained in:
parent
b8e39bd968
commit
675b1a392b
2 changed files with 13 additions and 8 deletions
|
@ -7,6 +7,7 @@ from copy import deepcopy
|
||||||
import ipaddress
|
import ipaddress
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
import socket
|
||||||
from typing import Any, cast
|
from typing import Any, cast
|
||||||
|
|
||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
|
@ -149,6 +150,8 @@ PORT_CLEANUP_CHECK_INTERVAL_SECS = 1
|
||||||
_HOMEKIT_CONFIG_UPDATE_TIME = (
|
_HOMEKIT_CONFIG_UPDATE_TIME = (
|
||||||
10 # number of seconds to wait for homekit to see the c# change
|
10 # number of seconds to wait for homekit to see the c# change
|
||||||
)
|
)
|
||||||
|
_HAS_IPV6 = hasattr(socket, "AF_INET6")
|
||||||
|
_DEFAULT_BIND = ["0.0.0.0", "::"] if _HAS_IPV6 else ["0.0.0.0"]
|
||||||
|
|
||||||
|
|
||||||
def _has_all_unique_names_and_ports(
|
def _has_all_unique_names_and_ports(
|
||||||
|
@ -308,7 +311,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
_LOGGER.debug("Begin setup HomeKit for %s", name)
|
_LOGGER.debug("Begin setup HomeKit for %s", name)
|
||||||
|
|
||||||
# ip_address and advertise_ip are yaml only
|
# ip_address and advertise_ip are yaml only
|
||||||
ip_address = conf.get(CONF_IP_ADDRESS, [None])
|
ip_address = conf.get(CONF_IP_ADDRESS, _DEFAULT_BIND)
|
||||||
advertise_ips: list[str] = conf.get(
|
advertise_ips: list[str] = conf.get(
|
||||||
CONF_ADVERTISE_IP
|
CONF_ADVERTISE_IP
|
||||||
) or await network.async_get_announce_addresses(hass)
|
) or await network.async_get_announce_addresses(hass)
|
||||||
|
|
|
@ -80,6 +80,8 @@ from tests.common import MockConfigEntry, get_fixture_path
|
||||||
|
|
||||||
IP_ADDRESS = "127.0.0.1"
|
IP_ADDRESS = "127.0.0.1"
|
||||||
|
|
||||||
|
DEFAULT_LISTEN = ["0.0.0.0", "::"]
|
||||||
|
|
||||||
|
|
||||||
def generate_filter(
|
def generate_filter(
|
||||||
include_domains,
|
include_domains,
|
||||||
|
@ -173,7 +175,7 @@ async def test_setup_min(hass: HomeAssistant, mock_async_zeroconf: None) -> None
|
||||||
hass,
|
hass,
|
||||||
BRIDGE_NAME,
|
BRIDGE_NAME,
|
||||||
DEFAULT_PORT,
|
DEFAULT_PORT,
|
||||||
[None],
|
DEFAULT_LISTEN,
|
||||||
ANY,
|
ANY,
|
||||||
ANY,
|
ANY,
|
||||||
{},
|
{},
|
||||||
|
@ -215,7 +217,7 @@ async def test_removing_entry(
|
||||||
hass,
|
hass,
|
||||||
BRIDGE_NAME,
|
BRIDGE_NAME,
|
||||||
DEFAULT_PORT,
|
DEFAULT_PORT,
|
||||||
[None],
|
DEFAULT_LISTEN,
|
||||||
ANY,
|
ANY,
|
||||||
ANY,
|
ANY,
|
||||||
{},
|
{},
|
||||||
|
@ -354,7 +356,7 @@ async def test_homekit_with_single_advertise_ips(
|
||||||
ANY,
|
ANY,
|
||||||
entry.title,
|
entry.title,
|
||||||
loop=hass.loop,
|
loop=hass.loop,
|
||||||
address=[None],
|
address=DEFAULT_LISTEN,
|
||||||
port=ANY,
|
port=ANY,
|
||||||
persist_file=ANY,
|
persist_file=ANY,
|
||||||
advertised_address="1.3.4.4",
|
advertised_address="1.3.4.4",
|
||||||
|
@ -393,7 +395,7 @@ async def test_homekit_with_many_advertise_ips(
|
||||||
ANY,
|
ANY,
|
||||||
entry.title,
|
entry.title,
|
||||||
loop=hass.loop,
|
loop=hass.loop,
|
||||||
address=[None],
|
address=DEFAULT_LISTEN,
|
||||||
port=ANY,
|
port=ANY,
|
||||||
persist_file=ANY,
|
persist_file=ANY,
|
||||||
advertised_address=["1.3.4.4", "4.3.2.2"],
|
advertised_address=["1.3.4.4", "4.3.2.2"],
|
||||||
|
@ -1678,7 +1680,7 @@ async def test_yaml_updates_update_config_entry_for_name(
|
||||||
hass,
|
hass,
|
||||||
BRIDGE_NAME,
|
BRIDGE_NAME,
|
||||||
12345,
|
12345,
|
||||||
[None],
|
DEFAULT_LISTEN,
|
||||||
ANY,
|
ANY,
|
||||||
ANY,
|
ANY,
|
||||||
{},
|
{},
|
||||||
|
@ -2049,7 +2051,7 @@ async def test_reload(hass: HomeAssistant, mock_async_zeroconf: None) -> None:
|
||||||
hass,
|
hass,
|
||||||
"reloadable",
|
"reloadable",
|
||||||
12345,
|
12345,
|
||||||
[None],
|
DEFAULT_LISTEN,
|
||||||
ANY,
|
ANY,
|
||||||
False,
|
False,
|
||||||
{},
|
{},
|
||||||
|
@ -2084,7 +2086,7 @@ async def test_reload(hass: HomeAssistant, mock_async_zeroconf: None) -> None:
|
||||||
hass,
|
hass,
|
||||||
"reloadable",
|
"reloadable",
|
||||||
45678,
|
45678,
|
||||||
[None],
|
DEFAULT_LISTEN,
|
||||||
ANY,
|
ANY,
|
||||||
False,
|
False,
|
||||||
{},
|
{},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue