Light Control - Motion and Manual Turn Off

This may be covered elsewhere - but I've not been able to locate it...

I'm looking to control lights on my patio as follows:

If it's after sunset / before sunrise and motion is detected, turn light on. Turn off after 10 minutes of the motion detector being inactive. If motion is sensed, reset 10 min timer. (This part I think I've got...) Would like the timers to vary based on mode.

Also, if I manually switch on, however, I'd like the same thing. Switch off after a certain amount of time. However, if motion is sensed after I turn it on manually at the switch, the timer is reset and starts counting down for the amount of time according to mode.

I've looked at Motion Lighting and RM posts, and am not seeing this. Thanks for your help!

Welcome to Hubitat!

I'm a little confused by the second part, so let's handle that separately. Because I'm not quite sure you actually need it.

For motion, your rule is simple.
Condition/Rule: Motion Active
Action for True: Lights on
Action False:
Delay by mode: Your delay for each mode with cancel on Truth change
Lights off

Now, you also want to delay turning the lights off when they are turned on manually. So, that would be a trigger....but I am curious as to why you think you need to trigger off the manual activation. Won't the motion sensor eventually go active even if you turn them on manually? Do you really need to have that part? If so, then it would be a simple trigger of
Trigger: Lights on
Action: Delay 5 mins, cancel on Truth change

But then, to keep that from turning the lights off once motion is detected, you would add to the actions if true for the first rule of "Stop actions for" the trigger you just created.

Thanks Ryan! This was very helpful. I'm migrating over from SmartThings and WebCore. Rule Machine approach is a different logic that I think I'm starting to 'get'. I wanted the 2nd part because I don't always go outside when I turn the light on - so the motion sensor wouldn't trip.

I did create a trigger that pops a virtual switch on. And, then the attached rule. Seems to be working just as I wanted. Thanks again.


Which version of the Rules Machine was this done on?

I have a very similar project, which I have tackled in a different way because I use Motion Active and Motion Inactive events as triggers.

However, I like the solution above better than mine, and thought I'd remodel mine on yours, but the current Rules Machine doesn't seem to have Actions for True and Actions for False.

The problem with my solution is that the motion sensor has a 4 minute recycle time (4 minutes is how long I want my lights to stay on for) so I turn them on when I detect motion and off when the motion goes inactive. The problem is that if someone turns them off manually then the motion sensor is not going to trigger them again until the 4 mins has expired.

Using your approach, I could set the motion sensor to have (say) a 1 minute recycle time, use a delay between ON and OFF (like you do) and then have a status change on the conditions becoming false to cancel the timer and turn the lights off.

Where my requirements differ is that if someone switches the lights ON manually then I want the lights to stay on until they switch them off manually.

So my rules looks like this:-


and for the OFF rule:-


The manual rules say: when the light comes on whilst the status is OFF then set the status to MANUAL ON. And when the light goes off (regardless of status) set the status to OFF.

I have a similar rule for my dining room lights, which perhaps you can adapt. Essentially, they come on when motion is detected or when i turn them on manually with my google home (a separate rule to the one shown here).

The rule then turns the lights off after no motion is detected. However, if the light switch is off they turn off after 3 minutes. If the light switch is on, they turn off after 20 minutes (which for my purposes is long enough to account for times when i want the lights on but people are not in there for a longer period).

Repeat motion during that time cancelled the delayed actions, so that they stay on.