mirror of
https://github.com/home-assistant/core.git
synced 2025-06-11 08:37:09 +00:00
Allow wemo config entry to be unloaded (#93082)
* Fix lingering timer in wemo * Also stop the subscriptions
This commit is contained in:
parent
36332eb441
commit
f6b700372a
@ -113,7 +113,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
wemo_dispatcher = WemoDispatcher(entry)
|
wemo_dispatcher = WemoDispatcher(entry)
|
||||||
wemo_discovery = WemoDiscovery(hass, wemo_dispatcher, static_conf)
|
wemo_discovery = WemoDiscovery(hass, wemo_dispatcher, static_conf)
|
||||||
|
|
||||||
async def async_stop_wemo(event: Event) -> None:
|
async def async_stop_wemo(_: Event | None = None) -> None:
|
||||||
"""Shutdown Wemo subscriptions and subscription thread on exit."""
|
"""Shutdown Wemo subscriptions and subscription thread on exit."""
|
||||||
_LOGGER.debug("Shutting down WeMo event subscriptions")
|
_LOGGER.debug("Shutting down WeMo event subscriptions")
|
||||||
await hass.async_add_executor_job(registry.stop)
|
await hass.async_add_executor_job(registry.stop)
|
||||||
@ -123,6 +123,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
entry.async_on_unload(
|
entry.async_on_unload(
|
||||||
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, async_stop_wemo)
|
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, async_stop_wemo)
|
||||||
)
|
)
|
||||||
|
entry.async_on_unload(async_stop_wemo)
|
||||||
|
|
||||||
# Need to do this at least once in case statistics are defined and discovery is disabled
|
# Need to do this at least once in case statistics are defined and discovery is disabled
|
||||||
await wemo_discovery.discover_statics()
|
await wemo_discovery.discover_statics()
|
||||||
@ -133,6 +134,12 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
|
"""Unload a wemo config entry."""
|
||||||
|
# This makes sure that `entry.async_on_unload` routines run correctly on unload
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
class WemoDispatcher:
|
class WemoDispatcher:
|
||||||
"""Dispatch WeMo devices to the correct platform."""
|
"""Dispatch WeMo devices to the correct platform."""
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user