Lights off after no motion for X amount of time

I'm new to Rule Machine starting to get used to it at least I thought I was. What am I doing wrong with this rule? I want the lights to go on in the garage when I open the door (which works perfectly fine btw) but after I leave the garage after one min with no motion from the garage motion sensor I want the garage lights to go off. If I go back out I want the timer to reset.

your delay needs to be able to be cancel-able, and you need to have a cancel delay in under the the first if statement so when you trigger the sensor the delay is canceled and the light doesnt turn off.

1 Like

This is such a common use case that there exists a couple apps that help you do that sort of thing. Take a look at Hubitat® Simple Lighting app. Also Motion Lighting something.

1 Like

I was looking at these options and I found that these apps either do motion or lighting. I thought RM would give me more options

1 Like

Wow this seems clunky compared to webcore. I think I'll try simple lighting before I go and edit the rule. It took me a while to figure out. I feel like I'm going to mess it up and have to start all over. In fact that seems easier to me just starting from scratch. This need a option to copy other users rules then change it to your liking that is how I learned webcore.

1 Like

That would be handy, especially since there are so many great examples here in the forums. But it is worth it to get the hang of RM, i'm still figuring it out but it really does let you do pretty much anything you can think up once you understand its logic

1 Like

HAL9000 So trying Simple Lighting. Will this cancel the timer if I reset the motion? I think this is why I tried RM it is more robust I believe once you get the hang of it.

1 Like

You're absolutely right that you are going to need Rule Machine for many automations. If you did webcore, you won't have any trouble with RM either. But lighting automations are so common that I like to group them together under Simple Lighting and knock them out really quickly. I save RM for when I want to do something like turn off the fan only on Tuesdays if neither of us are home and the moon is full except on November 12, etc. etc.


Ok I'm giving it another try. I see where to make it cancel-able on the second IF statement but not seeing what you were talking about on the first part.

1 Like

sorry just saw this.
Ok the delay part at the bottom is what you check to make a rule delayed.

So say you are turning off the lights after 2 mins. you want to check the delay tab on that action.

Then you add an action under the motion detected trigger that uses cancel delayed actions from that list.

then when the motion is triggered in the delay window set on turn off lights it will cancel the delay and the lights will remain on, with the delay being reset when the inactive trigger happens again.

That being said, if simple motion lighting wont do the trick, motion lighting allows more complex rules and usually will.

example. simple yet complex lighting for my kitchen from motion lighting app

I don't have any manual lighting rules showing the cancel-able action, so instead here is a test rule im working on right now for my washing machine and other appliances. ignore the odd contact, its a placeholder.

It took me awhile to figure out this logic too.
Here is my simple rule. I found that in order to set conditions on which to cancel, I had to set my trigger to "changed" instead of open or close. If you do that, you can set IF statements that will cancel (or reset the timer) the OFF action that is set as cancelable. It makes total sense to me to do it this way but understand there may be more efficient ways to do this.

1 Like

I added in the cancel delayed action and the garage light still stays on.

I would also suggest digging deeper into Motion Lighting.. there is actually a ton of stuff you can do.

In my case I am rewriting a lot of my rules as app/child apps in groovy. My thinking is that it is potentially more streamlined for my use-case.

Another popular choice (since we all now have SOO much free time) is Node-RED... I am very interested in this.

Another thought and I kinda hate to bring this up because in the past there have been issues and HE won't support it but have you seen this thread?

WebCoRE is alive and (possibly) well in HE and the more recent versions are much more hub friendly apparently.

Thanks for the suggestions(I'm using the extra time to make my transition from ST to HE :slight_smile: ) I really like the responsiveness of HE will using webCoRE slow things down like they were in ST?

It's very possible but I'd ask on the WC thread. When I first got the HE like 2 years ago I jumped on WebCoRE because I really like the interface and like you used it on ST. I had too many issues with hub lockups etc so changed to RM and haven't gone back. I have been following the progress though and it looks pretty interesting and maybe the issues have been solved or worked around. I may spin up a spare hub for giggles and give it a whirl.

As my system has grown (now up to 3 working hubs) I've been feeling like I want to optimize things a bit more so I've started writing my own custom apps that are direct replacements for RM rules. This is working out pretty well and I recommend if you are into that sort of thing.

The other server you might want to check out is Node-RED - I'm not sure I understand it completely but the visual interface is very slick and you can do a lot of amazing things with it. Some folks here are using it to run rules, collect data etc.

One other app if you haven't seen it yet - HubConnect, a third party app that links ST and HE hubs (Also HE to HE) so they can share devices. VERY nice.. I use it to communicate between my hubs.

1 Like

Looking at your rule screenshot the IF and ELSE-IF are both true so the ELSE-IF will never get evaluated.
If you are trying to get the light to turn off if there is no motion and the doors are closed you need to include motion inactive in your ELSE -IF statement.
ELSE-IF doors closed AND motion Inactive

Also you don't need the cancel delayed actions in the ELSE-IF as this will cancel the delay directly above it.

Edit. Put a trigger in for motion changed and also add motion active to your IF statement.

I've personally solved this with the Motion lighting app, and it's working great.

Side/Question: I'm not actually sure what the Alexa/Google name thing is here. As in what could I do with Alexa/Google with this notion rule?

Bobbles. Thanks for the input. I tweaked around with it last night and it works perfectly!

1 Like