RM 4.0 Rule Questions and Optimizations


I think it's obvious that I am a 4.0 bigot. It was not an easy process and I RTFM several times and still asked obvious questions. That said, I'm loving it. I no longer have Button Controller. Everything I could stuff into RM 4.0 is there and working better than ever. Every day I figure out how to slim down a rule, or make something more precise or find something else I can automate. It really was the one thing I needed to move from a control mindset to an automated mindset. My guess is that in about 2-3 more weeks, I won't be doing anything except enjoying the fruits of my labor.....oh wait...I think there's a thread about boats and black holes of time....


homeauto2112 - in your first post you had listed an outdoor light sensor. I'm curious which device manufacturer and model you chose for this type of application? I have a light sensors inside my home, but wasn't able to find any that were outdoor rated. Thanks


To be honest, I really like both - and depending on the problem I am trying to solve, I could see myself opting for one or the other if I knew that both would be indefinitely supported. If they were given different names maybe we could keep both!?


I see no reason to maintain two code bases. 4.0 is easier for more things than 3.x is.

People will get used to how rules are done in 4.0, just like they did in 3.x.


I'm not sure what @homeauto2112 is using, but I'm getting Luminance from a Hue Outdoor sensor 046677541736 | PHILIPS pairs directly with HE, and has been rock solid for the 2 or 3 months it's been outside.



Outdoor clear electrical cover, NodeMCU esp8266 with a TSL2591 illuminance Sensor connected via HubDuino. Never had a more reliable illuminance measurement and the NodeMCU has an awesome operating temperature range.

The NodeMCU and the sensor reside within the clear electrical cover protected from the elements mounted to the north side of my house.

All in under $25


I have more stupid questions! :slight_smile:

I want to do something like this:

I have an alarm that has switch on/off and LastUsedCodeName "some_string" properties.

Basically I want to do something like this:

if (switch turns off) then send Join notification "alarm disarmed by %lastusedcodename%

Now, what I can't figure out is how to add device.attribute (arbitrary one, not the one that triggered the event) to the notification. One thing I could think of is storing lastusedcodename into a global var and send that value in the notification, but that's a big-big cludge.

Any better ideas? Thanks!


This sounds very interesting. Do you have pics of the setup? What about the code you used for the esp, looking for anything tonget me going in the right direction on this. Thx


I’ll take some pictures later. HubDuino is an integration developed by @ogiewon and you can find the code and more about it here:



I use two Aeotec Multisensor 6 devices. The Backyard one is outdoors under a patio cover and the Bedroom one is inside next to the window. Both are powered (not running on batteries) so I can take advantaged of the reporting.


Possibly. I guess my initial thought was the less advanced users. Thinking more about this, I don’t think advanced home automation would draw in these crowds.

Personally I think that crowd will stick with remote control functions strictly. Maybe I’m wrong...

Hubitat understands their audience better then myself. I would leave those decisions up to them.

On a side note, I’ve created a few new rules under RM 4.0 and feel I grasp the changes now.

The whole concept of everything is now a trigger event threw me off at first.


Okay. This took a bit of work and overcoming ignorance on my part. The original ask was to limit the number of times the a Scene turning on/off would appear in my log files. I finally accomplished that with two rules (working on combining them into one).

The first rule take the multiple trigger evens of my light sensor and distills them down to two specific events. This may be handy when subscribing to devices that update a lot. Part of the trick here was to use the variable in the IF-THEN statement so as to limit the number of times it is called to change.


The second rule was changed to look only for variable and mode changes. Since the variable will only change twice (due to the rule above), the number of times things happen have been greatly reduced.


I don't know if this qualifies as as optimization but I've been going in the opposite direction as most people posting on these forums. Instead of consolidating rules I'm spreading them out into chunks/blocks/snippets. I make an action for each room that has motion detection and is occupied, hallways don't count. I have an rule that just counts activation's and sets a variable based on activity over time that resets over a sliding scale. I have individual action only rules to turn on each rooms by mode and a separate one to turn them off. The rule that automates is the controller rule, it uses the global variable to turn lights on or off. This gives me the flexibility to pause the controller to freeze the room. I can call the lights on or off from a virtual switch usable in a dashboard or from a button controller (Pico). If I add a bulb I only update the two rules that turn stuff on and off without touching any of the complicated controller rules. My rule count has gone WAY up but this runs smooth and is much easier to understand.


Here's another potential bug when creating a new rule.

  1. Create new rule 4.0
  2. Define trigger, define a 2nd trigger
  3. Delete 2nd trigger, click done

Problem: Select actions to run -> Manage or Create Conditions still shows the 2nd deleted trigger


I am trying to repeat my notification that tells me when a door/window is open when my thermostat is on. What is the proper way to set up the repeat?

Here is my current setup that will notify you one time.

I have tried putting a repeat above the Notify line and a stop repeat below it, and tried a repeat above the entire condition and a stop repeat at the end. Neither worked and only notified me the one time.


This is not a bug, and is completely harmless. If you don't want to use that condition, don't use it. It doesn't do anything unless you use it. These created conditions are not trigger events, they are conditions. They have no associated subscription to an event. They exist solely for your convenience. You can delete any you don't want.


I'm having a problem with cancelling a delay on a fade over time. I'm not sure if this is a bug, or if I'm missing something.

What I want to have happen:

  • Light comes on with motion
  • motion stops, light fades out over time
  • new motion at any time keeps light on, and if it was in the process of fading out it should go back to 100% and stay there until the delay runs out again

If I set the rule up without the fade, as this example, it works as expected. The light dims to 0%, but any motion before the 2 minute delay is over will reset the delay.

If I set the rule up with a fade over time, motion before the fade starts will reset the delay clock. Motion in the middle of the fade briefly sets the light back to 100%, but then it dims again to where it left off in the fade and continues until faded to 0%. Motion will not turn it back on until the fade is completed.

Here's the rule:

And here's a sample from the log. The light (Reading lamp) had dimmed to 49% when there was new motion. The light reset to 100%, then reset again to 45% and continued dimming.

What am I missing here? Does "cancel" only cancel the delay and not the fade? Is there any way to cancel a fade over time while it's fading?


You want to use Stop Rule Actions instead of cancel delay. That will stop a fade.


Instead of using lux in each of my rules that rely on light levels I use virtual switches.
I have one rule that takes the lux level and turns on or off these virtual switches.
This way only one rule gets evaluated every time lux level changes instead or around 10 rules. it also makes it easier if I decide to use a different device for lux measuring as I only have to change one rule.
Here is the rule I have (RM3) but my question is this.
There has to be a simpler way of doing this so I've decided to ask you boffins on the forum.
What are your thoughts on making this rule simpler in RM4. (If at all possible).
Thanks in advance.
(There are 8 of these IF-THEN ELSE-IF statements by the way).


Thanks! I'll give that a try.

ETA: That did the trick!