From 1e6babe79615f7aacccbe09a895e6ad6a5adaaae Mon Sep 17 00:00:00 2001 From: Jc2k Date: Thu, 2 May 2019 15:57:42 +0100 Subject: [PATCH] Loosen discovery config validation to avoid breaking changes (#23625) * Allow optional service handlers to be promoted to config flow without a breaking change * Updated wording * Remove period --- homeassistant/components/discovery/__init__.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/discovery/__init__.py b/homeassistant/components/discovery/__init__.py index 7490b530926..900cbda74d4 100644 --- a/homeassistant/components/discovery/__init__.py +++ b/homeassistant/components/discovery/__init__.py @@ -105,16 +105,19 @@ OPTIONAL_SERVICE_HANDLERS = { SERVICE_DLNA_DMR: ('media_player', 'dlna_dmr'), } +DEFAULT_ENABLED = list(CONFIG_ENTRY_HANDLERS) + list(SERVICE_HANDLERS) +DEFAULT_DISABLED = list(OPTIONAL_SERVICE_HANDLERS) + CONF_IGNORE = 'ignore' CONF_ENABLE = 'enable' CONFIG_SCHEMA = vol.Schema({ vol.Optional(DOMAIN): vol.Schema({ vol.Optional(CONF_IGNORE, default=[]): - vol.All(cv.ensure_list, [ - vol.In(list(CONFIG_ENTRY_HANDLERS) + list(SERVICE_HANDLERS))]), + vol.All(cv.ensure_list, [vol.In(DEFAULT_ENABLED)]), vol.Optional(CONF_ENABLE, default=[]): - vol.All(cv.ensure_list, [vol.In(OPTIONAL_SERVICE_HANDLERS)]) + vol.All(cv.ensure_list, [ + vol.In(DEFAULT_DISABLED + DEFAULT_ENABLED)]), }), }, extra=vol.ALLOW_EXTRA) @@ -140,6 +143,14 @@ async def async_setup(hass, config): ignored_platforms = [] enabled_platforms = [] + for platform in enabled_platforms: + if platform in DEFAULT_ENABLED: + logger.warning( + "Please remove %s from your discovery.enable configuration " + "as it is now enabled by default", + platform, + ) + async def new_service_found(service, info): """Handle a new service if one is found.""" if service in ignored_platforms: