Hey - I'm trying to create a simple automation - when movement is detected, we start counting down 15 minutes. If movement is detected during that time, we reset to 15 minutes. Once the timer is finished, we switch off the light. I've been able to do the set/reset part, but am unsure on how to switch off the light. Do I need to create another "When" block with a custom event? The timer entity only allows me to read the duration, which I think is static.
#Motion-resettable timer to switch off light - do I have to code it in yaml?
1 messages · Page 1 of 1 (latest)
just have a trigger that triggers on
motion sensor changed from detected to clear for 15 minutes
Right, so what I had before was:
- turn light on
- wait 15 min
- turn light off
I want that time to be 15 minutes from the last motion detected
what you want instead is
when motion goes from clear to detected - switch on light
when motion goes from detected to clear for 15 mins - switch off light
OK, I think I get it, let me try it.
this would be an example of a switch off trigger
you should really avoid "long running automations" with waits, and instead use additional triggers.
Your initial message doesn't state that the lights are ever turned on. I assume you turn them on when movement is detected?
In that case the easiest way would be to create an automation that turns on the light, waits for 15m and turns it off again. The whole set/reset part can be avoided if you switch the automation mode to restart
Every movement will abort and restart the automation and with that also the 15m delay. It doesn't matter when the lights are already on and you "turn them on again"
However what Michael said is true long running automations should be avoided
this is an alternate idea yeah but I don't recommend it as its a long running automation, and also learning to use multiple triggers in a more simple application like this may help later if/when trying to make more complex automations
Why are long-running automations discouraged?
I'd trigger on timer.finished, but I'm not sure how to do that.
I like your idea with a restartable automation, I'll do that because it's conceptually the simplest.
if something goes wrong or there are restarts for updates and stuff, things may get stuck in unexxpected states.
specially for something simple like this: there is in essence already a timer because its baked into how long the motion sensor has been clear which you can trigger from. by adding a new timer your adding needless complication