mirror of
https://github.com/home-assistant/core.git
synced 2025-07-09 22:37:11 +00:00
Remove zeroconf options from homekit (#35687)
* Remove zeroconf options from homekit homekit uses the system shared zeroconf instance which made the interface choice option controlled by the zeroconf integration setting. * change to cv.deprecated * adj * fix remaining tests from original merge conflict * remove invalidation_version
This commit is contained in:
parent
bfc5aa90b1
commit
5f4fdaa171
@ -6,7 +6,6 @@ import os
|
||||
|
||||
from aiohttp import web
|
||||
import voluptuous as vol
|
||||
from zeroconf import InterfaceChoice
|
||||
|
||||
from homeassistant.components import zeroconf
|
||||
from homeassistant.components.binary_sensor import (
|
||||
@ -71,7 +70,6 @@ from .const import (
|
||||
DEFAULT_AUTO_START,
|
||||
DEFAULT_PORT,
|
||||
DEFAULT_SAFE_MODE,
|
||||
DEFAULT_ZEROCONF_DEFAULT_INTERFACE,
|
||||
DOMAIN,
|
||||
EVENT_HOMEKIT_CHANGED,
|
||||
HOMEKIT,
|
||||
@ -113,23 +111,24 @@ def _has_all_unique_names_and_ports(bridges):
|
||||
return bridges
|
||||
|
||||
|
||||
BRIDGE_SCHEMA = vol.Schema(
|
||||
{
|
||||
vol.Optional(CONF_NAME, default=BRIDGE_NAME): vol.All(
|
||||
cv.string, vol.Length(min=3, max=25)
|
||||
),
|
||||
vol.Optional(CONF_PORT, default=DEFAULT_PORT): cv.port,
|
||||
vol.Optional(CONF_IP_ADDRESS): vol.All(ipaddress.ip_address, cv.string),
|
||||
vol.Optional(CONF_ADVERTISE_IP): vol.All(ipaddress.ip_address, cv.string),
|
||||
vol.Optional(CONF_AUTO_START, default=DEFAULT_AUTO_START): cv.boolean,
|
||||
vol.Optional(CONF_SAFE_MODE, default=DEFAULT_SAFE_MODE): cv.boolean,
|
||||
vol.Optional(CONF_FILTER, default={}): BASE_FILTER_SCHEMA,
|
||||
vol.Optional(CONF_ENTITY_CONFIG, default={}): validate_entity_config,
|
||||
vol.Optional(
|
||||
CONF_ZEROCONF_DEFAULT_INTERFACE, default=DEFAULT_ZEROCONF_DEFAULT_INTERFACE,
|
||||
): cv.boolean,
|
||||
},
|
||||
extra=vol.ALLOW_EXTRA,
|
||||
BRIDGE_SCHEMA = vol.All(
|
||||
cv.deprecated(CONF_ZEROCONF_DEFAULT_INTERFACE),
|
||||
vol.Schema(
|
||||
{
|
||||
vol.Optional(CONF_NAME, default=BRIDGE_NAME): vol.All(
|
||||
cv.string, vol.Length(min=3, max=25)
|
||||
),
|
||||
vol.Optional(CONF_PORT, default=DEFAULT_PORT): cv.port,
|
||||
vol.Optional(CONF_IP_ADDRESS): vol.All(ipaddress.ip_address, cv.string),
|
||||
vol.Optional(CONF_ADVERTISE_IP): vol.All(ipaddress.ip_address, cv.string),
|
||||
vol.Optional(CONF_AUTO_START, default=DEFAULT_AUTO_START): cv.boolean,
|
||||
vol.Optional(CONF_SAFE_MODE, default=DEFAULT_SAFE_MODE): cv.boolean,
|
||||
vol.Optional(CONF_FILTER, default={}): BASE_FILTER_SCHEMA,
|
||||
vol.Optional(CONF_ENTITY_CONFIG, default={}): validate_entity_config,
|
||||
vol.Optional(CONF_ZEROCONF_DEFAULT_INTERFACE): cv.boolean,
|
||||
},
|
||||
extra=vol.ALLOW_EXTRA,
|
||||
),
|
||||
)
|
||||
|
||||
CONFIG_SCHEMA = vol.Schema(
|
||||
@ -233,11 +232,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||
},
|
||||
)
|
||||
)
|
||||
interface_choice = (
|
||||
InterfaceChoice.Default
|
||||
if options.get(CONF_ZEROCONF_DEFAULT_INTERFACE)
|
||||
else None
|
||||
)
|
||||
|
||||
homekit = HomeKit(
|
||||
hass,
|
||||
@ -248,11 +242,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||
entity_config,
|
||||
safe_mode,
|
||||
advertise_ip,
|
||||
interface_choice,
|
||||
entry.entry_id,
|
||||
)
|
||||
await hass.async_add_executor_job(homekit.setup)
|
||||
await homekit.async_setup_zeroconf()
|
||||
zeroconf_instance = await zeroconf.async_get_instance(hass)
|
||||
await hass.async_add_executor_job(homekit.setup, zeroconf_instance)
|
||||
|
||||
undo_listener = entry.add_update_listener(_async_update_listener)
|
||||
|
||||
@ -404,7 +397,6 @@ class HomeKit:
|
||||
entity_config,
|
||||
safe_mode,
|
||||
advertise_ip=None,
|
||||
interface_choice=None,
|
||||
entry_id=None,
|
||||
):
|
||||
"""Initialize a HomeKit object."""
|
||||
@ -416,14 +408,13 @@ class HomeKit:
|
||||
self._config = entity_config
|
||||
self._safe_mode = safe_mode
|
||||
self._advertise_ip = advertise_ip
|
||||
self._interface_choice = interface_choice
|
||||
self._entry_id = entry_id
|
||||
self.status = STATUS_READY
|
||||
|
||||
self.bridge = None
|
||||
self.driver = None
|
||||
|
||||
def setup(self):
|
||||
def setup(self, zeroconf_instance):
|
||||
"""Set up bridge and accessory driver."""
|
||||
# pylint: disable=import-outside-toplevel
|
||||
from .accessories import HomeBridge, HomeDriver
|
||||
@ -440,7 +431,7 @@ class HomeKit:
|
||||
port=self._port,
|
||||
persist_file=persist_file,
|
||||
advertised_address=self._advertise_ip,
|
||||
interface_choice=self._interface_choice,
|
||||
zeroconf_instance=zeroconf_instance,
|
||||
)
|
||||
|
||||
# If we do not load the mac address will be wrong
|
||||
@ -455,12 +446,6 @@ class HomeKit:
|
||||
_LOGGER.debug("Safe_mode selected for %s", self._name)
|
||||
self.driver.safe_mode = True
|
||||
|
||||
async def async_setup_zeroconf(self):
|
||||
"""Share the system zeroconf instance."""
|
||||
# Replace the existing zeroconf instance.
|
||||
await self.hass.async_add_executor_job(self.driver.advertiser.close)
|
||||
self.driver.advertiser = await zeroconf.async_get_instance(self.hass)
|
||||
|
||||
def reset_accessories(self, entity_ids):
|
||||
"""Reset the accessory to load the latest configuration."""
|
||||
aid_storage = self.hass.data[DOMAIN][self._entry_id][AID_STORAGE]
|
||||
|
@ -23,11 +23,9 @@ from .const import (
|
||||
CONF_FILTER,
|
||||
CONF_SAFE_MODE,
|
||||
CONF_VIDEO_CODEC,
|
||||
CONF_ZEROCONF_DEFAULT_INTERFACE,
|
||||
DEFAULT_AUTO_START,
|
||||
DEFAULT_CONFIG_FLOW_PORT,
|
||||
DEFAULT_SAFE_MODE,
|
||||
DEFAULT_ZEROCONF_DEFAULT_INTERFACE,
|
||||
SHORT_BRIDGE_NAME,
|
||||
VIDEO_CODEC_COPY,
|
||||
)
|
||||
@ -227,14 +225,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
|
||||
vol.Optional(
|
||||
CONF_SAFE_MODE,
|
||||
default=self.homekit_options.get(CONF_SAFE_MODE, DEFAULT_SAFE_MODE),
|
||||
): bool,
|
||||
vol.Optional(
|
||||
CONF_ZEROCONF_DEFAULT_INTERFACE,
|
||||
default=self.homekit_options.get(
|
||||
CONF_ZEROCONF_DEFAULT_INTERFACE,
|
||||
DEFAULT_ZEROCONF_DEFAULT_INTERFACE,
|
||||
),
|
||||
): bool,
|
||||
): bool
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -68,7 +68,6 @@ DEFAULT_MAX_WIDTH = 1920
|
||||
DEFAULT_PORT = 51827
|
||||
DEFAULT_CONFIG_FLOW_PORT = 51828
|
||||
DEFAULT_SAFE_MODE = False
|
||||
DEFAULT_ZEROCONF_DEFAULT_INTERFACE = False
|
||||
DEFAULT_VIDEO_CODEC = VIDEO_CODEC_LIBX264
|
||||
DEFAULT_VIDEO_MAP = "0:v:0"
|
||||
DEFAULT_VIDEO_PACKET_SIZE = 1316
|
||||
@ -267,7 +266,6 @@ HK_NOT_CHARGABLE = 2
|
||||
CONFIG_OPTIONS = [
|
||||
CONF_FILTER,
|
||||
CONF_AUTO_START,
|
||||
CONF_ZEROCONF_DEFAULT_INTERFACE,
|
||||
CONF_SAFE_MODE,
|
||||
CONF_ENTITY_CONFIG,
|
||||
]
|
||||
|
@ -30,8 +30,7 @@
|
||||
"advanced": {
|
||||
"data": {
|
||||
"auto_start": "[%key:component::homekit::config::step::user::data::auto_start%]",
|
||||
"safe_mode": "Safe Mode (enable only if pairing fails)",
|
||||
"zeroconf_default_interface": "Use default zeroconf interface (enable if the bridge cannot be found in the Home app)"
|
||||
"safe_mode": "Safe Mode (enable only if pairing fails)"
|
||||
},
|
||||
"description": "These settings only need to be adjusted if the HomeKit bridge is not functional.",
|
||||
"title": "Advanced Configuration"
|
||||
|
@ -23,8 +23,7 @@
|
||||
"advanced": {
|
||||
"data": {
|
||||
"auto_start": "Autostart (disable if using Z-Wave or other delayed start system)",
|
||||
"safe_mode": "Safe Mode (enable only if pairing fails)",
|
||||
"zeroconf_default_interface": "Use default zeroconf interface (enable if the bridge cannot be found in the Home app)"
|
||||
"safe_mode": "Safe Mode (enable only if pairing fails)"
|
||||
},
|
||||
"description": "These settings only need to be adjusted if the HomeKit bridge is not functional.",
|
||||
"title": "Advanced Configuration"
|
||||
|
@ -27,7 +27,6 @@ def _mock_config_entry_with_options_populated():
|
||||
},
|
||||
"auto_start": False,
|
||||
"safe_mode": False,
|
||||
"zeroconf_default_interface": True,
|
||||
},
|
||||
)
|
||||
|
||||
@ -149,12 +148,7 @@ async def test_options_flow_advanced(hass):
|
||||
|
||||
with patch("homeassistant.components.homekit.async_setup_entry", return_value=True):
|
||||
result3 = await hass.config_entries.options.async_configure(
|
||||
result2["flow_id"],
|
||||
user_input={
|
||||
"auto_start": True,
|
||||
"safe_mode": True,
|
||||
"zeroconf_default_interface": False,
|
||||
},
|
||||
result2["flow_id"], user_input={"auto_start": True, "safe_mode": True},
|
||||
)
|
||||
|
||||
assert result3["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||
@ -167,7 +161,6 @@ async def test_options_flow_advanced(hass):
|
||||
"include_entities": [],
|
||||
},
|
||||
"safe_mode": True,
|
||||
"zeroconf_default_interface": False,
|
||||
}
|
||||
|
||||
|
||||
@ -202,8 +195,7 @@ async def test_options_flow_basic(hass):
|
||||
|
||||
with patch("homeassistant.components.homekit.async_setup_entry", return_value=True):
|
||||
result3 = await hass.config_entries.options.async_configure(
|
||||
result2["flow_id"],
|
||||
user_input={"safe_mode": True, "zeroconf_default_interface": False},
|
||||
result2["flow_id"], user_input={"safe_mode": True},
|
||||
)
|
||||
|
||||
assert result3["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||
@ -216,7 +208,6 @@ async def test_options_flow_basic(hass):
|
||||
"include_entities": [],
|
||||
},
|
||||
"safe_mode": True,
|
||||
"zeroconf_default_interface": False,
|
||||
}
|
||||
|
||||
|
||||
@ -264,8 +255,7 @@ async def test_options_flow_with_cameras(hass):
|
||||
|
||||
with patch("homeassistant.components.homekit.async_setup_entry", return_value=True):
|
||||
result4 = await hass.config_entries.options.async_configure(
|
||||
result3["flow_id"],
|
||||
user_input={"safe_mode": True, "zeroconf_default_interface": False},
|
||||
result3["flow_id"], user_input={"safe_mode": True},
|
||||
)
|
||||
|
||||
assert result4["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||
@ -279,7 +269,6 @@ async def test_options_flow_with_cameras(hass):
|
||||
},
|
||||
"entity_config": {"camera.native_h264": {"video_codec": "copy"}},
|
||||
"safe_mode": True,
|
||||
"zeroconf_default_interface": False,
|
||||
}
|
||||
|
||||
# Now run though again and verify we can turn off copy
|
||||
@ -315,8 +304,7 @@ async def test_options_flow_with_cameras(hass):
|
||||
|
||||
with patch("homeassistant.components.homekit.async_setup_entry", return_value=True):
|
||||
result4 = await hass.config_entries.options.async_configure(
|
||||
result3["flow_id"],
|
||||
user_input={"safe_mode": True, "zeroconf_default_interface": False},
|
||||
result3["flow_id"], user_input={"safe_mode": True},
|
||||
)
|
||||
|
||||
assert result4["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||
@ -330,7 +318,6 @@ async def test_options_flow_with_cameras(hass):
|
||||
},
|
||||
"entity_config": {"camera.native_h264": {}},
|
||||
"safe_mode": True,
|
||||
"zeroconf_default_interface": False,
|
||||
}
|
||||
|
||||
|
||||
@ -353,7 +340,6 @@ async def test_options_flow_blocked_when_from_yaml(hass):
|
||||
"exclude_entities": ["climate.front_gate"],
|
||||
},
|
||||
"safe_mode": False,
|
||||
"zeroconf_default_interface": True,
|
||||
},
|
||||
source=SOURCE_IMPORT,
|
||||
)
|
||||
|
@ -2,8 +2,8 @@
|
||||
import os
|
||||
from typing import Dict
|
||||
|
||||
from asynctest import MagicMock
|
||||
import pytest
|
||||
from zeroconf import InterfaceChoice
|
||||
|
||||
from homeassistant.components import zeroconf
|
||||
from homeassistant.components.binary_sensor import (
|
||||
@ -26,10 +26,10 @@ from homeassistant.components.homekit.const import (
|
||||
CONF_AUTO_START,
|
||||
CONF_ENTRY_INDEX,
|
||||
CONF_SAFE_MODE,
|
||||
CONF_ZEROCONF_DEFAULT_INTERFACE,
|
||||
DEFAULT_PORT,
|
||||
DEFAULT_SAFE_MODE,
|
||||
DOMAIN,
|
||||
HOMEKIT,
|
||||
HOMEKIT_FILE,
|
||||
SERVICE_HOMEKIT_RESET_ACCESSORY,
|
||||
SERVICE_HOMEKIT_START,
|
||||
@ -99,7 +99,6 @@ async def test_setup_min(hass):
|
||||
with patch(f"{PATH_HOMEKIT}.HomeKit") as mock_homekit:
|
||||
mock_homekit.return_value = homekit = Mock()
|
||||
type(homekit).async_start = AsyncMock()
|
||||
type(homekit).async_setup_zeroconf = AsyncMock()
|
||||
assert await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
@ -112,7 +111,6 @@ async def test_setup_min(hass):
|
||||
{},
|
||||
DEFAULT_SAFE_MODE,
|
||||
None,
|
||||
None,
|
||||
entry.entry_id,
|
||||
)
|
||||
assert mock_homekit().setup.called is True
|
||||
@ -130,18 +128,13 @@ async def test_setup_auto_start_disabled(hass):
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
data={CONF_NAME: "Test Name", CONF_PORT: 11111, CONF_IP_ADDRESS: "172.0.0.0"},
|
||||
options={
|
||||
CONF_AUTO_START: False,
|
||||
CONF_SAFE_MODE: DEFAULT_SAFE_MODE,
|
||||
CONF_ZEROCONF_DEFAULT_INTERFACE: True,
|
||||
},
|
||||
options={CONF_AUTO_START: False, CONF_SAFE_MODE: DEFAULT_SAFE_MODE},
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
with patch(f"{PATH_HOMEKIT}.HomeKit") as mock_homekit:
|
||||
mock_homekit.return_value = homekit = Mock()
|
||||
type(homekit).async_start = AsyncMock()
|
||||
type(homekit).async_setup_zeroconf = AsyncMock()
|
||||
assert await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
@ -154,7 +147,6 @@ async def test_setup_auto_start_disabled(hass):
|
||||
{},
|
||||
DEFAULT_SAFE_MODE,
|
||||
None,
|
||||
InterfaceChoice.Default,
|
||||
entry.entry_id,
|
||||
)
|
||||
assert mock_homekit().setup.called is True
|
||||
@ -201,15 +193,15 @@ async def test_homekit_setup(hass, hk_driver):
|
||||
{},
|
||||
DEFAULT_SAFE_MODE,
|
||||
advertise_ip=None,
|
||||
interface_choice=None,
|
||||
entry_id=entry.entry_id,
|
||||
)
|
||||
|
||||
zeroconf_mock = MagicMock()
|
||||
with patch(
|
||||
f"{PATH_HOMEKIT}.accessories.HomeDriver", return_value=hk_driver
|
||||
) as mock_driver, patch("homeassistant.util.get_local_ip") as mock_ip:
|
||||
mock_ip.return_value = IP_ADDRESS
|
||||
await hass.async_add_executor_job(homekit.setup)
|
||||
await hass.async_add_executor_job(homekit.setup, zeroconf_mock)
|
||||
|
||||
path = get_persist_fullpath_for_entry_id(hass, entry.entry_id)
|
||||
assert isinstance(homekit.bridge, HomeBridge)
|
||||
@ -221,7 +213,7 @@ async def test_homekit_setup(hass, hk_driver):
|
||||
port=DEFAULT_PORT,
|
||||
persist_file=path,
|
||||
advertised_address=None,
|
||||
interface_choice=None,
|
||||
zeroconf_instance=zeroconf_mock,
|
||||
)
|
||||
assert homekit.driver.safe_mode is False
|
||||
|
||||
@ -245,15 +237,15 @@ async def test_homekit_setup_ip_address(hass, hk_driver):
|
||||
{},
|
||||
None,
|
||||
None,
|
||||
interface_choice=None,
|
||||
entry_id=entry.entry_id,
|
||||
)
|
||||
|
||||
mock_zeroconf = MagicMock()
|
||||
path = get_persist_fullpath_for_entry_id(hass, entry.entry_id)
|
||||
with patch(
|
||||
f"{PATH_HOMEKIT}.accessories.HomeDriver", return_value=hk_driver
|
||||
) as mock_driver:
|
||||
await hass.async_add_executor_job(homekit.setup)
|
||||
await hass.async_add_executor_job(homekit.setup, mock_zeroconf)
|
||||
mock_driver.assert_called_with(
|
||||
hass,
|
||||
entry.entry_id,
|
||||
@ -262,7 +254,7 @@ async def test_homekit_setup_ip_address(hass, hk_driver):
|
||||
port=DEFAULT_PORT,
|
||||
persist_file=path,
|
||||
advertised_address=None,
|
||||
interface_choice=None,
|
||||
zeroconf_instance=mock_zeroconf,
|
||||
)
|
||||
|
||||
|
||||
@ -282,15 +274,15 @@ async def test_homekit_setup_advertise_ip(hass, hk_driver):
|
||||
{},
|
||||
None,
|
||||
"192.168.1.100",
|
||||
interface_choice=None,
|
||||
entry_id=entry.entry_id,
|
||||
)
|
||||
|
||||
zeroconf_instance = MagicMock()
|
||||
path = get_persist_fullpath_for_entry_id(hass, entry.entry_id)
|
||||
with patch(
|
||||
f"{PATH_HOMEKIT}.accessories.HomeDriver", return_value=hk_driver
|
||||
) as mock_driver:
|
||||
await hass.async_add_executor_job(homekit.setup)
|
||||
await hass.async_add_executor_job(homekit.setup, zeroconf_instance)
|
||||
mock_driver.assert_called_with(
|
||||
hass,
|
||||
entry.entry_id,
|
||||
@ -299,44 +291,7 @@ async def test_homekit_setup_advertise_ip(hass, hk_driver):
|
||||
port=DEFAULT_PORT,
|
||||
persist_file=path,
|
||||
advertised_address="192.168.1.100",
|
||||
interface_choice=None,
|
||||
)
|
||||
|
||||
|
||||
async def test_homekit_setup_interface_choice(hass, hk_driver):
|
||||
"""Test setup with interface choice of Default."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
data={CONF_NAME: "mock_name", CONF_PORT: 12345},
|
||||
source=SOURCE_IMPORT,
|
||||
)
|
||||
homekit = HomeKit(
|
||||
hass,
|
||||
BRIDGE_NAME,
|
||||
DEFAULT_PORT,
|
||||
"0.0.0.0",
|
||||
{},
|
||||
{},
|
||||
None,
|
||||
None,
|
||||
InterfaceChoice.Default,
|
||||
entry_id=entry.entry_id,
|
||||
)
|
||||
|
||||
path = get_persist_fullpath_for_entry_id(hass, entry.entry_id)
|
||||
with patch(
|
||||
f"{PATH_HOMEKIT}.accessories.HomeDriver", return_value=hk_driver
|
||||
) as mock_driver:
|
||||
await hass.async_add_executor_job(homekit.setup)
|
||||
mock_driver.assert_called_with(
|
||||
hass,
|
||||
entry.entry_id,
|
||||
BRIDGE_NAME,
|
||||
address="0.0.0.0",
|
||||
port=DEFAULT_PORT,
|
||||
persist_file=path,
|
||||
advertised_address=None,
|
||||
interface_choice=InterfaceChoice.Default,
|
||||
zeroconf_instance=zeroconf_instance,
|
||||
)
|
||||
|
||||
|
||||
@ -356,12 +311,11 @@ async def test_homekit_setup_safe_mode(hass, hk_driver):
|
||||
{},
|
||||
True,
|
||||
advertise_ip=None,
|
||||
interface_choice=None,
|
||||
entry_id=entry.entry_id,
|
||||
)
|
||||
|
||||
with patch(f"{PATH_HOMEKIT}.accessories.HomeDriver", return_value=hk_driver):
|
||||
await hass.async_add_executor_job(homekit.setup)
|
||||
await hass.async_add_executor_job(homekit.setup, MagicMock())
|
||||
assert homekit.driver.safe_mode is True
|
||||
|
||||
|
||||
@ -378,7 +332,6 @@ async def test_homekit_add_accessory(hass):
|
||||
{},
|
||||
DEFAULT_SAFE_MODE,
|
||||
advertise_ip=None,
|
||||
interface_choice=None,
|
||||
entry_id=entry.entry_id,
|
||||
)
|
||||
homekit.driver = "driver"
|
||||
@ -415,7 +368,6 @@ async def test_homekit_remove_accessory(hass):
|
||||
{},
|
||||
DEFAULT_SAFE_MODE,
|
||||
advertise_ip=None,
|
||||
interface_choice=None,
|
||||
entry_id=entry.entry_id,
|
||||
)
|
||||
homekit.driver = "driver"
|
||||
@ -441,7 +393,6 @@ async def test_homekit_entity_filter(hass):
|
||||
{},
|
||||
DEFAULT_SAFE_MODE,
|
||||
advertise_ip=None,
|
||||
interface_choice=None,
|
||||
entry_id=entry.entry_id,
|
||||
)
|
||||
homekit.bridge = Mock()
|
||||
@ -476,7 +427,6 @@ async def test_homekit_start(hass, hk_driver, device_reg, debounce_patcher):
|
||||
{},
|
||||
DEFAULT_SAFE_MODE,
|
||||
advertise_ip=None,
|
||||
interface_choice=None,
|
||||
entry_id=entry.entry_id,
|
||||
)
|
||||
homekit.bridge = Mock()
|
||||
@ -566,7 +516,6 @@ async def test_homekit_start_with_a_broken_accessory(hass, hk_driver, debounce_p
|
||||
{},
|
||||
DEFAULT_SAFE_MODE,
|
||||
advertise_ip=None,
|
||||
interface_choice=None,
|
||||
entry_id=entry.entry_id,
|
||||
)
|
||||
|
||||
@ -612,7 +561,6 @@ async def test_homekit_stop(hass):
|
||||
{},
|
||||
DEFAULT_SAFE_MODE,
|
||||
advertise_ip=None,
|
||||
interface_choice=None,
|
||||
entry_id=entry.entry_id,
|
||||
)
|
||||
homekit.driver = Mock()
|
||||
@ -653,7 +601,6 @@ async def test_homekit_reset_accessories(hass):
|
||||
{entity_id: {}},
|
||||
DEFAULT_SAFE_MODE,
|
||||
advertise_ip=None,
|
||||
interface_choice=None,
|
||||
entry_id=entry.entry_id,
|
||||
)
|
||||
homekit.bridge = Mock()
|
||||
@ -702,7 +649,6 @@ async def test_homekit_too_many_accessories(hass, hk_driver):
|
||||
{},
|
||||
DEFAULT_SAFE_MODE,
|
||||
advertise_ip=None,
|
||||
interface_choice=None,
|
||||
entry_id=entry.entry_id,
|
||||
)
|
||||
homekit.bridge = Mock()
|
||||
@ -737,7 +683,6 @@ async def test_homekit_finds_linked_batteries(
|
||||
{"light.demo": {}},
|
||||
DEFAULT_SAFE_MODE,
|
||||
advertise_ip=None,
|
||||
interface_choice=None,
|
||||
entry_id=entry.entry_id,
|
||||
)
|
||||
homekit.driver = hk_driver
|
||||
@ -832,7 +777,6 @@ async def test_setup_imported(hass):
|
||||
with patch(f"{PATH_HOMEKIT}.HomeKit") as mock_homekit:
|
||||
mock_homekit.return_value = homekit = Mock()
|
||||
type(homekit).async_start = AsyncMock()
|
||||
type(homekit).async_setup_zeroconf = AsyncMock()
|
||||
assert await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
@ -845,7 +789,6 @@ async def test_setup_imported(hass):
|
||||
{},
|
||||
DEFAULT_SAFE_MODE,
|
||||
None,
|
||||
None,
|
||||
entry.entry_id,
|
||||
)
|
||||
assert mock_homekit().setup.called is True
|
||||
@ -887,7 +830,6 @@ async def test_yaml_updates_update_config_entry_for_name(hass):
|
||||
with patch(f"{PATH_HOMEKIT}.HomeKit") as mock_homekit:
|
||||
mock_homekit.return_value = homekit = Mock()
|
||||
type(homekit).async_start = AsyncMock()
|
||||
type(homekit).async_setup_zeroconf = AsyncMock()
|
||||
assert await async_setup_component(
|
||||
hass, "homekit", {"homekit": {CONF_NAME: BRIDGE_NAME, CONF_PORT: 12345}}
|
||||
)
|
||||
@ -902,7 +844,6 @@ async def test_yaml_updates_update_config_entry_for_name(hass):
|
||||
{},
|
||||
DEFAULT_SAFE_MODE,
|
||||
None,
|
||||
None,
|
||||
entry.entry_id,
|
||||
)
|
||||
assert mock_homekit().setup.called is True
|
||||
@ -932,7 +873,7 @@ async def test_raise_config_entry_not_ready(hass):
|
||||
await hass.async_block_till_done()
|
||||
|
||||
|
||||
async def test_homekit_uses_system_zeroconf(hass, hk_driver, mock_zeroconf):
|
||||
async def test_homekit_uses_system_zeroconf(hass, mock_zeroconf):
|
||||
"""Test HomeKit uses system zeroconf."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
@ -941,13 +882,15 @@ async def test_homekit_uses_system_zeroconf(hass, hk_driver, mock_zeroconf):
|
||||
)
|
||||
system_zc = await zeroconf.async_get_instance(hass)
|
||||
|
||||
with patch(f"{PATH_HOMEKIT}.accessories.HomeDriver", return_value=hk_driver), patch(
|
||||
f"{PATH_HOMEKIT}.HomeKit.async_start"
|
||||
with patch(f"{PATH_HOMEKIT}.HomeKit.add_bridge_accessory"), patch(
|
||||
f"{PATH_HOMEKIT}.show_setup_message"
|
||||
), patch("pyhap.accessory_driver.AccessoryDriver.add_accessory"), patch(
|
||||
"pyhap.accessory_driver.AccessoryDriver.start"
|
||||
):
|
||||
entry.add_to_hass(hass)
|
||||
assert await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
assert hk_driver.advertiser == system_zc
|
||||
assert hass.data[DOMAIN][entry.entry_id][HOMEKIT].driver.advertiser == system_zc
|
||||
|
||||
|
||||
def _write_data(path: str, data: Dict) -> None:
|
||||
@ -972,7 +915,6 @@ async def test_homekit_ignored_missing_devices(
|
||||
{"light.demo": {}},
|
||||
DEFAULT_SAFE_MODE,
|
||||
advertise_ip=None,
|
||||
interface_choice=None,
|
||||
entry_id=entry.entry_id,
|
||||
)
|
||||
homekit.driver = hk_driver
|
||||
@ -1052,7 +994,6 @@ async def test_homekit_finds_linked_motion_sensors(
|
||||
{"camera.camera_demo": {}},
|
||||
DEFAULT_SAFE_MODE,
|
||||
advertise_ip=None,
|
||||
interface_choice=None,
|
||||
entry_id=entry.entry_id,
|
||||
)
|
||||
homekit.driver = hk_driver
|
||||
|
Loading…
x
Reference in New Issue
Block a user