Timer Reset

Is there a way to reset a timer?

I’m trying to program a motion sensor to control a light such that the light stays on while there is motion and remains on for an extra 5 minutes. If there is motion again during this 5 minutes, I want to reset the time so that the light stays on again for 5 more minutes.

The way it works now, with the call_timer, is that the first time motion is detected, the light goes on and stays on for 5 minutes. Then it goes off, even if there motion during that time.

One (not so pretty) way of doing this is using a variable to track number of motions detected. I’m assuming you are creating a luup scene or event. In unverified luup/lua…

function SomeFunction()
NumMotions = NumMotions - 1
if (NumMotions == 0) then

if (NumMotions == nil or NumMotions == 0) then
NumMotions = 1
NumMotions = NumMotions + 1
luup.call_timer(“SomeFunction”, 1, “5m”, “”,“”)

I’m pretty sure you can place the function “SomeFunction” in the startup lua page to avoid reloading the code on every motion.