Correct way in Rule Machine to do this light on motion then off after 5 minutes?

Awesome explanation, thanks @bertabcd1234, you rock!

Ok so my next question is, are there scenarios where either may be more advantageous than the other?

(Canceled delayed actions VS Wait)

Just depends on what you want the rule to actually do. :slight_smile: But in most cases I can think of, the cancellation is the desirable outcome, and using the "Wait" means a few less clicks. It's a bit newer (at least the ease of using "elapsed time" is), so you won't find it in as many docs/examples.

1 Like

Are they actually always cancelled? What is the point of the "Cancel wait" action then? I simply say this because I recently found a bug in my rule that effectively brought my hub to it's knees where I was using "Wait for condition" and it had 81,000+ simultaneous wait conditions that was crashing my hub every 24 hours. After stopping and starting the rule and changing to "Wait for Event" everything seems to be fine now and the waits are properly being canceled, but I have a "Cancel Wait" at the start of the rule.

Given the behavior of waits, I'm not really sure what use "Cancel Wait" servers with a rule that has triggers, though there could be some use case I'm missing. I imagine it may have value if you have a "triggerless" rule that just gets invoked from others, assuming that doesn't count as a trigger, too...

Interesting, I was always going off the assumption that any rule that has a wait condition/event needed a cancel wait action first to avoid multiple instances, I was basing that assumption off of this thread:

I'm not sure what to make of that post, but they are definitely cancelled if the rule is re-triggered:

1 Like

I have wondered about this myself.

My assumption is that the behaviour of the wait has been modified and the “cancel wait” was present earlier on.

Waits are cancelled by the rule being triggered.

I don't think there should be a Cancel Wait action, as there is no context it which it does anything. That will come out in 2.2.5.

5 Likes

What will happen to rules that use the Cancel Wait action in them? Should I just preemptively delete them or would the update just delete them for me?

Nothing. Release 2.2.5 includes a new version of Rule, Rule-4.1. Existing Rule-4.0 rules will still function as before and don't need to be changed. Rule-4.1's main difference is Wait for Conditions, replacing Wait for Condition. This allows a full logical expression instead of a single condition.

3 Likes

i am so confused now

1 Like

Sorry, we got distracted discussing related issues. :slight_smile:

There are ways you can make it work, either by modifying your triggers or re-ordering your blocks of conditional actions (as you may know, only the first matching block in an IF ... ELSE-IF ... ELSE-IF ... END-IF will be evaluated) with other minor changes. But it might be good to have a clear idea for others of what you want to turn the lights on (or off) besides motion: either door opening or closing, or just one (or both) doors doing one specific thing? And you always want the timeout to start regardless of whether there's motion? (If you don't, that makes things easier since you could always "Wait for event: motion inactive.")

1 Like

Let me see if I can break it down.

Turn on if any door opens or motion
Turn off of both doors closed and motion stops 5 minutes delay, motion will reset delay

Turn off if one door is open and motion stops after 10 minutes

yeah i see that what i dont know is is there a command to make it go to the a final rule? in my field we have a "then next term" or "then term xxxx"

this would make it drop to the my last else-if ( or does that just need to an "else"

here is a similiar one but with the addition off a virtual switch that gets turned on with a physical light turn on to disable the automtion so the lights can stay on.

Here is one I did a while ago:

There is a motion sensor and a contact switch. The light will turn on with motion and off when motion stops - which is 30 seconds in the case of the sensor I use. If the door is closed then it won't turn off the light.

Two notes: 1) I forget why I used "NOT open" instead of "closed." 2) The contact switch can probably be removed from the trigger events. If the door is being opened or closed you will likely trigger the motion sensor anyway. I mean you could open or close the door really, really slowly but what's the use case for that? :wink:

Hope this helps.

1 Like

i was going to ask if it make a difference? lol

It works so I didn't bother with it. I plan on adding more to the rule eventually and revisit it then. I have to install the Inovelli switches first. That way guests can turn off the lights without killing the power to the bulbs. Not that they need to turn them off as they will turn off by themselves but I don't want to explain that every time. So I'll give them a button to press. :wink:

My other bathroom already uses a Pico remote to do the same thing. You can use the Pico to override the default behavior. I use a Pico there because the bathroom only has a single gang box that contained both a switch and the only power outlet in the room. I updated the ancient and (as I found when I removed it) switch/outlet. I replaced it with a GFI outlet and used a double switch plate to mount the Pico as well.

Lol I put security covers on mine that you can only turn off the switch with a pencil or you can remove side wings to allow access but .makes them stop and :thinking:

Yeah, I just wanted to give them something to push. It is unnecessary but it makes people feel at ease.