Vesync unload error when not all platforms used (#134166)

This commit is contained in:
cdnninja 2025-01-01 05:03:39 -07:00 committed by GitHub
parent 7ab2d2e07a
commit 3a68a0a67f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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)