I have a sliding door which sometimes gets left open. It has contact sensor, so I want to use that to toggle a bulb until the door is closed, if the door has been left open for a period of time. I have an automation which almost does what I want, but I can’t figure out how to restore the original state of the bulb when the door is closed. If the bulb was off when the automation began executing, it should return to off, when the door is closed. Here is what I have:
alias: Patio Door Opened
description: ''
trigger:
- platform: state
entity_id: group.patio_sensors
to: 'on'
for: '00:01:00'
condition: []
action:
- repeat:
while:
- condition: state
entity_id: group.patio_sensors
state: 'on'
sequence:
- delay:
hours: 0
minutes: 0
seconds: 5
milliseconds: 0
- type: toggle
device_id: 596a12edf624a47d9ffd8e8e4e97f1d7
entity_id: light.window_bulb
domain: light
mode: single