diff --git a/homeassistant/components/daikin/config_flow.py b/homeassistant/components/daikin/config_flow.py index b9956a87af0..155fdd18376 100644 --- a/homeassistant/components/daikin/config_flow.py +++ b/homeassistant/components/daikin/config_flow.py @@ -12,7 +12,7 @@ import voluptuous as vol from homeassistant import config_entries from homeassistant.const import CONF_API_KEY, CONF_HOST, CONF_PASSWORD -from .const import CONF_UUID, KEY_IP, KEY_MAC, TIMEOUT +from .const import CONF_UUID, KEY_MAC, TIMEOUT _LOGGER = logging.getLogger(__name__) @@ -124,14 +124,6 @@ class FlowHandler(config_entries.ConfigFlow): return await self.async_step_user() return await self._create_device(host) - async def async_step_discovery(self, discovery_info): - """Initialize step from discovery.""" - _LOGGER.debug("Discovered device: %s", discovery_info) - await self.async_set_unique_id(discovery_info[KEY_MAC]) - self._abort_if_unique_id_configured() - self.host = discovery_info[KEY_IP] - return await self.async_step_user() - async def async_step_zeroconf(self, discovery_info): """Prepare configuration for a discovered Daikin device.""" _LOGGER.debug("Zeroconf user_input: %s", discovery_info) diff --git a/homeassistant/components/discovery/__init__.py b/homeassistant/components/discovery/__init__.py index 2b293179888..0a3deeef33b 100644 --- a/homeassistant/components/discovery/__init__.py +++ b/homeassistant/components/discovery/__init__.py @@ -38,25 +38,17 @@ SERVICE_WEMO = "belkin_wemo" SERVICE_WINK = "wink" SERVICE_XIAOMI_GW = "xiaomi_gw" +# These have custom protocols CONFIG_ENTRY_HANDLERS = { - SERVICE_DAIKIN: "daikin", SERVICE_TELLDUSLIVE: "tellduslive", "logitech_mediaserver": "squeezebox", } +# These have no config flows SERVICE_HANDLERS = { - SERVICE_MOBILE_APP: ("mobile_app", None), - SERVICE_HASS_IOS_APP: ("ios", None), SERVICE_NETGEAR: ("device_tracker", None), - SERVICE_HASSIO: ("hassio", None), - SERVICE_APPLE_TV: ("apple_tv", None), SERVICE_ENIGMA2: ("media_player", "enigma2"), - SERVICE_WINK: ("wink", None), SERVICE_SABNZBD: ("sabnzbd", None), - SERVICE_SAMSUNG_PRINTER: ("sensor", None), - SERVICE_KONNECTED: ("konnected", None), - SERVICE_OCTOPRINT: ("octoprint", None), - SERVICE_FREEBOX: ("freebox", None), "yamaha": ("media_player", "yamaha"), "frontier_silicon": ("media_player", "frontier_silicon"), "openhome": ("media_player", "openhome"), @@ -69,20 +61,30 @@ SERVICE_HANDLERS = { OPTIONAL_SERVICE_HANDLERS = {SERVICE_DLNA_DMR: ("media_player", "dlna_dmr")} MIGRATED_SERVICE_HANDLERS = [ + SERVICE_APPLE_TV, "axis", "deconz", + SERVICE_DAIKIN, "denonavr", "esphome", + SERVICE_FREEBOX, "google_cast", + SERVICE_HASS_IOS_APP, + SERVICE_HASSIO, SERVICE_HEOS, "harmony", "homekit", "ikea_tradfri", "kodi", + SERVICE_KONNECTED, + SERVICE_MOBILE_APP, + SERVICE_OCTOPRINT, "philips_hue", + SERVICE_SAMSUNG_PRINTER, "sonos", "songpal", SERVICE_WEMO, + SERVICE_WINK, SERVICE_XIAOMI_GW, "volumio", SERVICE_YEELIGHT, diff --git a/homeassistant/components/freebox/__init__.py b/homeassistant/components/freebox/__init__.py index 9120c7d0866..35e89eb2b09 100644 --- a/homeassistant/components/freebox/__init__.py +++ b/homeassistant/components/freebox/__init__.py @@ -4,10 +4,9 @@ import logging import voluptuous as vol -from homeassistant.components.discovery import SERVICE_FREEBOX -from homeassistant.config_entries import SOURCE_DISCOVERY, SOURCE_IMPORT, ConfigEntry +from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry from homeassistant.const import CONF_HOST, CONF_PORT, EVENT_HOMEASSISTANT_STOP -from homeassistant.helpers import config_validation as cv, discovery +from homeassistant.helpers import config_validation as cv from homeassistant.helpers.typing import HomeAssistantType from .const import DOMAIN, PLATFORMS @@ -29,21 +28,6 @@ async def async_setup(hass, config): """Set up the Freebox component.""" conf = config.get(DOMAIN) - async def discovery_dispatch(service, discovery_info): - if conf is None: - host = discovery_info.get("properties", {}).get("api_domain") - port = discovery_info.get("properties", {}).get("https_port") - _LOGGER.info("Discovered Freebox server: %s:%s", host, port) - hass.async_create_task( - hass.config_entries.flow.async_init( - DOMAIN, - context={"source": SOURCE_DISCOVERY}, - data={CONF_HOST: host, CONF_PORT: port}, - ) - ) - - discovery.async_listen(hass, SERVICE_FREEBOX, discovery_dispatch) - if conf is None: return True diff --git a/homeassistant/components/freebox/config_flow.py b/homeassistant/components/freebox/config_flow.py index 2ee52884c88..49354f16705 100644 --- a/homeassistant/components/freebox/config_flow.py +++ b/homeassistant/components/freebox/config_flow.py @@ -105,7 +105,3 @@ class FreeboxFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_import(self, user_input=None): """Import a config entry.""" return await self.async_step_user(user_input) - - async def async_step_discovery(self, discovery_info): - """Initialize step from discovery.""" - return await self.async_step_user(discovery_info) diff --git a/homeassistant/components/freebox/manifest.json b/homeassistant/components/freebox/manifest.json index 2739849b547..e6a7a17a119 100644 --- a/homeassistant/components/freebox/manifest.json +++ b/homeassistant/components/freebox/manifest.json @@ -4,6 +4,6 @@ "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/freebox", "requirements": ["freebox-api==0.0.9"], - "after_dependencies": ["discovery"], + "zeroconf": ["_fbx-api._tcp.local."], "codeowners": ["@hacf-fr", "@Quentame"] } diff --git a/homeassistant/generated/zeroconf.py b/homeassistant/generated/zeroconf.py index 5521ab9da8f..d3a976e78ea 100644 --- a/homeassistant/generated/zeroconf.py +++ b/homeassistant/generated/zeroconf.py @@ -59,6 +59,11 @@ ZEROCONF = { "domain": "esphome" } ], + "_fbx-api._tcp.local.": [ + { + "domain": "freebox" + } + ], "_googlecast._tcp.local.": [ { "domain": "cast" diff --git a/tests/components/daikin/test_config_flow.py b/tests/components/daikin/test_config_flow.py index a7165b2cb9b..076f9f54878 100644 --- a/tests/components/daikin/test_config_flow.py +++ b/tests/components/daikin/test_config_flow.py @@ -7,13 +7,8 @@ from aiohttp import ClientError from aiohttp.web_exceptions import HTTPForbidden import pytest -from homeassistant.components.daikin.const import KEY_IP, KEY_MAC -from homeassistant.config_entries import ( - SOURCE_DISCOVERY, - SOURCE_IMPORT, - SOURCE_USER, - SOURCE_ZEROCONF, -) +from homeassistant.components.daikin.const import KEY_MAC +from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_USER, SOURCE_ZEROCONF from homeassistant.const import CONF_HOST from homeassistant.data_entry_flow import ( RESULT_TYPE_ABORT, @@ -132,7 +127,6 @@ async def test_device_abort(hass, mock_daikin, s_effect, reason): @pytest.mark.parametrize( "source, data, unique_id", [ - (SOURCE_DISCOVERY, {KEY_IP: HOST, KEY_MAC: MAC}, MAC), (SOURCE_ZEROCONF, {CONF_HOST: HOST}, MAC), ], ) diff --git a/tests/components/discovery/test_init.py b/tests/components/discovery/test_init.py index 2c1e41e8285..4dd77c98187 100644 --- a/tests/components/discovery/test_init.py +++ b/tests/components/discovery/test_init.py @@ -16,8 +16,8 @@ from tests.common import async_fire_time_changed, mock_coro SERVICE = "yamaha" SERVICE_COMPONENT = "media_player" -SERVICE_NO_PLATFORM = "hass_ios" -SERVICE_NO_PLATFORM_COMPONENT = "ios" +SERVICE_NO_PLATFORM = "netgear_router" +SERVICE_NO_PLATFORM_COMPONENT = "device_tracker" SERVICE_INFO = {"key": "value"} # Can be anything UNKNOWN_SERVICE = "this_service_will_never_be_supported" @@ -39,7 +39,7 @@ async def mock_discovery(hass, discoveries, config=BASE_CONFIG): with patch("homeassistant.components.zeroconf.async_get_instance"), patch( "homeassistant.components.zeroconf.async_setup", return_value=True ), patch.object(discovery, "_discover", discoveries), patch( - "homeassistant.components.discovery.async_discover", return_value=mock_coro() + "homeassistant.components.discovery.async_discover" ) as mock_discover, patch( "homeassistant.components.discovery.async_load_platform", return_value=mock_coro(), diff --git a/tests/components/freebox/test_config_flow.py b/tests/components/freebox/test_config_flow.py index 197be7bd3a6..ad935c47cc4 100644 --- a/tests/components/freebox/test_config_flow.py +++ b/tests/components/freebox/test_config_flow.py @@ -10,7 +10,7 @@ import pytest from homeassistant import data_entry_flow from homeassistant.components.freebox.const import DOMAIN -from homeassistant.config_entries import SOURCE_DISCOVERY, SOURCE_IMPORT, SOURCE_USER +from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_USER from homeassistant.const import CONF_HOST, CONF_PORT from tests.common import MockConfigEntry @@ -66,17 +66,6 @@ async def test_import(hass): assert result["step_id"] == "link" -async def test_discovery(hass): - """Test discovery step.""" - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": SOURCE_DISCOVERY}, - data={CONF_HOST: HOST, CONF_PORT: PORT}, - ) - assert result["type"] == data_entry_flow.RESULT_TYPE_FORM - assert result["step_id"] == "link" - - async def test_link(hass, connect): """Test linking.""" result = await hass.config_entries.flow.async_init(