Show your Rule Machine automations

This is actually a set of rules that control the automations in my master bedroom. See post #50 above for a link to a file where you can see all of my rules. But, I thought I would put these out here for y’all to see. I’d like some comments on how I can improve these. I’ve found a flaw that I’m trying to work around right now.

Goal of the Automations:

  1. Bed room lights turn on upon entering room. Different lights will be at different levels based on the current mode.
  2. All automations stop when my wife is using her pump
  3. All automations stop when my wife is in bed (usually before me) and set lights to custom level for her.
  4. All automations are easy to edit and quick to change. I do not want to change every rule just to make one change in the system.

Rule One - Master Bedroom Lights On/Off - This is the rule that triggers the lights on and off. It does this by telling the other rules to turn on and off. It is the heart of my bedroom automations. I think of it as the hub in a wheel. The other rules are spokes. This one is also where the override switches work. I turn on an override switch for this one rule, and everything shuts down.

Something to note about this rule. This rule becomes true when the motion sensor fires. That sensor resets after 15 seconds of no motion. The spoke rules determine how long the lights stay on. Every time motion is detected, the spoke rules are reset. I wanted the automation to be put on hold while my wife’s pumping. The problem with using an override switch is that the rules kept having to be jump started after the switch was turned off. This is how I got around that…

This rule becomes true when the pump goes above 1 watt. It stays true until the pump turns off. This keeps the spoke rules true until the pump turns off. The motion sensor still picks up motion, but since the rule never change truth state with the pump on, all automation are halted, and immediately restarted when the pump goes off. (This is my favorite part of all of this) @bravenel you might like this part too!

These rules are all of the mode rules. They determine which lights and what levels they are set at.

This rule is for when my wife wants to shut down the automations and take a nap, or put the baby down for sleep…

This rule turns everything off when we leave the house.

Now that I’ve written this I realize I’m missing a rule. I need to create one that turns the lights on if the house is in sleep mode and we arrive during that mode. (kids went to bed before we got home).

Also the flaw. I just remembered, I fixed the flaw by adjusting one of the rules.

With my rules set up this way I can add new scenarios to the room without rewriting a bunch of rules. I just create the new scene rule and add it to the On/Off rule.

Opinions? Remarks? Do you see any flaws or ways to improve this? Thanks.

Oh yeah, I forgot. Along with the automations the room is completely controlled by its own Amazon Echo and 2 minimotes.

**** And now thanks to @bravenel updating the capture/restore bug I am setting up the minimotes to do mood lighting scenes at the touch of a button!!!

lol. I think my wife would love it if we had moron sensors. So our house can do different things when I’m around.


My wife is constantly sending my text back to me requesting they be decoded.

I have got to work on my proofreading

Or use Swype…I honestly don’t know how people actually type out words on their screens unless they have one of those massive phones. I started using it with the very first Galaxy S phone and haven’t used another keyboard since.

I’ve decided to give rule machine another try so hopefully I’ll be posting here soon. I have to figure out what “true” means when some conditions are true and some are false. It’s a massive undertaking to go through the research on this given the number of threads, code changes, etc. but I really want to use it. Well, given that I can’t do everything I want with Smart Lighting I want to use something that meets my requirements. I really wish I could write the rules on my PC instead of my phone.

You can with Bluestacks.
Or Andy.
I have both installed on my PC

Hey folks, let’s keep this thread for sharing examples of personal rules. If you need logic assistance or have questions about how to use Rule, there are other threads more appropiate to those topics. One for example is this:


If the physical switch is within the range of the motion sensor number 3 may not be possible.

Here’s an easy one that has proven to be extremely useful, and replaced two instances of the old Change Nest Mode smartapp. It’s a conditional trigger that sets the Nest mode based on the SmartThings mode. I have the standard three modes… Home, Away, and Night.The Nest thermostat is set to ‘present’ when ST is in Home or Night, and to ‘away’ when ST is in Away. Since it’s a trigger, it runs every time the mode changes. Since I wanted true/false evaluation, I set a condition that would always be True (temp > 0). I could have just as easily used a ridiculous humidity or lux value, or a private boolean here.

This simple rule demonstrates use of custom commands (‘present()’ and ‘away()’), and separate True/False actions. It can easily be expanded to completely replace Routines, lock doors, set SHM status, etc.

EDIT: The description above is correct, but I must have been tired when I originally posted this, because it doesn’t work as a conditional trigger. See three posts down for the corrected Rule. :flushed:

Correct me if I’m wrong here, looking at this doesn’t seem like it would work for when mode becomes away. A conditional trigger will have its conditions evaluated upon the trigger happening and then take the appropriate action of true or false. In your case, mode becoming home or night will trigger the evaluation of the nest temp (always true) and set the thermostat to home. Switching mode to away won’t cause this conditional trigger to fire because it’s not part of the trigger. Also how can the condition ever become false and fire your false actions if temp will always be above >0? This seems better suited for a rule and not a trigger. Sorry if I’m wrong.

Hmm, I did test this last night and it worked as described, but now you’ve got me wondering if maybe something else was setting the thermostat to Away. I’ll strip this down to bare essentials and post back.

Yes, you are absolutely correct. I had a Routine I’d forgotten about that was confusing the issue. Here’s the corrected Rule:

This is really nice. Wich Device handler are you using for your Nest?


A modified version of this one… modified to use Nest orange for the heat color, and the new(er) multiAttributeTile:

Yes, I know the four Heat/Cool adjust buttons are redundant with the VALUE_CONTROL (up/down) buttons, but that feature does not currently work in Android. When its fixed, I’ll remove them.

Glad you got it all sorted out. Thanks for that screenshot of the nest too. I’ll b updating mine shortly, that’s way nicer than what I have now.

Here is my first shot at using Rule Machine for controlling a 3-speed ceiling fan based on room temperature thanks to @bravenel for some direction. I installed GE 12730 Z-Wave Smart Fan Control and use the device type by @ChadCK [Z-Wave Smart Fan Control Custom Device Type] I used my ecobee3 temperature reading for my input as well as the ecobee3 motion sensor to determine room occupancy.

I setup three rules, one for each speed of Low, Medium, High that only execute if the ecobee3 senses motion in the room AND the Virtual Switch “Fan Auto Enable” is ON.

If temp is >=73 and <75 Run custom command to enable lowSpeed() on Fan controller
If temp is >=75 and <77 Run custom command to enable medSpeed() on Fan controller
If temp is >=77 Run custom command to enable highSpeed() on Fan controller

I could have done it just using “Set these dimmers” for each speed setting but I was learning about some of the advanced features of Rule Machine and wanted to try it out since ChadCK had exposed the binary speed control in his device type.

1 Like

Very cool idea…pardon that pun.

Does your ceiling fan have lights on it was well? I wanted to use that switch but with mine having lights integrated it didn’t seem like a good idea.

I really like the visual!! Would you like to share your code?


Do you mind posting the modifications you’ve made? I’ve been wanting to attempt using the multiAttributeTile but I’m completely new at this stuff.

I fought with this one for a while: my wife and I get up at different times from each other, with a varying schedule. So, there’s no telling who’s awake and whose asleep in the morning. I’ve built rules to essentially shut down the master bathroom and closet while at the same time turning on the downstairs, such that one switch makes transitioning from upstairs to downstairs seamless. The issue is that, if one of us or the other is in the bathroom while the other one is trying to head downstairs, flipping the switch shuts down the bathroom and leaves one of us showering in the dark!

I laid out a bunch of possible rules on paper so that I could tie down the different options, and his is what came to the surface: we needed one specific items to let RM know if someone was still in bed or not. I ended up using the master bedroom overhead lights, which seems so obvious now :wink: Especially given that my RM alarm to get out of bed toggles the overhead lights on only if she’s already up.

So what the rule does is check for the state of the overhead lights and thusly decide whether or not to shut down the bathroom. I wrote a second rule, using a virtual switch to turn on the downstairs lights (or not) based on a lux value outside using the CoopBoss integration. (Thanks Jon!).

Lastly, I wrote a rule that, if the bathroom lights DO stay on (since the overhead lights are on meaning were both us), when the last one out turns off the overhead bedroom lights it shuts down the bathroom. Hope the expanded logic helps someone!

The fan has integrated lights. It is not easy to see in the photo due to the angle plus I had to remove the glass but its the Hunter Regalia 60-in with Light kit that I got at my local Lowe’s Store. I removed the two pull chains and use Rule Machine to be the fan auto control with an Aeon Minimote on the corner table to increase the wife-acceptance-factor for override of the fan and turning on lights.