From 28c1b79d89b752db80507da6fc1f53617b224eb4 Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Thu, 22 Dec 2022 20:08:40 -0500 Subject: [PATCH] Attempting to sync the boolean with the actual state of the lights --- packages/lighting_and_scenes.yaml | 39 ++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/packages/lighting_and_scenes.yaml b/packages/lighting_and_scenes.yaml index db0a831..77cd675 100644 --- a/packages/lighting_and_scenes.yaml +++ b/packages/lighting_and_scenes.yaml @@ -425,7 +425,7 @@ automation: - id: b897d714-bbf2-44ce-afaf-63cf3694351c alias: Tina Desk Lights Handler description: Handles turning on the desk lights with smart scene selection and also turning them off - mode: restart + mode: single trigger: - platform: state entity_id: input_boolean.tina_desk_lights @@ -441,6 +441,16 @@ automation: entity_id: input_select.tina_desk_scenes to: 'Reset' id: reset + - platform: state + entity_id: light.tina_desk_lights + from: 'on' + to: 'off' + id: lights-off + - platform: state + entity_id: light.tina_desk_lights + from: 'off' + to: 'on' + id: lights-on action: - if: - condition: or @@ -492,6 +502,33 @@ automation: - service: light.turn_off target: entity_id: light.tina_desk_lights + - if: + - condition: trigger + id: lights-off + then: + - if: + - condition: state + entity_id: input_boolean.tina_desk_lights + state: 'on' + then: + - service: input_boolean.turn_off + target: + entity_id: input_boolean.tina_desk_lights + - if: + - condition: trigger + id: lights-on + then: + - if: + - condition: state + entity_id: input_boolean.tina_desk_lights + state: 'off' + then: + - service: input_boolean.turn_on + target: + entity_id: input_boolean.tina_desk_lights + - delay: + seconds: 2 + # The delay is to prevent the boolean from re-running the automation if the lights were turned on manually script: emma_wakeup: