Reset timer

OK, let me start by saying I'm a newbie, so please go easy on me.
I have a rule to turn on my garage lights when either the door opens or the garage motion is active and then stay on for 2 minutes. That works, BUT, I want the timer to reset when it sees new motion, and it doesn't - it turns off after the first motion - it doesn't reset. What do I need to add?

Perhaps whatever your using for motion detection is not resetting itself.
I’d confirm that first.
Watch it from the Device page, or set logging on for that device and confirm that it is resetting.

Then look HERE

Instead of a separate delay action between on and off, put the delay on the OFF action itself (with cancel ability selected, too, of course).

Funny, I was going to post almost the exact same thing, except I had the delay on the OFF action already. I tried adding the cancel ability and it doesn't seem to fix it. The lights turn off at seemingly unpredictable times. Sometimes they come on for 20 seconds or so and turn off again.

Exactly what mine does - but that's because the timer gets SET, not RESET, every time it sees motion. So if you look at your logs you'll see motion active, timer set and then whatever your off time is set for you'll see a "Delay Over" which shut your lights off, and that could be 20 seconds after they came on.

I tried that and I now have this:


but it still does the same thing. I can see many motions setting the timer, but then I see many "Delay Over"'s corresponding with each motion, so I know the motion sensor is working fine.

Hi there.
Although you have put a (cancel) against the delayed off for the light, all that does is allow the turn off to be cancelled. You also have to tell it to cancel it in another action.
Personally I would do it something like this.
Use a conditional action of IF - THEN.
In your triggers I would have
Garage motion - changed.
Garage door - changed.
In you actions I would go.
IF
Garage door is open
OR
Garage motion is active.
THEN
ON garage lights.
Cancel delayed actions.
ELSE
Off garage lights (delay 2 mins. Cancel)
END - IF.

That should work. (I think :wink: )

1 Like

You are right, of course. I'm surprised I didn't notice that to begin with.

I would do:

if motion then
If switch off, turn on
Cancel delayed actions
Else
If switch on, turn off with delay (cancel)
End if

Forgive my ignorance as I'm still learning this, but wouldn't your version of this allow the lights to turn off even if motion continues since the lights would be on already?

No because the Cancel delayed actions is not in the "If switch off, turn on" simple conditional action if statement, so it gets run every time there is motion.

Maybe it would be more clear with some spacing / indention, and with the delay put before the IF:

IF (motion==active) THEN
-----Cancel delayed actions
-----IF (switch==off) THEN (switch=on)
ELSE
-----IF (switch==on) THEN (switch=off, with delay of X and cancel ability selected)
END IF

OK, yes that clarifies it nicely. I'll set that up. Thanks for the help!

If you don't care about chewing up a little more bandwidth you could always make it simpler by sending the OFF and ON regardless what the current status of the switch is.

Like this:
IF (motion==active) THEN
-----Cancel delayed actions
-----switch=on
ELSE
-----switch=off, with delay of X and cancel ability selected
END IF

I prefer to not send any more traffic on the mesh than I have to, that is why I do the off/on check. But in truth for something like this it probably doesn't matter unless you get many dozens of switches in play.

Cool, thanks. I also appreciate efficiency up front as things tend to get more complicated as time goes on.

So I could also do:
IF (motion==active OR door==open) THEN.................

Correct?

Technically, yes.

Just be sure that is what you want though.... As if you did that, and still left the ELSE part the same, the light would turn off after motion stopped regardless if the door was still open or not.

You could probably work around that by making the ELSE an ELSE IF like:
ELSE IF (motion==inactive AND door==closed)

I'm pretty sure that would work. What I'm looking for is when the garage door opens, turn on the garage light (so long as the lux is <45), then keep the light on as long as the garage motion sensor sees motion, then turn off when motion stops (after a few minutes). Where would I add the lux condition?

So when I go out to the garage for a smoke, the door will open and close, the light comes on (so long as the lux is <45), I move around so the light stays on, then I go back inside (so the door opens and closes again) and the light goes off a few minutes later.

This SHOULD work for that, right?

Thanks for your help

So the above got me close, but the lights tended to stay on. The script would skip the off step when things were sometimes active (lights on) and not get triggered again, so the off delay wouldn't activate. So here's the actions I'm testing out now and so far it seems to work the way I intended:

IF Back Door sensor open OR
Garage Motion sensor active THEN
----IF Garage lights is off THEN
-------On: Garage lights
----END-IF
----Cancel Delayed Actions
END-IF
IF Garage lights is on THEN
----Off: Garage lights --> delayed: 0:03:00 (cancel)
END-IF

I'm here today trying to get above entered using the same sensor using the Rule Machine 5.1. I need more help on the steps of the simplest way to input. I can't seem to find when entering the Select Actions to Run and then Conditional Actions then IF rule THEN. Once I get there I get lost in the steps to get hike20 script inputted. Any help would be greatly appreciated. Thanks.