From 00db97a765460f2961d7823a0ed9ec83f38e0bdd Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 5 Apr 2024 15:59:27 -1000 Subject: [PATCH] Run device_registry stop listener immediately (#114978) --- homeassistant/helpers/device_registry.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/homeassistant/helpers/device_registry.py b/homeassistant/helpers/device_registry.py index 2c160262c50..aa172c7e35b 100644 --- a/homeassistant/helpers/device_registry.py +++ b/homeassistant/helpers/device_registry.py @@ -1259,7 +1259,9 @@ def async_setup_cleanup(hass: HomeAssistant, dev_reg: DeviceRegistry) -> None: """Cancel debounced cleanup.""" debounced_cleanup.async_cancel() - hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, _on_homeassistant_stop) + hass.bus.async_listen_once( + EVENT_HOMEASSISTANT_STOP, _on_homeassistant_stop, run_immediately=True + ) def _normalize_connections(connections: set[tuple[str, str]]) -> set[tuple[str, str]]: