ELSE never fires

Hi. Sorry I am new to Hubitat and this is my first rule. I tried searching but most posts I found are on the old version of RM

In the following rule, the lights never actually turn off. They should be turning off after 2 minutes of inactivity. Not sure what i did wrong.

Change your trigger to Motion “changed” instead of active.

Also, you’re going to want to add a “Cancel delayed actions” to your IF actions.... AND modify your ELSE’s delayed OFF action to be a cancellable.

1 Like

Change trigger to “change”

It works!!!! Thanks a lot. Newbie mistake. Btw, I assume that your other suggestions will allow the lights to stay on until there’s been no motion for 2 minutes? Otherwise it turns off lights after 2 minutes regardless? Here’s my new setup:

1 Like

If you want it to stay on during motion change the following.

This should work...

Trigger

Motion changed

If time and motion active
Cancel delayed actions
Turn on
ELSE if motion not active and time is this and light is on
Turn off after delay of 2 mins With cancel on
End IF

1 Like

Correct! Your rule looks fine to me.

1 Like

FWIW, there's an example exactly like what you want in the Rule 4.0 documentation--I know it doesn't sound fun to read, but RM is complex and I'd recommend doing so. :slight_smile:

I'd also recommend Hubitat Simple Lighting or Motion Lighting for this automation instead. They're a lot easier to set up (for anyone but especially if you're new to the platform), either can handle everything you're doing, and they might execute a bit faster since they are much smaller apps than Rule Machine and take less time to load (milliseconds, possibly only dozens or hundreds, but possibly important if you're walking into an indoor room).

Good luck either way, and glad you got it figured out in RM!

I tried that first but I couldn’t find a way to add the “Parents awake” virtual switch as a condition. Maybe I missed it. I want to avoid lights turning on while we sleep. The virtual switch is triggered by my GH “good morning/good night” routines. It works really well right now.

Have you looked into using the Hub's built-in MODES feature? Since you are executing a Good Morning and Good Night set of automations, you could easily have these set the MODE accordingly. MODE is available in most built-in Apps to help adjust the behavior of automations to be specific to the current MODE of the hub. Just an idea in case you hadn't already considered it. I use modes of AWAY, DAY, EVENING, and NIGHT. I try to keep it simple.

2 Likes

Ha - another youngster! At my age, modes are down to AWAY, HOME, and SLEEP :joy:

3 Likes

That’s the first thing I looked at. Keep on mind I’ve had HE running for only a week. But the modes
Didn’t seem to fit my use case. First off, I wanted these to be triggers as well (I.e. say good night to GH, which flips the awake timer, which executes actions in Hubitat). Secondly, the modes didn’t seem to offer enough variety. So for instance, if I want an independent “away/sleeping/etc” mode for each member of the family, I don’t believe you can achieve that with modes. I could be wrong.

Whoops so I read the docs again and I think maybe the second one is achievable. But it seems like I would need a virtual switch to integrate with GH anyway, so it would be another layer of complexity. Again, correct me if I’m wrong.

:smiley: I run my whole house on modes. They are probably Hubitat's strongest feature (imho). For your condition about setting up the home up for sleep, I use a virtual switch exposed to Alexa. When my wife and I go to bed, we tell Alexa "Good night" and it flips the switch which triggers the mode to change to Home - Overnight which kicks off another rule that shuts off all the lights, locks the doors, etc. Then, I have another routine in Alexa that flips another virtual switch in the morning while my wife gets ready for work. All of this can be accomplished just as easily with Google Home.

I completely missed this. You are correct, however, you can achieve this by combining modes with presence. I do that in a few of my rules as I want some things to fire only when I'm home and my wife isn't and the mode is in a certain state:

OK, I missed the virtual switch check in your Rule. You've gotten some great advice about modes and virtual switches above, but I'll just add that Motion Lighting does have "Switch to disable turning on" (and another for "off"), so you can restrict parts of the automation that way. Unfortunately, it only lets you choose one switch (but if you ever need more than one, perhaps you could handle that logic in Rule Machine and let Motion Lighting do what it does best). There are also a bunch of other options you can explore; the docs I linked to above explain most.

Of course, you can also keep using Rule Machine; I didn't mean to steer you away, just point you towards easier-to-use built-in apps that might meet your needs (and be a bit faster at them, usually not quite enough to be noticeable to a human, but some people here have been intrigued with measuring this lately).

1 Like

Thanks everyone. I am actually quite blown away with the features of Hubitat not to mention the amazing help I’m getting from the community. I’ve used Home Assistant and ST before and they both had major shortcomings, enough to drive me away. Hubitat seems to have BY FAR the best combination of usability, reliability, and responsiveness, coupled with great device support and great integration options. I will have to do more research (based on your advice) on the use of modes and motion lighting apps to get the best functionality. I love the fact that not only can I achieve what I want without major headache (unlike HA/yaml madness, and unlike ST/“why did it take 5 minutes” bewilderment) but there are multiple ways to achieve it. My wife will hate me for the next few months. :smiley:

3 Likes