RM4 - List of example rules

Hi all,

I love the idea of browsing a long uninterrupted list of our communities favourite automations. Both for inspiration and guidance.

So please join in and share one or more of your automations that you think someone may find useful. Don't worry if its been posted before, you may have a different way of writing it.

Post anything from simple to complex. Something you find quite mundane may be a monumental help to someone else.


---- TO ENSURE A LONG UNINTERUPTED LIST PLEASE REFRAIN FROM COMMENTING ----

Name of Rule: Wake Announcement / Alarm Clock

Comments: Triggers my bedside GH speaker to make an announcement every 5 minutes after my alarm until I've gotten up and triggered my bathroom lighting rule. Also ties in with an automated Public holiday switch.

---- TO ENSURE A LONG UNINTERUPTED LIST PLEASE REFRAIN FROM COMMENTING ----

13 Likes

---- TO ENSURE A LONG UNINTERUPTED LIST PLEASE REFRAIN FROM COMMENTING ----

Name of Rule: Capture and Restore lights with contact sensor

Comments: Brightens a light right above a cupboard while the door is open. Once the door is closed, the light returns back to its original level setting.

---- TO ENSURE A LONG UNINTERUPTED LIST PLEASE REFRAIN FROM COMMENTING ----

3 Likes

---- TO ENSURE A LONG UNINTERUPTED LIST PLEASE REFRAIN FROM COMMENTING ----

Name of Rule: Workday morning motion lighting

Comments: Triggers a light based off motion. Starts off dim with low colour temperature then after 3 minute delay changes the colour temp and starts to brighten. The light stays on till I leave the house. The front door contact sensor turns both the light off and sets the PB back to True ready for the next morning. The colour temp shift is actually a really refreshing way to wake up!!

---- TO ENSURE A LONG UNINTERUPTED LIST PLEASE REFRAIN FROM COMMENTING ----

3 Likes

---- TO ENSURE A LONG UNINTERUPTED LIST PLEASE REFRAIN FROM COMMENTING ----

Name of Rule: Fridge Door Left Open

Comments: I have an LG side-by-side fridge with split door-in-door that allows you to access frequently used items like milk, sodas beer, etc. While the feature is pretty handy, the inner door doesn't close like a normal fridge door; it needs to be pushed until it latches. The design is so counter-intuitive that everyone who uses the inner door just swings it closed like every other fridge door on the planet. The end result is that the door doesn't latch and leaks tons of cold air. To add to this boneheaded design decision, LG decided that a "door left open" chime wasn't needed for the inner door despite being present on the main fridge door and the freezer door.

Hubitat to the rescue. I have a contact sensor named "Refrigerator Door" that monitors the closed state of the inner door. Triggered by this contact's open/closed state change, it allows the user to leave the inner door open for 2 minutes before sending a PushOver notification.

If the door is left open between the hours of 9 AM and 10 PM, the rule opens the "V-Fridge Door" virtual contact for 10 seconds, then closes it. This virtual contact is part of an Alexa routine triggered when the contact opens. The routine does an "announce" to every Echo device in the house and speaks the following message "Someone has left the refrigerator door open. Please close it.". The time condition prevents waking the entire house if someone grabs a late night snack beer. [EDIT] updated rule image (wordwrap causing THEN statement to appear on a separate line)

The rule repeats every 5 minutes until the door is finally closed.

fridge%20door%20rule

---- TO ENSURE A LONG UNINTERUPTED LIST PLEASE REFRAIN FROM COMMENTING ----

7 Likes

---- TO ENSURE A LONG UNINTERRUPTED LIST PLEASE REFRAIN FROM COMMENTING ----

Name of Rule: Freezing Outside Temp
**Comments:**This rule monitors the temp of my crawlspace using a temp probe attached to a Qubino 2 Relay module located in the crawlspace. If crawlspace temps drop below freezing it sends a Pushover notification and turns the water pipe heat tape on. Once temps return to above freezing it sends another Pushover notification and turns off the heat tape. The private boolean ensures the notifications are only sent once for each freezing temps/normal temps state change.

So why the odd device naming convention? My video doorbell is prone to lockups and the Qubino allows me to power cycle my doorbell transformer--I'm just leveraging the temp probe capabilities for this rule, which as you might guess has nothing to do with doorbells :slight_smile:

heat%20tape%20rule

---- TO ENSURE A LONG UNINTERRUPTED LIST PLEASE REFRAIN FROM COMMENTING ----

2 Likes

---- TO ENSURE A LONG UNINTERRUPTED LIST PLEASE REFRAIN FROM COMMENTING ----

Name of Rule: Laundry Cycle Complete Notification (using power monitoring)

Comments: Here is my Dryer RM4 rule. The Washer one is basically the same, except for the power threshold. You'll need to figure that value out for your specific devices to prevent false alerts. My power data is collected every 30 seconds, so this rule currently requires 2 power updates in a row below the threshold to trigger the notification (this is the purpose of the 32 second cancellable delay statement. The Private Boolean logic prevents this rule from issuing continuous notifications once the cycle is complete.

image

---- TO ENSURE A LONG UNINTERRUPTED LIST PLEASE REFRAIN FROM COMMENTING ----

8 Likes

---- TO ENSURE A LONG UNINTERRUPTED LIST PLEASE REFRAIN FROM COMMENTING ----

This rule has no trigger which does mean it can't run on its own. It can however be triggered from other rules. Since I evaluate locking the door in several other rules, I split out the logic into this one rule and trigger it from those rules. This technique could eliminate complexity in some of your rules and make changes quicker and cleaner.

---- TO ENSURE A LONG UNINTERRUPTED LIST PLEASE REFRAIN FROM COMMENTING ----

7 Likes

---- TO ENSURE A LONG UNINTERRUPTED LIST PLEASE REFRAIN FROM COMMENTING ----

Name of Rule: Notifications: TTS via AlexaTTS

Comments:
I use text-to-speech announcements for various events that range from the mundane (move clothes to the dryer) to the potentially serious (water heater leak sensor is wet). Rather than add complexity to each triggered rule that has an notification action, I simply setup a global variable "tts_payload" to which the notification is set. I then have a separate rule that runs each time the variable "tts_payload" changes. This rule is pasted below

I'd like to receive the more critical announcements by SMS when I'm not at home.
Therefore, rules that indicate a critical condition has triggered (eg. peripheral contact sensor triggered, leak sensor triggered, smoke alarm) also turn on a virtual switch called "Emergency". If this switch is on and I am not at home, then the variable "sms_payload" is set to the value of "tts_payload", and the TTS announcement occurs on the Echo Dot in my Office. "sms_payload" is separately processed to notify me via SMS.

Because, I don't want to badger the maid with announcements and or have announcements when I have visitors, virtual switches indicating either of these conditions cause the rule to be exited.

Under all other conditions, announcements are made at two different Echo devices.

---- TO ENSURE A LONG UNINTERRUPTED LIST PLEASE REFRAIN FROM COMMENTING ----

6 Likes

---- TO ENSURE A LONG UNINTERRUPTED LIST PLEASE REFRAIN FROM COMMENTING ----

Name of Rule: Lights on Contact or Motion

Comments:
This rule turns on a light when motion is detected or a contact sensor (e.g., door) opens, then off with a 1-minute delay after motion stops or the contact sensor closes. While Motion Lighting can handle this exact scenario (and I always encourage people to try Simple Lighting or Motion Lighting first), I've seen many people ask for how to do this with just contact sensors (easy: take out the motion below) or with other, more complex conditions that are do-able in Rule Machine. This should provide a good basis for doing something more complex.

image

---- TO ENSURE A LONG UNINTERRUPTED LIST PLEASE REFRAIN FROM COMMENTING ----

5 Likes

---- TO ENSURE A LONG UNINTERRUPTED LIST PLEASE REFRAIN FROM COMMENTING ----

Name of Rule: Doggy Door

Comments:
The purpose of this rule is to turn on the back yard light that is on the garage on a lone switch in the garage with a contact sensor when we let the pups out from the patio door in the kitchen. The concept is this: Open the door. The dogs go out and the light turns on. Close the door. The light stays on. Open the door. Dogs come in and the light is still on. Close the door. Light turns off. Walk away. Kinda slick. It's restricted to only run between sunset and sunrise. There's a little quirk that sometimes leaves it on that I haven't bothered to work out yet, but the rule works great otherwise.
[Edit]
I forgot to mention that you need to create a virtual dimmer switch to do the counting. I'm sure there are other ways to capture state, but this was the easiest way to wrap my head around it.

4 Likes

---- TO ENSURE A LONG UNINTERRUPTED LIST PLEASE REFRAIN FROM COMMENTING ----

Name of Rule: LivingRoomTV status controls lighting

Comments:
I use this rule each time I turn on my living room TV. There is nothing special about the rule itself; however, it makes use of two useful integrations/drivers written by others. The two integrations are:

  • @armandโ€™s Roku TV Device Handler. This integration is useful for lots of things; the sole use in this rule is to determine when my Roku TV is turned on or off.
  • @ogiewonโ€™s HTTP Momentary Switch. In this rule, I make use of two momentary switches created with this driver - Sonos-pause and Sonos-join. Sonos-pause pauses the living room speakers when the TV turns on, and Sonos-join re-joins them to other Sonos speakers when the TV is turned off.

Useful Rule Machine features that this rule makes use of, include:

  • A global variable (daylight) which is set to 1 shortly after sunrise and to 0 shortly before sunset.
  • A local variable (lights-on) that is set to 1 if certain lights were on when the TV was turned on, and to 0 when the TV is turned off.
  • Capture - which captures that state of lights
  • Restore - which restores lights to their pre-existing state when the TV is turned off.

This rule works like this:

  1. When the TV is turned ON, Sonos speakers are silenced and bias lighting behind the TV is turned on.
  2. If certain lights are on, the local variable โ€œlights-onโ€ is set to 1 and the status of those lights is captured before they are either turned off, or depending on the global variable โ€œdaylightโ€ are set to different color temperature and intensity. The variable โ€œdaylightโ€ also determines the intensity of bias lighting.
  3. When the TV is turned OFF, the living room Sonos are re-joined to other Sonos and bias lighting is turned off.
  4. If the mode is NOT Sleep, then lighting is restored to the parameters in play before the TV was turned on. On the other hand, if the mode is Sleep, different lighting conditions are chosen.

---- TO ENSURE A LONG UNINTERRUPTED LIST PLEASE REFRAIN FROM COMMENTING ----

3 Likes

---- TO ENSURE A LONG UNINTERRUPTED LIST PLEASE REFRAIN FROM COMMENTING ----

Name of Rule: Workday morning reminder

Comments: On the odd occasion I need to take something to work for the day. Most of the time its lunch I've prepared the night before or something else important.
This rule links up to a virtual switch I created and placed on my dashboard. My Google home also turns the switch on if asked.
When I walk out into my kitchen before work, the reminder fires on my GH speaker. I could make the switch turn off once this rule has fired but I'm not always ready to retrieve the item so preferred to leave as a manual interaction.
Its a pretty basic rule but one that always brings a smile to my face.

---- TO ENSURE A LONG UNINTERRUPTED LIST PLEASE REFRAIN FROM COMMENTING ----

---- PLEASE LIKE IF YOU FOUND THIS RULE HELPFUL ----

6 Likes

---- TO ENSURE A LONG UNINTERRUPTED LIST PLEASE REFRAIN FROM COMMENTING ----

Name of Rule: Kitchen Cabinets Home/Away/Quiet

Comments:
This rule uses the lightify strips above my kitchen cabinets as indirect lighting and a night light. I control this with three rules. KISS in mind with this automation.
The lights will turn on an hour before sunset and off an hour after sunrise in the first rule. This rule is pushy. If the lights would get turned off/on when they should be on/off, they'll turn right back to the evaluated state.

The lights then dim down to 20% as accent lighting if motion is inactive. When motion becomes active, these lights ramp up to 100% and remain there until motion changes to inactive. I have several motion sensors that I use, but only two to trigger the lights on. The lights will also stay at 100% if the kitchen and dining room lights are active. So that they work together.

When we go to bed. I trigger one set to turn off in a separate rule and the other to dim to 15%. When motion is triggered with one sensor that won't be tripped unless you walk directly into the kitchen, the single strip ramps up to 100%. It's bright enough to be able to get a drink of water yet dim enough that it doesn't light up every other room in the house. Very muted. Should mode change back to quiet or home and it's during the specified time, the other strip will turn on and interact accordingly.
[EDIT]
I ran across a blinking issue with my lights if mode was still in night after sunrise and there was movement in the kitchen. I modified the rule to include a time restriction.

---- TO ENSURE A LONG UNINTERRUPTED LIST PLEASE REFRAIN FROM COMMENTING ----

5 Likes

---- TO ENSURE A LONG UNINTERRUPTED LIST PLEASE REFRAIN FROM COMMENTING ----

Name of Rule: Family Room Back Door Deadbolt Unlocks/Locks

Comments: These two rules turn my patio lights on and off when the deadbolt on my backdoor is unlocked or locked (only at night). It's great for letting the dog out after dark. These two rules were created in HomeKit, but you could easily do the same thing with RM. I use HomeBridge and Maker API to connect Hubitat to HomeKit.

This demonstrates the versatility of Hubitat.

---- TO ENSURE A LONG UNINTERRUPTED LIST PLEASE REFRAIN FROM COMMENTING ----

1 Like

---- TO ENSURE A LONG UNINTERRUPTED LIST PLEASE REFRAIN FROM COMMENTING ----

Name of Rule: BEDROOM FAN

Comments: I like air movement at night when we're sleeping. I have the thermostat set to drop the temp by 2 degrees which makes for perfect sleeping weather. To help regulate the temperature, I set up the fan to set the speed based on an Aeotec multisensor 6 in the room. It's powered, so I have it report often. But the reporting doesn't have to be spot on. I'd rather it not to avoid the fan tripping on and off at a certain temperature. The fan only turns on and sets speed during night and quiet time. It turns off when mode changes to home as we are no longer in bed. There are probably a ton of different ways to set up this rule, but this worked for me. I usually stick to the [KISS] method when writing my rules, but I did combine the power off at the beginning of this one. Usually not my style.

---- TO ENSURE A LONG UNINTERRUPTED LIST PLEASE REFRAIN FROM COMMENTING ----

---- PLEASE LIKE IF YOU FOUND THIS RULE HELPFUL ----

3 Likes

Same rule to capture restore light values when CAPTURE/RESTORE isn't working with your bulbs. old OSRAM bulbs are one of those . The bulb need a refresh and some delays so HE doesn't get ahead of the bulbs actual state.

---- TO ENSURE A LONG UNINTERUPTED LIST PLEASE REFRAIN FROM COMMENTING ----

1 Like

---- TO ENSURE A LONG UNINTERUPTED LIST PLEASE REFRAIN FROM COMMENTING ----

Name of Rule: Living Room Light - Daytime

Comments: To turn on lights based on a low LUX value then turn them off based on a high LUX value only when someone is home. I use a Zooz 4 in 1 sensor so the LUX values are a bit different however it works very well. We haven't touched these light switches in nearly a year

Enjoy
Rick

4 Likes

---- TO ENSURE A LONG UNINTERUPTED LIST PLEASE REFRAIN FROM COMMENTING ----

Name of Rule: Inovelli Master Rule

Comments: To turn on Inovelli notification LEDs on Red series switches based on different events like water leak detected, alarm activated, garage door open, mail arrived, HSM armed. The rule is prioritized so if a water leak is detected that notification will always show even if the garage door is opened after, and alarm activated will override any but water, and so on. The only exception is if the garage door is opened and the mail arrived but water and alarm havn't been activated then all but the garage light switch will show the garage door as open while the garage switch will show that mail has arrived since I can see the door is still open from there. My notification switches are in groups so they are turned off then back on when activating them in case the switch was already on but the reliant switches were turned off by another notification previously.

2 Likes

---- TO ENSURE A LONG UNINTERUPTED LIST PLEASE REFRAIN FROM COMMENTING ----

Edit: Here are three related rules to manage a Litter-Robot Connect using Dominic Meglioโ€™s (@dman2306โ€™s) Hubitat port of the SmartThings driver and app.

The three rules are pretty much independent, and have been split so you may use one or two if you don't want all three.

With these three rules, the Litter-Robot mobile app (almost) never has to be used. I've revised these rules to reflect observations by @Bear (regarding the DFI (Drawer Full Indicator) flag - DF1, DF2, and DFS status) and his additions to the Litter Robot driver to expose the Litter Robot Status codes, and the observations by @forlornlawngnome regarding cyclesAfterDrawerFull not resetting. Dominic Meglio (@dman2306) has indicated that, at some point, time permitting, he will figure out how to reset the DFI flag from a driver command. I can't figure it out. Until there is a command to have the driver reset the DFI flag, the best way to empty the litter drawer, when it needs emptying, seems to be:

  1. turn the power off to the Litter Robot
  2. open the litter drawer, change the bag
  3. close the litter drawer - the Drawer Open rule will reset everything but the DFI flag
  4. add litter to the globe to fill to the fill line
  5. turn the power back on to the Litter Robot, this causes a clean cycle and calibrates the litter weight
  6. open the Litter Robot mobile app, it will ask if you forgot to reset the Drawer Gauge
  7. tap the button in the dialog to indicate you want to reset the Drawer Gauge, this resets DFI flag

โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”

Name of Rule: Litter Robot Drawer Open/Close Monitor

Comments: The Litter-Robot has a litter catch bag that fills up as the device cycles. When the bag fills, the drawer must be opened, the filled bag removed, and a new bag inserted. Then, the litter cycle gauge must be manually reset using the Litter-Robot mobile app. This rule automatically resets the gauge (through @dman2306โ€™s Hubitat driver) when the drawer is closed after being open for at least 30 seconds (during bag replacement). This permits taking a peek and closing drawer without triggering reset of the gauge. โ€œLitter Robot Drawerโ€ is a contact sensor on the drawer. The Litter Robot driver doesnโ€™t seem to generate a trigger event for the Litter Waste Level Monitor rule when Level goes to 0 after resetGauge(), hence this rule runs the Waste Level Monitor rule at the end.

โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”

Name of Rule: Litter Robot Waste Level Monitor

Comments: This rule was inspired by @jared.zimmermanโ€™s forum post explaining how he set up an IFTTT automation to change the color of room lights from green to yellow to red depending on how full the Litter-Robot waste drawer was. This rule does the same with our vanity under-counter Hue lightstrips. However, my wife wants the vanity under-counter lights in our bathroom to be navy blue during the night (indicated by a virtual โ€œBedtime Switchโ€, controlled by Alexa and a schedule). Additionally, all the vanity under-counter lights turn purple while the Litter Robot Drawer is open (so you can make sure the contact sensor is closed after bag replacement).

Bear (@Bear) correctly observed that the drawerLevel attribute from the driver is only advisory, and is only a guess based on number of cycles since last Drawer Gauge reset, calculated as a percentage of cycles assuming that the previous Drawer Gauge reset was done when the drawer was full 100%. Whenever the DFI flag trips (caused by poop or clumped litter blocking the Drawer Full IR sensor), well, the litter drawer is full, regardless of how many cycles have occurred. DF1 is the first cycle after DFI is tripped, DF2 is the second cycle after DFI is tripped, and DFS is the third cycle after DFI is tripped, and there will be no more cycles after DFS until the drawer is cleaned and DFI is reset.



โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”

Name of Rule: Litter Robot Flash on Alarm

Comments: I quickly tired of getting notifications on my iPhone and iPad that the Litter Robot's Litter Drawer was full (you have 3 cycles after DFI is triggered to empty the drawer, and my cats can only poop so fast). While thinking of a solution, I realized that there was a bigger problem, namely, the need to be alerted whenever an Alarm condition existed on the Litter Robot. There are many reasons why the Litter Robot might need attention and won't perform cleaning cycles - the bonnet could be dislodged, one of the globe positioning sensors could be broken, etc. You can read the driver's code for all of the various issues that case alarms. So, this rule flashes the lightstrips under our bathroom vanities (without changing their color) when such an alarm condition exists that needs attention.

As most or all of you know, Rule Machine has a very special idiomatic form to do a "While ... Repeat" equivalent, namely, "Simple Conditional Action", which tests a single condition prior to entry into the repeat loop, and prior to each return through the repeat loop. So, in order to use this idiom that only allowed a single condition to be tested, I had to build a boolean "OR" expression and then test the result of that expression in the "Simple Conditional". Otherwise, if multiple conditions were permitted for this "while" idiom, the rule would be much simpler, and only have the few lines in the middle.

Some in the forum have pointed out that the second building of this boolean expression at the end of the Repeat loop seems redundant in view of the "Stop Repeating Actions" prior to the "Simple Conditional Action" statement. Perhaps, but my response to this is: First, my intent was to exactly replicate the "Simple Conditional Action" idiom, except with a full boolean expression "OR" conditional, which tests the condition prior to repeat loop entry the first time and also prior to repeat loop entry each successive time; and, second, during testing, I have seen instances where there were multiple threads concurrently executing in the Repeat loop (observed by double-frequency or zero-frequency flashing). Remember, each time the lastStatusCode changes, a new thread instantiation is triggered that concurrently runs the rule. That's also why there are two different local variables used to build the boolean expression. I've never seen this version of the rule fail.



---- TO ENSURE A LONG UNINTERUPTED LIST PLEASE REFRAIN FROM COMMENTING ----

3 Likes

---- TO ENSURE A LONG UNINTERUPTED LIST PLEASE REFRAIN FROM COMMENTING ----

Name of Rule: Litter Box Vacuuming (two parts)

Comments: I saw @672southmain's litter box rule and thought I would share mine. My cats like to kick litter all over the hardwood floor by the litter box. I got tired of getting it on my feet when walking by and made this. It vacuums around the litter box after every two hours but only if the litter box has been used since last time. It also saves and restores the light states by the litterbox.

Part 1: Vacuuming

Part 2: Motion sensor (ignores motion sensor if Roomba is running to prevent false triggers)

---- TO ENSURE A LONG UNINTERUPTED LIST PLEASE REFRAIN FROM COMMENTING ----

1 Like

Download the Hubitat app