From 754dfab3a1320b61ba4d9f48102d2147992d3dff Mon Sep 17 00:00:00 2001 From: Olen Date: Sat, 9 Nov 2024 18:09:17 +0100 Subject: [PATCH] fix: exception if calendar is not set up Signed-off-by: Olen --- custom_components/chore_helper/chore.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/custom_components/chore_helper/chore.py b/custom_components/chore_helper/chore.py index 48d5197..3f963f7 100644 --- a/custom_components/chore_helper/chore.py +++ b/custom_components/chore_helper/chore.py @@ -153,9 +153,10 @@ async def async_will_remove_from_hass(self) -> None: """When sensor is removed from HA, remove it and its calendar entity.""" await super().async_will_remove_from_hass() del self.hass.data[const.DOMAIN][const.SENSOR_PLATFORM][self.entity_id] - self.hass.data[const.DOMAIN][const.CALENDAR_PLATFORM].remove_entity( - self.entity_id - ) + if const.CALENDAR_PLATFORM in self.hass.data[const.DOMAIN]: + self.hass.data[const.DOMAIN][const.CALENDAR_PLATFORM].remove_entity( + self.entity_id + ) @property def unique_id(self) -> str: