I have an automation which detects a child who has woken up and briefly pops on the stairs lighting for them to find their way in the dark. It works well. What doesn’t work so well is if the fact the automation takes no heed of whether or not the lighting was already on before it kicked in:
action:
- service: light.turn_on
entity_id: light.attic_stairs
- service: light.turn_on
entity_id: light.landings_lighting
- wait_template: "{{ is_state('group.PIRs', 'off') }}"
- service: light.turn_off
entity_id: light.attic_stairs
- service: light.turn_off
entity_id: light.landings_lighting
is there any efficient way I could modify this so that it only turns the lights on/off if a) they need turning on and b) they were off before the automation ran?
If it was just ONE set of lights being controlled, I would control it with a condition check in the actions but that won’t work here
thanks!