Skip to content

Commit

Permalink
Allow wemo config entry to be unloaded (home-assistant#93082)
Browse files Browse the repository at this point in the history
* Fix lingering timer in wemo

* Also stop the subscriptions
  • Loading branch information
epenet authored May 16, 2023
1 parent 36332eb commit f6b7003
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion homeassistant/components/wemo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
wemo_dispatcher = WemoDispatcher(entry)
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."""
_LOGGER.debug("Shutting down WeMo event subscriptions")
await hass.async_add_executor_job(registry.stop)
Expand All @@ -123,6 +123,7 @@ async def async_stop_wemo(event: Event) -> None:
entry.async_on_unload(
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
await wemo_discovery.discover_statics()
Expand All @@ -133,6 +134,12 @@ async def async_stop_wemo(event: Event) -> None:
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:
"""Dispatch WeMo devices to the correct platform."""

Expand Down

0 comments on commit f6b7003

Please sign in to comment.