This automation works but feels clunky. What do folks recommend as a cleaner approach?
The basic goal is to have a single automation that turns on the light when I wake up the computer and then turns it off after a delay when the computer goes to sleep. (Pardon the extra YAML, I switched from visual and didn’t bother removing the fluff.)
alias: Toggle office light with computer
description: ""
trigger:
- platform: state
entity_id:
- binary_sensor.w9f3cyhw9j_active
for:
hours: 0
minutes: 0
seconds: 0
condition: []
action:
- choose:
- conditions:
- condition: state
entity_id: binary_sensor.w9f3cyhw9j_active
state: "on"
sequence:
- type: turn_on
device_id: 472eb9172e70cbde08393b27a2f87b0a
entity_id: light.office_light
domain: light
brightness_pct: 50
- conditions:
- condition: state
entity_id: binary_sensor.w9f3cyhw9j_active
state: "off"
for:
hours: 0
minutes: 0
seconds: 0
sequence:
- delay:
hours: 0
minutes: 5
seconds: 0
milliseconds: 0
- condition: state
entity_id: binary_sensor.w9f3cyhw9j_active
state: "off"
- type: turn_off
device_id: 472eb9172e70cbde08393b27a2f87b0a
entity_id: light.office_light
domain: light
mode: single