Hi, I was wondering if someone could help me with this. Reading through the forums the for condition where I have it won’t work but I don’t know how to format to get it to work.
What I’m after is for a condition that if the state of the sensor is off for 30 seconds then the light turns off. Is this doable or should I just use 2 automations, one for on and the other for off with a trigger?
The condition requiring the binary_sensor to be off for 30 seconds will never be true. Why not? The condition is looking for 30 seconds of “off” but that will never occur because the trigger occurs the instant the binary_sensor changes to off.
Thanks. Didn’t know about wait template. Below is what I ended up with, seems like it’s working. One more question though, is there any advantage of using the choose function when there is only one outcome?
No. I could and should have put that in the condition block which would prevent the automation from firing at all unless the condition was met. I was just quickly offering a solution, guess I didn’t look it over too well. Nice catch.
You should know that the example posted above doesn’t do this:
It waits until the binary_sensor changes to off and then immediately waits for 30 seconds before turning off the light. Basically, the moment someone stops moving, the countdown begins. It’s not the same as requiring the binary_sensor to maintain an ‘off’ state for a minimum of 30 seconds which implies no one is present for at least 30 seconds.
In addition, I believe the suggested automation should have mode: restart (unless specified, it defaults to using mode: single). In its current form, if motion occurs again during the 30 second delay, it will be ignored and the light will be turned off even though someone is still present.