The automation code you posted appears to be in line with the behaviour you’re describing:
When the motion sensor is triggered (changes its state to on
), and light level is below a certain threshold, the script to turn on lights is started; this timer script first turns off any previous instance, then turns on the light, and then starts the timer to turn the lights off; this second script waits for 10 minutes, and then turns off the lights. That’s it.
I assume that your motion sensor is only triggered once when you enter the room, and while it keeps detecting motion, it’s never turning off, and hence never turns to state on
again.
If you want the lights to keep on while there’s still motion, you have to build this into your timer script.
Please have a look at my previous post that includes a working motion light for inspiration.
In the timer_off
script you can see an example of how to use conditions to decide whether to keep the lights on and restart the timer, or just turn off the lights.