Rule re-trigger while still running?

A thought just came to me (yeah, dangerous I know).

Say I have a simple motion triggered rule to turn on a light for 5 minutes (either though a wait then turn off or delayed off mechanism), and the motion sensor reset time is 59s. If the sensor is triggered again a minute after the initial trigger I presume the light will stay on for a total of 6 minutes?

If this is the correct behaviour, is it possible to suspend the rule from being triggered again during the 5 minute 'light on' period ?

Normally you'll have something like this:
image
This rule will turn on the light when there is motion. It will retrigger everytime there is motion, until there has been no motion fot 5 minutes, the light will turn off.

If you want to turn the light off after 5 minutes, regardless of any further motion, you could use a private boolean (that's one way of doing it):
image

The trigger for both of these rules would be:
image

2 Likes

(Sorry, I only saw now that you're using simple motion trigger. My answer was RM!)

Thanks, I was referring to using RM! (simple motion doesn't have any timer functions).

I guess setting a boolean is the only way to go!

1 Like

You could leave out the "ELSE-IF" if you want to have the light turn off after exactly five minutes.
You could also make your trigger event when sensor is active.

That will be a lot cleaner.

1 Like

Let me see if I understand. If you have motion in the space your sensor is in, you want the light to turn off anyway? That doesn't really follow with the concept of motion lighting. The whole point of motion lighting is that lights turn off after a timeout after motion goes INACTIVE not active. Why would you want the lights off if motion is still active in the space you are monitoring?

Mainly a thought exercise in RM. If the motion sensor is triggering a new action instance where an existing one is already running (ie via a delay) there could be quite a few instances of the rule running simultaneously if the reset period of the sensor is fairly short.

No, because the sensor going active cancels the delay and therefore closes out the "other instance" of the rule running. At least it should if you have designed your rule correctly.

This is true. I have adopted a philosophy of ' If there is any chance a rule could be re-triggered before completing, all delays and waits must have a method of cancellation.'

2 Likes

No, it really isn't. Not if you have designed your rule correctly. Motion going active again should cancel any delays in place before shutting off the lights. Otherwise, the lights are going to turn off while you're still in the room. Not very effective motion lighting.

The app isn't running while the delay is waiting. A scheduled task is set and that app is closed. When the app opens again when the sensor goes active, the scheduled task is unscheduled. So, there is only one instance of the app running at a time.

Just to be clear we are talking about rule behaviour in RM not the motion lighting app, right?

Either one, it doesn't matter. The app doesn't stay running while a delay is waiting. That would be completely useless for the hub and a complete waste of processing capacity. When you have a delay, whether in Rule Machine or in Motion Lighting, the app schedules the task and then closes. Even it it's only a minute or two. It is done processing in less than a second. There is no reason for it to stay open in the system.

1 Like

Thanks for that. So, more broadly, existing delay actions are cancelled if the rule is retriggered regardless of the type of trigger used?

Only if you have an action of cancel delayed actions and the actions are cancelable. But even if you build it incorrectly and forget to put in the cancel, you end up with multiple scheduled tasks for he rule to perform, not two instances of the rule running simultaneously. But if it makes it easier for you to think about it as still running, you can. but the app shuts down after the scheduled task is scheduled.

1 Like

This post saved me SO MUCH TIME! Thank you!

Everyone starts with a simple "sense motion turn light on", and "stop sensing motion, turn light off" type automation.

Then they add delays.

They they try to fiddle with the sensor timeouts.

Argh!

I had TWO rules, one to turn the lights on with all the IF THEN ELSE conditions, and one to turn the lights off, again with IF THEN ELSE caveats. They were at times fighting each other.

Your example showed a VERY USEFUL "Cancel Delayed Actions" command, and how to use it.

I now have ONE RULE per room, and it works perfectly.

Again, thank you!

Is anyone using Zone Motion Controllers (and more than one motion sensor) to improve room "presence" detection?

Recommended?

I have one motion sensor detecting when I enter the bathroom (for example), and one motion sensor mounted over the shower to assure that motion is still detected.

I'm not convinced the arrangement is perfect. Since you can't trigger on an AND condition, zones may be helpful.

I use ZMC for all my motion sensors whether there is only one or more motion sensors used.
This way if I want to change a device or include/exclude devices I do not have to amend the rules that these devices are in.
Just change the ZMC devices and it's done.
I use more than one device in my kitchen, lounge, dining room, bathroom and EN Suite to give better coverage of those areas.
Also I do not worry about using delays or cancel delays etc. as this is all done in ZMC.
It's just a straight forward ZMC motion active = lights on.
ZMC motion inactive = lights off.
Personally I just think it makes life and control a lot simpler.

1 Like

I'll give it a try, thank you! I also have some IF THEN ELSEs in there to account for ambient light and time of day, but the approach sounds "doable".

Any tips for using ZMC would be appreciated!

In your first example, could you make that ELSE-IF into a simple ELSE? The Gang_Sensor is either active or inactive, right?

You probably could. There are no more options, it's either Active, or it's not :slight_smile: