Only create one executor job to shutdown wemo (#113836)

Currently we created two but the work can be done in a single job
This commit is contained in:
J. Nick Koston 2024-03-19 13:59:37 -10:00 committed by GitHub
parent ec3db0a6aa
commit b26f0bc488
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -92,11 +92,13 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
discovery_responder = pywemo.ssdp.DiscoveryResponder(registry.port) discovery_responder = pywemo.ssdp.DiscoveryResponder(registry.port)
await hass.async_add_executor_job(discovery_responder.start) await hass.async_add_executor_job(discovery_responder.start)
async def _on_hass_stop(_: Event) -> None: def _on_hass_stop(_: Event) -> None:
await hass.async_add_executor_job(discovery_responder.stop) discovery_responder.stop()
await hass.async_add_executor_job(registry.stop) registry.stop()
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, _on_hass_stop) hass.bus.async_listen_once(
EVENT_HOMEASSISTANT_STOP, _on_hass_stop, run_immediately=True
)
yaml_config = config.get(DOMAIN, {}) yaml_config = config.get(DOMAIN, {})
hass.data[DOMAIN] = WemoData( hass.data[DOMAIN] = WemoData(