From c79b361927525744881703e808ef03d0869e454e Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Mon, 4 Apr 2022 11:09:38 +0200 Subject: [PATCH] Unsubscribe from listeners when removing integration sensor (#69235) --- homeassistant/components/integration/sensor.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/integration/sensor.py b/homeassistant/components/integration/sensor.py index c0bac1b2745..ba76556fc51 100644 --- a/homeassistant/components/integration/sensor.py +++ b/homeassistant/components/integration/sensor.py @@ -253,8 +253,10 @@ class IntegrationSensor(RestoreEntity, SensorEntity): self._state = integral self.async_write_ha_state() - async_track_state_change_event( - self.hass, [self._sensor_source_id], calc_integration + self.async_on_remove( + async_track_state_change_event( + self.hass, [self._sensor_source_id], calc_integration + ) ) @property