From 502939c43045560c6c40ff63df3eae0eb65642d5 Mon Sep 17 00:00:00 2001 From: Maciej Bieniek Date: Tue, 8 Jun 2021 13:23:25 +0200 Subject: [PATCH] Do not configure Shelly config entry created by custom component (#51616) --- homeassistant/components/shelly/__init__.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/homeassistant/components/shelly/__init__.py b/homeassistant/components/shelly/__init__.py index 4d7b8654720..425ff11399b 100644 --- a/homeassistant/components/shelly/__init__.py +++ b/homeassistant/components/shelly/__init__.py @@ -68,6 +68,18 @@ async def async_setup(hass: HomeAssistant, config: dict): async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up Shelly from a config entry.""" + # The custom component for Shelly devices uses shelly domain as well as core + # integration. If the user removes the custom component but doesn't remove the + # config entry, core integration will try to configure that config entry with an + # error. The config entry data for this custom component doesn't contain host + # value, so if host isn't present, config entry will not be configured. + if not entry.data.get(CONF_HOST): + _LOGGER.warning( + "The config entry %s probably comes from a custom integration, please remove it if you want to use core Shelly integration", + entry.title, + ) + return False + hass.data[DOMAIN][DATA_CONFIG_ENTRY][entry.entry_id] = {} hass.data[DOMAIN][DATA_CONFIG_ENTRY][entry.entry_id][DEVICE] = None