From 0d1984558f3dfd67f6292491ec62ccc970e0d766 Mon Sep 17 00:00:00 2001 From: freybene Date: Wed, 29 May 2024 16:26:25 +0200 Subject: [PATCH] Fix error when disabling single entity --- custom_components/smartthings_find/device_tracker.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/custom_components/smartthings_find/device_tracker.py b/custom_components/smartthings_find/device_tracker.py index cc65906..daa2855 100644 --- a/custom_components/smartthings_find/device_tracker.py +++ b/custom_components/smartthings_find/device_tracker.py @@ -43,9 +43,14 @@ class SmartThingsDeviceTracker(DeviceTrackerEntity): if 'icons' in device['data'] and 'coloredIcon' in device['data']['icons']: self._attr_entity_picture = device['data']['icons']['coloredIcon'] - self.async_update = coordinator.async_add_listener(self.async_write_ha_state) + def async_write_ha_state(self): + if not self.enabled: + _LOGGER.debug(f"Ignoring state write request for disabled entity '{self.entity_id}'") + return + return super().async_write_ha_state() + @property def available(self) -> bool: """Return true if the device is available."""