Rule Machine Rule for Turning On/Off Devices with Motion

What is the best way to write a rule in Rule Machine to turn off a device if the sensor in the room consistently fails to detect motion for, say, a period of 2 consecutive minutes?

See a very simple example below. Bathroom light would be turned on if motion is detected and turned back off if there is no motion for 2 minutes. A simpler method would be to use the use motion lighting app, it is specifically setup for this type of thing and will step you through the process.

3 Likes

This example doesn't actually look for inactivity. It turns off the light 2 minutes after it's turned on. I would suggest the Wait be rewritten as:

Wait for Expression: Motion Sensor inactive --> duration: 0:02:00

1 Like

Actually it does. The trigger is the sensor going active. Each time there is a trigger, the wait is canceled and the timer starts again. The motion sensor has to remain inactive for 2 minutes before it will turn off the light.

2 Likes

If the motion sensor goes active and stay active for two minutes the light will turn off.

That is true, although in the usage of my sensors they never stay active that long. Usually no more than a few seconds, If you have a sensor in an area that can detect motion constantly for that long then you are right. your wait would be better solution.

2 Likes

So does this wait 2 minutes after the motion sensor first goes inactive, or does it make sure the motion sensor has been inactive for 2 minutes?

@Krishna this Wait for duration will make sure the motion sensor has been inactive for 2 minutes before allowing the rule to move the the next action and turn off the light. If the motion sensor goes active again before the 2 minutes is up, the rule will retrigger, cancel the exiting wait, and start a new Wait.

A little more info...
Wait for Expression: Motion Sensor inactive --> 0:02:00

was recently added and replaces the need to do the following:

Wait for Condition:  Motion Sensor inactive
Wait for event:  --> elapsed time: 0:02:00

I'm using both, they function effectively the same (when the Motion Sensor is in both the Wait and trigger), and have worked very well for my needs.

1 Like

Does the solution have to be in rule machine? Could you not use motion lighting? No problem if you are wanting to use this as a way to learn more about RM, just thought I'd ask.

Good question and not trying to answer for the OP but I'd like to give my experience with Motion Lighting. I'll admit that I haven't used it for quite a while but that's where I started. My rules generally were restricted to running between sometime at night and sunrise. I noticed that periodically my lights were on after sunrise. What I found is that if motion triggered the light on before sunrise and motion remained active until after sunrise, the motion lighting rule was restricted and would not turn off the light. For me, the solution was to use a Wait action in Rule Machine.

1 Like

Is Motion Lighting a new app? I'd never heard of that one before. I'm trying to consolidate all my rules in Rule Machine just to make it easier for me to organize and view the information.

It's been around for quite some time I would say, think it's now referred to as motion and mode lighting, then you get a choice of which child app you want to use.