diff --git a/homeassistant/components/discovery/__init__.py b/homeassistant/components/discovery/__init__.py index 130898018d5..466d9d40d07 100644 --- a/homeassistant/components/discovery/__init__.py +++ b/homeassistant/components/discovery/__init__.py @@ -34,7 +34,6 @@ SERVICE_HASSIO = 'hassio' SERVICE_HOMEKIT = 'homekit' SERVICE_HEOS = 'heos' SERVICE_IGD = 'igd' -SERVICE_IKEA_TRADFRI = 'ikea_tradfri' SERVICE_KONNECTED = 'konnected' SERVICE_MOBILE_APP = 'hass_mobile_app' SERVICE_NETGEAR = 'netgear_router' @@ -54,7 +53,6 @@ CONFIG_ENTRY_HANDLERS = { 'google_cast': 'cast', SERVICE_HEOS: 'heos', SERVICE_TELLDUSLIVE: 'tellduslive', - SERVICE_IKEA_TRADFRI: 'tradfri', 'sonos': 'sonos', SERVICE_IGD: 'upnp', SERVICE_HOMEKIT: 'homekit_controller', diff --git a/homeassistant/components/tradfri/config_flow.py b/homeassistant/components/tradfri/config_flow.py index bbbe104f296..76f6a8f5764 100644 --- a/homeassistant/components/tradfri/config_flow.py +++ b/homeassistant/components/tradfri/config_flow.py @@ -76,8 +76,8 @@ class FlowHandler(config_entries.ConfigFlow): errors=errors, ) - async def async_step_discovery(self, user_input): - """Handle discovery.""" + async def async_step_zeroconf(self, user_input): + """Handle zeroconf discovery.""" for entry in self._async_current_entries(): if entry.data[CONF_HOST] == user_input['host']: return self.async_abort( diff --git a/homeassistant/components/tradfri/manifest.json b/homeassistant/components/tradfri/manifest.json index c9a4fca3dc9..aba3805a4aa 100644 --- a/homeassistant/components/tradfri/manifest.json +++ b/homeassistant/components/tradfri/manifest.json @@ -7,6 +7,7 @@ "pytradfri[async]==6.0.1" ], "dependencies": [], + "zeroconf": ["_coap._udp.local."], "codeowners": [ "@ggravlingen" ] diff --git a/homeassistant/generated/zeroconf.py b/homeassistant/generated/zeroconf.py index f009132228c..434a463dc17 100644 --- a/homeassistant/generated/zeroconf.py +++ b/homeassistant/generated/zeroconf.py @@ -8,6 +8,9 @@ SERVICE_TYPES = { "_axis-video._tcp.local.": [ "axis" ], + "_coap._udp.local.": [ + "tradfri" + ], "_esphomelib._tcp.local.": [ "esphome" ] diff --git a/script/hassfest/zeroconf.py b/script/hassfest/zeroconf.py index 9cec4a7211b..390429c3da7 100644 --- a/script/hassfest/zeroconf.py +++ b/script/hassfest/zeroconf.py @@ -63,7 +63,8 @@ def validate(integrations: Dict[str, Integration], config: Config): config.cache['zeroconf'] = content = generate_and_validate(integrations) with open(str(zeroconf_path), 'r') as fp: - if fp.read().strip() != content: + current = fp.read().strip() + if current != content: config.add_error( "zeroconf", "File zeroconf.py is not up to date. " diff --git a/tests/components/tradfri/test_config_flow.py b/tests/components/tradfri/test_config_flow.py index 6756a01bbc7..8fcc72dd4a5 100644 --- a/tests/components/tradfri/test_config_flow.py +++ b/tests/components/tradfri/test_config_flow.py @@ -99,7 +99,7 @@ async def test_discovery_connection(hass, mock_auth, mock_entry_setup): }) flow = await hass.config_entries.flow.async_init( - 'tradfri', context={'source': 'discovery'}, data={ + 'tradfri', context={'source': 'zeroconf'}, data={ 'host': '123.123.123.123' }) @@ -249,7 +249,7 @@ async def test_discovery_duplicate_aborted(hass): ).add_to_hass(hass) flow = await hass.config_entries.flow.async_init( - 'tradfri', context={'source': 'discovery'}, data={ + 'tradfri', context={'source': 'zeroconf'}, data={ 'host': 'some-host' }) diff --git a/tests/components/zeroconf/test_init.py b/tests/components/zeroconf/test_init.py index 0596d5e0ed5..106cf3377f4 100644 --- a/tests/components/zeroconf/test_init.py +++ b/tests/components/zeroconf/test_init.py @@ -3,6 +3,7 @@ from unittest.mock import patch from aiozeroconf import ServiceInfo, ServiceStateChange +from homeassistant.generated import zeroconf as zc_gen from homeassistant.setup import async_setup_component from homeassistant.components import zeroconf @@ -36,5 +37,5 @@ async def test_setup(hass): hass, zeroconf.DOMAIN, {zeroconf.DOMAIN: {}}) await hass.async_block_till_done() - assert len(MockServiceBrowser.mock_calls) == 2 - assert len(mock_config_flow.mock_calls) == 2 + assert len(MockServiceBrowser.mock_calls) == len(zc_gen.SERVICE_TYPES) + assert len(mock_config_flow.mock_calls) == len(zc_gen.SERVICE_TYPES)