Time thresholds (if door is open for 5 minutes, etc...) for rules in RM4?

So RM4 has been a mystery for me. I am a programmer, and engineer and RM4 is just a wacky thing compared to how straightforward RM1 -3 was.

So I have some simple things I need to get done with some new rules. Like "If a door is open for 5 minutes send me a notification" I was able to do this in the other RMs easily, but in RM4 I have no idea how to set that. I see the triggers and actions and see the conditionals for actions (which is a bit confusing because I would think we would want conditionals on a trigger, but... that's just me)...

I read the documentation but I seem to be missing something... I cant seem to find a way to do something like that where it canceles the action if the door is closed in that 5 minute span. Also setting up something to keep repeating the notification every 5 - 10 minutes if it is left open. This now seems pretty convoluted, or some different logic flow than I was used to.

You'd need something like this:


Contact sensor *changed*


IF ( Contact sensor closed ) THEN
    Cancel Delayed Actions
    Log Sensor is open -> delayed 0:05:00 (cancelable)

Also note that if this is all you want, the built-in Notifications app can do this with a lot less work. (It can't do the repeating notification example, so you'd still need something else like Rule Machine for that.)


Thanks guys! This did help. For me having the logic in the actions and not in the trigger is what confused me a bit! This is definitely pretty geeked out logic/coding, I can see how people get intimidated by this platform a bit :slight_smile:


I've got a similar problem with RM and seem to be going around in circles.
I have contact sensors on the 2 pantry doors that I want to turn on a wifi bulb with a 3 minute timer to turn off the bulb if the doors are not closed but turn off the bulb if the 2 doors are closed before the 3 mins are up.
I can turn on & off the bulb when the doors are closed with the Simple Lighting Rule but RM has got me stumped.
Any help would be appreciated.

That's how I would do it too,

(EDIT: I missed the both doors part, disregard the part below

but I would just do ELSE instead of ELSE-IF. No need to burn the CPU cycles and value lookup time for a 2-state trigger.)


Ah, good point. I should have read closer. You're right. :+1:


Thank you lads, I'll give it a go and get back to you.
Much appreciated!!

1 Like

To the two lads, Carl & JasonJoel, you were bang on the money.

Rule Machine worked a treat & I had a small epiphany! The penny finally dropped as RM just started to make sense, not saying I am an expert by any means, lol but I get the basics of RM, how and why it was designed this way, Clever Minds were at play when designing HE.

Again, Thank you boys for your help. I would have gone around & around in circles without the support. :drooling_face:


@Carl I just got a contact sensor to trigger a pantry door light in the same manner (turn off light if left open, and turn off with door closed). Your rule helped guide me what I needed to do to get it to work. Thanks!!

1 Like

The default Sunset sometimes isn't a great trigger for our lighting to change here, esp. during the summer, I've tried offsets and it still doesn't feel quite right, as it can be a "bright dusk" for quite a while. Using the above logic I tried to make something that takes our average indoor lux level (omitting things like closets that would throw off the average) and made this rule, which if I did it right should set "evening" mode when the average lux is below 100 for 10 consecutive mins.

Does this rule seem like a good application for this?

Also since I assume this just keeps running all the time I'd need to tell it not to change the mode when I've manually set the mode (e.g. Sleep)

Is there a better way to say, "just do this once per day" ?

I'm ok with it triggering much earlier on a day that is cloudy and overcast, but I wouldn't want it triggering in the middle of the night

Update : figured out since sunrise sets Daytime mode then I can add the condition Mode = Daytime, which will effectively reset the rule to run only once per sunrise

I don't understand why there is a "cancel delayed actions" in the repeat. I understand why it would be run in the "else" section but why in the "then" section? That action would only be run after the delay was finished anyway so there would be nothing to cancel.
Could someone help me understand?