From 4166e789d52b7bdea17db58452980e358b40fb07 Mon Sep 17 00:00:00 2001 From: Hugo <42470993+hugobloem@users.noreply.github.com> Date: Sun, 3 Nov 2024 08:52:09 +0000 Subject: [PATCH] fix(scene): do not restore if already off (#127) --- custom_components/stateful_scenes/StatefulScenes.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/custom_components/stateful_scenes/StatefulScenes.py b/custom_components/stateful_scenes/StatefulScenes.py index 6b537fc..f1f9454 100644 --- a/custom_components/stateful_scenes/StatefulScenes.py +++ b/custom_components/stateful_scenes/StatefulScenes.py @@ -259,6 +259,9 @@ def turn_on(self): def turn_off(self): """Turn off all entities in the scene.""" + if not self._is_on: # already off + return + if self.restore_on_deactivate: self.restore() else: @@ -267,6 +270,7 @@ def turn_off(self): service="turn_off", target={"entity_id": list(self.entities.keys())}, ) + self._is_on = False @property