Rule Machine - Get peer assistance here with setting up rules

@bravenel I know you have mentioned several times that you don’t want donations. With that in mind I would be willing to send you a color bulb or the funds to pick up a color bulb, since the latter would be easier. I don’t see this as a donation, more so as directly contributing to the development of this wonderful app since it will be used for a specific purpose.

I hope this comes across in the spirit that was intended.


Could someone help me on how to set this logic correctly. I think maybe this could all be done using sub rules but I am unable to figure it out.

Currently I have 3 rules working. The main one is when any door or window is open between the hours of 10:01pm to 6:00 am turn on two lights with a delayed off of 5min after the rule becomes false which would be when the door or window closes. If they don’t close turn the two lights will turn off after 15min.

The other 2 rules also use the same two lights above but they have motion sensors also in that room that I use for both of these rules. The rule is during the same hours of 10:01pm to 6:00am if the motion detector in that room detects motion turn on the light in that room and after there is no motion turn off after 1 minute. These 2 rules for these two lights are basically used as pathway lights.

My issue comes from both of these lights are also located where there are entrance doors to the home. So what will happen I believe is that if I come home during the hours of 10:01pm to 6:00am the first rule will become true and activate the both lights, but instead of turning off after 5min after the door is closed, it will turn off after 1min if the motion sensor does not see any activity. So it basically nullifies my first rule in the event that a door is open.

How could I write a rule to make it so that if the door is opened and I walk through and close the door, and of course the motion detects motion for a few seconds, it only turns off the lights after 5 minutes instead of 1min from the motion sensor rule?

Appreciate any help on how to set this logic. Thank you.

This is tricky, and not really doable at the moment. I have a similar problem in one room, where there is a timer for a switch and a motion sensor. The fact is, that if the motion sensor has a turn-off timer, that’s going to trump the other timer, even though I’d like the opposite behavior.

I have something in development that may allow a solution for this, no guarantees. Stay tuned.

1 Like

So in regards to the new Switch to Disable option - is it linked to the switch being ‘on’ or ‘off’ ? so like if I want to disable a rule that controls a connected switch if i manually turn it on - i would need a virtual switch to be in the ‘off’ state when the switch itself is physically turned ‘on’? Or should there be an option to choose the on/off state of the controlling switch?

If the switch is ON the rule is disabled. It really is an arbitrary choice on my part, and some people might prefer it to be an “enabled” switch with the opposite meaning. But, it really makes no difference if you are using a dedicated switch for disablement, like a virtual switch. The feature is not intended to be generalized, where you can pick which way it means which – that would be confusing.

My recommendation is to use a virtual switch. That can be turned on or off by any number of mechanisms to disable the rule, including by another rule or by a Trigger Happy trigger.

Ok. I just wasn’t sure if ON=disabled or ON=enabled for the switch value, since it wasn’t noted.

in my instance, a virtual switch wouldn’t be necessary - using the actual physical switch and turning it ON would disable the rule from modifying it’s state, turning it back off would re-enable the rules to run as normal. (which will work fine, so long as someone remembers to turn off the light!)

You might be able to solve this now with a combination of Rule Machine and Trigger Happy, and the newly released Disable switch. What you could do is have which ever rule you want to be the boss (coming home), disable the other rule (the motion sensor case). Then when the coming home rule turns the light off after 5 minutes, that could re-enable the other rule. You would need a virtual switch as the disable switch for the motion rule.

Thanks Bruce! It’s a bit over my head but I’ll try to figure it all out and give it a try.

Bruce, I can’t get my head around on how to actually set this up and in which app. I know how to setup a virtual switch but I am lost to set it up exactly how you said I would actually want it. Which is the coming home rule is the boss and the other 2 rules as the disabled/enabled worker. Any help would be really appreciated. Thanks.

I’d be happy to help you, mañana. As I said, I have a similar problem. In the morning I will get that set up and see if it all works as I hope it will. I’ll get back to you then…

Thanks so much Bruce. Maybe you could post a step by step instruction when you setup yours tomorrow and I should hopefully be able to follow it and adjust it to my own situation.

Having some problems that maybe someone can help me with. Basically I use smart lighting to turn on lights by motion for local control. However I don’t let smart lights turn the light off, I am instead using rule machine for that. My problem is, my lights seem to be turning off even if all the conditions are not met. The reason I am using rule machine is because even tho I have motion from one room turn on, I want lights to stay on if door is open or motion is active in garage right next to it. I also want a delay after conditions are met before light goes off.

Based on what I have stated for my use case, is this setup correctly?

What I think my be happening is the following. Motion is junk room turns on the light. I then open door and go into the garage, which opens garage contact and sets off garage motion. I work in the garage for a few minutes, during with time, junk motion has gone inactive, and door contact is closed. Now I go inside and work in junk room, retrip the junk motion, but 3-4 minutes later (after garage has been inactive for 3 minutes) junk room light turns off even with me in there and motion tripped.

I am guessing that while I am in garage, junk motion goes inactive, and even tho it goes active again in a few minutes, rule machine doesn’t look at it because it met the inactive condition earlier so it stopped paying attention to it?

I have this same setup in several location within house and seems to do the same thing in all of them.

I also have a single virtual switch setup to disable all my rule machine rules when turned on, however it only seems to disable one rule, and not the others I have setup using that same switch.

Try the off after X minutes pending cancellation instead…

You are using Turn off after delay. That’s going to turn off after the time no matter what happens in between. For motion-off type things, use Turn off after delay, cancellable. That will kill the time once motions happens again, actually on each reversal of rule truth. @Toasty has it right.

I just tested how to do this, and found a bug in Disable Rule. That’s fixed now, but you need to get the latest version of Rule from Github.

You will need a virtual switch to make this work, which you can create in the IDE (On/Off Button Tile).

For both of the motion rules, you select the virtual switch as the Disable switch (in More Options at the bottom of the page). In the door open rule, add as an Action for True to turn on the virtual switch, and in “Turn off after delay” part of that rule, add turn off the virtual switch.

What that’s going to do is this: The motion rules will work as they always do if the door isn’t opened. But, when the door is opened, both of those rules will be disabled, and their actions to turn off the lights after 1 minute will not happen. When the door is closed again, all will return to normal. In other words, the door rule takes over and prevents the motion rules from turning off the lights prematurely.

1 Like

Thanks Bruce, I will give this a try tonight. So just to clarify I do not need to use the new app Trigger Happy at all then?

I don’t think so, you should be able to do it with Rule Machine.

The Virtual Switch you are talking about, is it the same thing as Simulated switch I see in IDE?

I haven’t used that so I don’t know; I use On/Off Button Tile.

Bruce, I think I got this working correctly, but confused on one part. On my Door contact sensor rule that I want to be the BOSS rule, under ACTIONS FOR TRUE I have the followng:

On: Light Rule Virtual Switch
Delayed Off: Bar Light, Staircase Light, Light Rule Virtual Switch: 15 minutes (this is if a door or window stay open and are not closed the lights will then turn off after 15 minutes)
Dim: Bar Light, Staircase Light: 20

under ACTIONS FOR FALSE I have the following:

Delayed Off: Bar Light, Staircase Light: 5minutes (this is so when the door or window closes the lights will turn off after 5 minutes)

So my question is do I also need to add this Light Rule Virtual Switch I created to the above False action so it will all work correctly and deactivate after 5min after the door closes?