Fixed restoring entity state when reloading
This commit is contained in:
@@ -288,11 +288,6 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
|
|||||||
"""Unload a config entry."""
|
"""Unload a config entry."""
|
||||||
platforms = {}
|
platforms = {}
|
||||||
|
|
||||||
hass.data[DOMAIN][entry.entry_id][UNSUB_LISTENER]()
|
|
||||||
for dev_id, device in hass.data[DOMAIN][TUYA_DEVICES].items():
|
|
||||||
if device.connected:
|
|
||||||
await device.close()
|
|
||||||
|
|
||||||
for dev_id, dev_entry in entry.data[CONF_DEVICES].items():
|
for dev_id, dev_entry in entry.data[CONF_DEVICES].items():
|
||||||
for entity in dev_entry[CONF_ENTITIES]:
|
for entity in dev_entry[CONF_ENTITIES]:
|
||||||
platforms[entity[CONF_PLATFORM]] = True
|
platforms[entity[CONF_PLATFORM]] = True
|
||||||
@@ -305,6 +300,12 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
hass.data[DOMAIN][entry.entry_id][UNSUB_LISTENER]()
|
||||||
|
for dev_id, device in hass.data[DOMAIN][TUYA_DEVICES].items():
|
||||||
|
if device.connected:
|
||||||
|
await device.close()
|
||||||
|
|
||||||
if unload_ok:
|
if unload_ok:
|
||||||
hass.data[DOMAIN][TUYA_DEVICES] = {}
|
hass.data[DOMAIN][TUYA_DEVICES] = {}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user