Rule Machine - This is Frustrating the Heck Out of Me

Does that cancel work? My understanding of RM4 cancels is they require a call from the Cancel Delayed Actions, right?

1 Like

You need something to cancel the delay if the fridge is closed.

The trigger is fridge door opens. If it's closed the delay is cancelled and then that is no longer true, so it doesn't speak the message. Just tested this several times and it worked perfectly every time.

Technically, you are not cancelling the delay. You are just checking if the door is currently open, 90 seconds after it opened.

Ha Ha. That's because I'm a lazy git and thought I'd just copy and paste one of my rules. Delete 90% of what I've got and your there!!!!!!!!! :smile: :smile:

2 Likes

The delay isn't really cancelled--you have to have a "Cancel delayed actions" action somewhere to cancel anything with the "Cancel?" flag set. Bruce explains how that works in this post: [Released] Rule 4.0 - #62 by bravenel

Your rule will mostly work because, as stated above, you're testing whether it's still open after the delay. This creates almost the same result (except possibly more scheduled jobs that will just do nothing when they're run instead of getting un-scheduled when they are known to no longer be needed--probably not a problem), but I see one important difference. Suppose you do the following:

  1. Time 0:00 - open door (triggers rule)
  2. Close door (does nothing)
  3. Time 1:29 - open door (triggers rule again)
  4. Wait at least one second, then close door

In this case, it seems to me that between steps 3 and 4, you'll get the notification from the first triggering of the rule because at time 1:30, the IF in that rule will evaluate to true. The example from @bjcowles above that uses a "Cancel delayed actions" when the door closes fixes this problem by truly un-scheduling the execution (at step 2 in my example sequence) instead of just testing the state when it it scheduled to be run again.

2 Likes

Yeah you are both correct. I forgot about testing opening the door again before the delay is over, so I see where that's wrong. However, I'm baffled how to make this work properly. Can you show me an example (gonna have to clean it up for my brain @bobbles! :rofl:)?

Thanks for a much better explanation than my ambiguous attempt.

@bjcowles has an example above that works, but a more general explanation of delays and cancelling in RM 4.0, I'd look at Bruce's original post in the thread: [Released] Rule 4.0. He has one example with motion-based lighting, but the whole section called "What became of Rule Truth and Cancel on Truth Change?" is quite ... illuminating.

What does the cancel do then? (I realise the trigger should be changed to "changed".

That cancel will do nothing unless you specifically 'Cancel Delayed Actions' somewhere.

1 Like

I've been schooled. The example @bjcowles gave works great. I was trying a delay before the speak with ELSE Cancel Delayed Actions after it was pointed out that my first example had a problem, but that second attempt would speak no matter what.

Appreciate the guidance guys. I will RTFM :rofl:

3 Likes

Also wanted to thank @pete3500 for the post. So silly I never thought of this use. We sometimes overpack the freezer and it doesn't close properly or bounces back open when you close the fridge door (it's an old fridge). That costs us quite a bit when we discover hours later that the freezer is slightly open and everything is covered in frost/half defrosted.

Appreciate the new project idea!

1 Like

Bob - Thank you for the schooling in RM 4.0. Really appreciate it. And my guess is that looking for "changed" in place of open/closed (unlocked/locked) makes this more efficient than my RM 3.0 rule.

Spent the last hour changing several of my RM 3.0 rules to RM 4.0!

1 Like

Wow! Thanks to everyone, I figured there was a way, but I couldn't have asked for more help!! Everyone kicks ass!!

1 Like

No problem!! Here's what mine looks like.


1 Like

Can someone tell me what is wrong with this rule? It all works except the repeat will not shut off when all the doors/windows, whichever one was open, are finally closed. thanks

I think you need to put the "END-REP" above the ELSE-IF statement. The END-REP acts as a bookend to the "Repeat ever..." And you might be able to remove the Delay statement and just select delay on the Notify action (Speak on Living ...)

I moved it above endif but it still wants to repeat.

Hi never said that, he said

And that is where it should go.

You also need a stop repeating actions before the end-IF.

BTW I don't understand the delay? Why not just repeat every 45 seconds. Then remove the cancel delay and just have stop repeating.