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 Franck Nijhof
parent 554cdd1784
commit fea3dfda94
No known key found for this signature in database
GPG Key ID: D62583BA8AB11CA3

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)