From 5eaa0e9491dd740c529713290686a092ee781078 Mon Sep 17 00:00:00 2001 From: David Mulcahey Date: Fri, 5 Jan 2024 16:37:25 -0500 Subject: [PATCH] Fix assertion error when unloading ZHA with pollable entities --- homeassistant/components/zha/sensor.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/zha/sensor.py b/homeassistant/components/zha/sensor.py index 027e710e30c762..ea5d09dd6f4d56 100644 --- a/homeassistant/components/zha/sensor.py +++ b/homeassistant/components/zha/sensor.py @@ -216,9 +216,9 @@ async def async_added_to_hass(self) -> None: async def async_will_remove_from_hass(self) -> None: """Disconnect entity object when removed.""" - assert self._cancel_refresh_handle - self._cancel_refresh_handle() - self._cancel_refresh_handle = None + if self._cancel_refresh_handle is not None: + self._cancel_refresh_handle() + self._cancel_refresh_handle = None self.debug("stopped polling during device removal") await super().async_will_remove_from_hass()