From cc59d364018e8456315bfb68aeee8bdd4e4ae89d Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Sun, 19 Mar 2023 15:31:50 -0400 Subject: [PATCH] Only run timer on unoccupied if lights are on Also don't restart timer if it was already running. --- packages/lighting_and_scenes.yaml | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/packages/lighting_and_scenes.yaml b/packages/lighting_and_scenes.yaml index f544815..692eda7 100644 --- a/packages/lighting_and_scenes.yaml +++ b/packages/lighting_and_scenes.yaml @@ -662,11 +662,21 @@ automation: - condition: trigger id: basement-unoccupied sequence: - - service: timer.start - target: - entity_id: timer.basement_studio_door_timer - data: - duration: "{{ (states('input_number.basement_studio_lights_off_delay') | int ) * 60 }}" + - if: + - condition: state + entity_id: light.basement_studio_lights + state: 'on' + then: + - if: + - condition: state + entity_id: timer.basement_studio_door_timer + state: idle + then: + - service: timer.start + target: + entity_id: timer.basement_studio_door_timer + data: + duration: "{{ (states('input_number.basement_studio_lights_off_delay') | int ) * 60 }}" - conditions: - condition: trigger id: timer-finished