From 20ead7902a343397a1b8347e6f78a8a2a5b2df7b Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 20 Apr 2021 06:17:08 -1000 Subject: [PATCH] Fix memory leak in ambient_station on reload (#49455) --- homeassistant/components/ambient_station/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/ambient_station/__init__.py b/homeassistant/components/ambient_station/__init__.py index 9d3359ca981..4879f68f079 100644 --- a/homeassistant/components/ambient_station/__init__.py +++ b/homeassistant/components/ambient_station/__init__.py @@ -355,7 +355,11 @@ async def async_setup_entry(hass, config_entry): async def _async_disconnect_websocket(*_): await ambient.client.websocket.disconnect() - hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, _async_disconnect_websocket) + config_entry.async_on_unload( + hass.bus.async_listen_once( + EVENT_HOMEASSISTANT_STOP, _async_disconnect_websocket + ) + ) return True