Hello, I’m trying to determine what options I have to control a specific light in my house.
I have a light in my house that can be turned on 1 of 2 ways.
- Simple - a light switch
- Slightly Complex - A motion detector, but this will only turn the light on if it’s already off, if it’s after sunset and if the TV is not turned on (or if it’s on but paused).
My question is how should I go about turning it off automatically. I do not want it to turn off automatically if it was manually turned on (by the switch). I only want it to turn off automatically if it was triggered by motion.
My thought is to use a template and base it off of the auto-on automation? I’ve attempted a template trigger like this:
trigger: template
value_template: "{{ state_attr('automation.hall_lights_on', 'last_triggered') }}"
for:
hours: 0
minutes: 0
seconds: 45
Bur for some reason, that never triggers. My hope is that it would have turned the light off 45 seconds after the motion automation was triggered. Is there another way to go about this?
Edit:
I just had another thought of how to accomplish this. I’ll give it a try today, but please chime in on thoughts.
I could change the auto-on automation to be in “restart” mode instead of “single”. I’d then add an action after the “turn on the light” action that would wait 45 seconds, and then another action to turn it off.
So the outcome should be that whenever the light turns on, it will turn off 45 seconds later. But since it’s in restart mode, that 45 second timer would reset every time the motion is triggered.