Quick Rule Tutorial?

Good evening... So I am new to hubitat... 2 days in.
I have about 110 devices ported in so far from ST/WEbcore/IFTTT/etc.
I have created a few simple rules (modes/switches lock doors, close garage doors) etc.
However I cant seem to pick up the syntax in a few things.
For instance how can I.

  1. Turn on Pool Tree spotlights at Sunset - 20 (got that down).
  2. Turn off at 1am (without creating a separate rule)
    So I want those both in the same rule... Should be easy, but im stumbling.

Also, trying to figure out how to do something like.
IF Motion is Detected, turn on switch 1 for 5 minutes, then set dimmer to 10%, etc etc

Basically complex rules.

Ive been through conditions and restrictions, but for some reason its not clicking with me at all. Webcore for all its confusion and setup time etc at least spoke to me. IF, THEN, ELSE... I get that. The way RM is written is powerful, but it doesnt yet speak to me.

I should say, this is all in RM4... Since its the newest, I figure I want to use that... All the tutorial videos seem to show earlier versions of RM that look totally different.

thanks in advance folks

3 Likes

Good call on using RM4. Although I was finally starting to wrap my head around RM3, I find that RM4 works much more like my head does. I think the videos have not caught up yet.

For your first two questions, something like this should work:


This rule will be triggered at sunset. First the lights will come on. Then it will wait until 1:00 AM (PDT is my time zone). Then the lights will go out.

Restrictions are completely optional. There's nothing you can do with a restriction that you can't do within a rule's actions.

For lighting things, here's my kitchen lights rule:

Very basically, if the motion detector "changed" -- i.e. became either active or inactive -- the rule is triggered.
-- If the mode is not "home" or "asleep" then the rule is cancelled. (This is the same as setting a restriction by mode.)
-- If the motion detector is active, then I want the lights turned on. "Private boolean" is true first thing in the morning (it's set in another rule). I want the lights to come on at 100% daylight white. If it's later in the day, I set the level of the light based on a lux value that's set in a different rule. If it's after I've gone to bed, I want the light on in a dim nightlight mode.
-- If the motion detector is inactive, during the day, the rule waits for 10 minutes then fades the light down to zero. At night, the rule waits for 2 minutes then turns the lights off. The "cancel delayed action" up in the "motion is active" part of the rule cancels the waits so the lights stay on if further motion is detected.

Edited to add: "Kitchen Auto Lights" is a switch that I can set in other rules for use cases where I want to change whether or not the lights are automated.

Hope this helps!

1 Like

I also struggle with rule machine, no matter which version. Like you, it just doesn't click for me. I also get the basic ideas of triggers, and the basic logic statements, but I can't seem to put it all together into a usable rule.

I have tried looking at the examples people post, and the examples make sense to me on the forums, but when I try to put that into RM it all falls apart.

I would welcome a tutorial or something to try and figure out what my mental block is.

Ill look through all this tomorrow...
Neonturbo, I agree with you,, when the rule is spelled out it makes perfect sense. But when you actually try to create it, its not set up at all logically.
Webcore, again for its faults, was line by line, easy to follow.

1 Like

i've found this mental block afew times, and RM4 is pretty blocky.
I've found if I write down what I want in the order I want it, I can tick it off as i go through the rule.

1 Like

The thing I love most is the ability to clone a rule.

When I want to create a complex rule, I first start with a small part of it that's not so complex. when I get that working right, then I clone it so I have it saved; then I start adding more complexity. Lather, rinse, repeat, until I get it working the way I want.

There's no law that says that a single rule has to do every single automation. It's perfectly OK to have multiple rules to take care of different parts of what you want. Then, once you have it all working, look at how they might be combined.

And I agree with @stevebott123... writing down what you want to do -- or outlining it, or flowcharting it, or however makes sense to you -- is a great way to start.

Don't be afraid of two rules: as people used to say, "rules are free." :slight_smile: (OK, people still say this, but it arose during earlier versions of Rule Machine, where rule actions were less flexible than they are now.) This would be blindingly easy with two rules, each with one of the two desired times as a trigger. However, a rule can have multiple triggers, so you could combine them into one, then create conditionals to test for the time in the rule actions and act accordingly. (That shouldn't cause problems here, but I've seen people get themselves into trouble with lots of triggers on the same rule.)

Perhaps a better question here is: why Rule Machine? Hubitat Simple Lighting can handle both of these cases quite easily. (Another way I think people get themselves into trouble, especially when new to Hubitat, is by turning to Rule Machine for things stock apps can already do.)

A common rule pattern is to turn something on with motion, then turn it off after a delay. This could easily be modified to turn them on then dim them to 10%. Again, I think a lot of people needlessly complicate things by turning to RM here when the stock Motion Lighting app can handle a lot of this, but for dimming rather than turning off I do believe RM might be the way to go.

There is an example very similar to what I mentioned above in the docs, which since you haven't seen I'm guessing you haven't read (the "?" icon in the upper right of any native or well-written custom app will take you to a docs page, but the forum thread I'm linking to here is a bit better): [Released] Rule 4.0. I know, I know, they look long and it sounds boring, but it's the best way to start learning and a fantastic resource after you get started. :slight_smile:

1 Like

Ill check out the motion lighting app. Most of my custom webcore stuff had to do with lighting, not much else.
I had one very complex piston that ran my entire nightly automation which was pages long, but I dont need to re invent that wheel.

So can you guys please take a look at this..
Not sure whats wrong, but the lights did not turn off this morning at 1am when they should have... am i missing something?

That looks OK to me. I ran a quick test on the sample rule I made, and it worked as expected.

Do you have logging for this rule turned on? Did anything show up in the logs that looks odd?

So not sure why the other night it didnt work.. last night it did... rule seems to be working as intended now.
BTW I just added a Air Curtain (blows air down across a doorway for keeping AC in, bugs out) and made a rule to turn it on via switch and open close sensor. Maybe the coolest thing ever haha. Only reason it works is because hubitat is local. If it was still on smart things the delay would be too long to be effective.

Great! I’m glad it’s working.

Welcome to Hubitat. :wink: