From 70b29dc823dd8929634c51dd4af16f643632a6cc Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 10 May 2020 14:30:54 -0500 Subject: [PATCH] Make interface_choice option effective (#35444) I missed the second commit that actually makes this work in the original merge. --- homeassistant/components/zeroconf/__init__.py | 2 +- tests/components/zeroconf/test_init.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/zeroconf/__init__.py b/homeassistant/components/zeroconf/__init__.py index 2e4bb9af30a..c804fb6b642 100644 --- a/homeassistant/components/zeroconf/__init__.py +++ b/homeassistant/components/zeroconf/__init__.py @@ -56,7 +56,7 @@ CONFIG_SCHEMA = vol.Schema( def setup(hass, config): """Set up Zeroconf and make Home Assistant discoverable.""" - if config.get(CONF_DEFAULT_INTERFACE): + if DOMAIN in config and config[DOMAIN].get(CONF_DEFAULT_INTERFACE): zeroconf = Zeroconf(interfaces=InterfaceChoice.Default) else: zeroconf = Zeroconf() diff --git a/tests/components/zeroconf/test_init.py b/tests/components/zeroconf/test_init.py index eaa4c5ee61a..bd74b3c2b8d 100644 --- a/tests/components/zeroconf/test_init.py +++ b/tests/components/zeroconf/test_init.py @@ -92,6 +92,19 @@ async def test_setup_with_default_interface(hass, mock_zeroconf): assert mock_zeroconf.called_with(interface_choice=InterfaceChoice.Default) +async def test_setup_without_default_interface(hass, mock_zeroconf): + """Test without default interface config.""" + with patch.object(hass.config_entries.flow, "async_init"), patch.object( + zeroconf, "ServiceBrowser", side_effect=service_update_mock + ): + mock_zeroconf.get_service_info.side_effect = get_service_info_mock + assert await async_setup_component( + hass, zeroconf.DOMAIN, {zeroconf.DOMAIN: {CONF_DEFAULT_INTERFACE: False}} + ) + + assert mock_zeroconf.called_with() + + async def test_homekit_match_partial_space(hass, mock_zeroconf): """Test configured options for a device are loaded via config entry.""" with patch.dict(