From 3a68a0a67f5cd36222c6cc0e9869e10181afa4e0 Mon Sep 17 00:00:00 2001 From: cdnninja Date: Wed, 1 Jan 2025 05:03:39 -0700 Subject: [PATCH] Vesync unload error when not all platforms used (#134166) --- homeassistant/components/vesync/__init__.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/vesync/__init__.py b/homeassistant/components/vesync/__init__.py index b6f263f3037..0993743d461 100644 --- a/homeassistant/components/vesync/__init__.py +++ b/homeassistant/components/vesync/__init__.py @@ -135,7 +135,18 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Unload a config entry.""" - unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS) + in_use_platforms = [] + if hass.data[DOMAIN][VS_SWITCHES]: + in_use_platforms.append(Platform.SWITCH) + if hass.data[DOMAIN][VS_FANS]: + in_use_platforms.append(Platform.FAN) + if hass.data[DOMAIN][VS_LIGHTS]: + in_use_platforms.append(Platform.LIGHT) + if hass.data[DOMAIN][VS_SENSORS]: + in_use_platforms.append(Platform.SENSOR) + unload_ok = await hass.config_entries.async_unload_platforms( + entry, in_use_platforms + ) if unload_ok: hass.data.pop(DOMAIN)