Mode or Rule? (Noob alert)

Hi everyone. I'm completely new to HA (roll eyes here) but spent weeks pouring through forums to learn what I could prior to landing on an HE. Hub arrived yesterday, set it up with no issues (a testament to the platform) and did a few simple light and outlet automatons. Here is the next item on my to-do list with which I'm having a little trouble. I'm sure that this is ridiculously simple, but - see my username - I'm struggling. I have a few bulbs set up downstairs on motion to act as night lights during certain hours (overnight) It is very rare, but sometimes our dogs have to go out in the middle of the night. So rare in fact that I usually forget to disarm the alarm (monitored Honeywell wireless Vista) and set it off. I would like those bulbs that I use as motion triggered nightlights to turn on but red when the alarm is armed.

I have zero intention of updating or changing (at least at this point) my alarm because I'm happy with it and have no interest in integrating into my HA. So, I have Total Connect 2.0 sending me a text when the alarm is armed, and set up an Applet in IFTTT that sees that text, and turns on a virtual switch. Ugly, but it works. I originally set a rule that if the virtual switch was on and motion detected, then turn the bulb on and red with another rule that just turned the bulbs on white with motion detected. I thought that wouldn't work, because I have no way to make one rule take precedence over another. So decided to make an Alarm On mode and exclude it from changing based on time of day. Set that up, but when the alarm is disarmed, the mode goes null rather than the correct mode based upon time of day.

I can play with this and figure it out I'm sure. But I'm trying to avoid setting things up in such a way that a few months from now when I (theoretically) know what I'm doing I kick myself and have to redo it all. I'd appreciate any opinions in the right way to go. I don't want anyone to write the rule for me as I have to learn- but just guidance on which avenue makes sense. Mode, rule, or something else? Thanks!

and suddenly I realize I can use restrictions to dictate the color of the bulb if I go with a rule ...

Well if nothing else at the moment...at least a "Welcome to the HE Community" is in order if you haven't gotten one yet. This is a GREAT bunch of people who really dig helping each other, from the simplest question or rule to the 'Off The Charts' complex with all the bells and whistles. Welcome Aboard!

Mode is just a word.. almost literally. Hubitat has one global variable.. it's called Mode. You can invent as many (or as few) modes as you want. One per hour if you want :slight_smile:
but then you'd have to use it, and that would mean a lot of OR conditions in a Rule. If you're not ready for Modes (day, evening, away, night) the push that off for a while. The Hub runs just fine without using Mode.

You've done the hard part as far as I can guess.. you've got your alarm setting a virtual switch. Well done.

There's two off the top of my head answers to your conundrum: Motion Lighting APP and Rule Machine.
Motion Lighting is what it says... it takes a motion event and turns on lights. It's intended to be pretty simple for the specific things it's built to do. For everything else, there's Rule Machine.

Rules are Free
Use a lot of rules then, as you get insight, you can begin merging them together... you said you wanted to learn, not be shown.

I'd suggest you draw your need.. either in your head or on paper/tablet. What event will turn on the light? What factor controls the color? What turns the light off?

A word about Restrictions... You use them as a "wrapper" around the Rule itself to make the Rule there or gone. That's a critical visualization because the Restrictions don't cause the Rule to be evaluated. Imagine you have your Alarm Virtual Switch turn ON, but you created a Sunset to Midnight restriction. If the Virtual switch goes on at 1 minute before Sunset, you'd probably expect to have the Rule run the True Action as soon as sunset came along... won't happen... ever. One of the Conditions in your Rule has to have an event during the time the Restriction Window is Open.

That help.. make it worse?

3 Likes

Thank you!

That's a huge help, thank you. When I was in college, the programming course was DOS (you're totally allowed to laugh,). But that means "IF, THEN, ELSE," is deeply imbedded in my brain. I have mapped out several rules on paper as suggested, I just need to translate that into RM and understand the additional flexibility available. I'm going to take your information and start over, possibly with a bottle of wine. I'll get it figured out. Thanks again!

1 Like

I love the analogy @csteele made about Mode being a global variable.

I may be putting the cart in front of the horse here, but one critical thing to remember about RM restrictions is that it effectively makes time stand still. Couple that with the concept of a simple rule only executing actions when the state changes from True to False or False to True, and you can see where it can get confusing. If you restrict a rule while it's in True state, then resume it later and expect another True condition to make it run....well...not gonna happen since the state didn't flip. Something else has to happen to make it flip to False first, then back to True. For that reason, I personally don't like using restrictions with standard rules. I try to just use them with Triggers or Triggered Rules that are not dependent on a state flip.

1 Like

@destructure00 that is fantastic information. I think given all of this I'm headed for:

If between certain hours
And motion and the alarm virtual switch is on
Then turn on the light in color red
Or if between certain hours
And motion and alarm virtual switch is off
Then turn the light on in white
Else, do nothing

Now to figure that out in RM. :grin: