From 02e14d56aa77321f26f5e1dd8556d2585a2f21b9 Mon Sep 17 00:00:00 2001 From: Oliver Skibbe Date: Sun, 8 Feb 2026 14:26:39 +0000 Subject: [PATCH] Treat UNAVAILABLE similar to STATE_OFF. Consolidating conditions for state OFF and UNAVAILABLE. --- custom_components/auto_off_timer/__init__.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/custom_components/auto_off_timer/__init__.py b/custom_components/auto_off_timer/__init__.py index 8407744..65d1240 100644 --- a/custom_components/auto_off_timer/__init__.py +++ b/custom_components/auto_off_timer/__init__.py @@ -208,17 +208,11 @@ def _state_change_handler(self, event) -> None: ) if new_state.state == STATE_ON: - if old_state.state == STATE_UNAVAILABLE: - _LOGGER.warning( - "Entity %s turned ON, but last state was UNAVAILABLE, ignoring", - entity_id, - ) - return - elif not self._should_enable_for_entity(entity_id): + if not self._should_enable_for_entity(entity_id): _LOGGER.info("Entity %s turned ON, but condition not met", entity_id) return self._schedule_timeout(entity_id) - elif new_state.state == STATE_OFF: + elif new_state.state == STATE_OFF or new_state.state == STATE_UNAVAILABLE: self._cancel_timeout(entity_id)