[Released] Rule 4.0


Is there a way to have a rule set the mode to what "Mode Manager" thinks it should be instead of having to select an actual mode?

For example... Most days I work from home so I have a "Work From Home" mode. My other modes (morning, day, evening and night) are all based on time of day. Sometimes I kill my "Work From Home" mode when it should otherwise be "Day" and others when it should otherwise be "Evening". I'd love to be able to set the mode to whatever Mode Manager is setup for.


You can set a mode based on switches. I do that, and use rules to set the switches. Here's an example:

Set mode with switches coexists peacefully with other methods of setting modes, so you can still have your mode change based on time of day, or however you set them otherwise. I set modes based on time of day, switches, and presence.


You need to get Mode Manager to do this, as it is the keeper of knowing what mode you should be in. You could use a virtual switch, and in Mode Manager use that switch for Return from Away Mode (under Set mode with switches), either on or off as appropriate. Presumably you have your Work From Home mode set in Mode Manager as a mode to ignore time changes for. If this is so, then Mode Manager will know what mode it should be based on time, and then when you flip the switch, it will put it in that mode.


Is that the "Select switches (OFF) for Return from Away Mode" that shows up when you enable the slider for "Use time settings for Return from Away"?

I use a virtual switch ("WFH") to set the mode to begin with. So if I choose it here then when it turns off "Return from Away Mode" kicks in?


Yep, that's the plan...


Excellent, thanks!


I don't think the condition is "Time between fired your rule at two times",
actually the condition IS TRUE when time is between two defined times, i.e. the condition is true during the interval and it is fired and continue to fire depending on the define rule. And that is what the purpose of this "time between" condition does.

I know because i am having problem converting the below RM3 to RM4

Select Conditions
Time between 9:00 AM EDT and 11:00 PM EDT TRUE
Variable HSMArmStay(true) = true TRUE
Variable HSMArmAway(false) = false TRUE
Variable HSMArmNight(false) = false TRUE

Define Rule
Time between 9:00 AM EDT and 11:00 PM EDT AND
Variable HSMArmStay(true) = true AND
Variable HSMArmAway(false) = false AND
Variable HSMArmNight(false) = false

Select Actions for True
Hubitat® Safety Monitor: Arm Home
Notify HSMTextStatusDisplay: 'HSM ArmedStay auto setting = armed home @%now%'
Off: ArmedNight

The variables are used to report and manually control the HSM via virtual sw. The pic below is what my HSM is.

I cannot come up with a trigger rule in RM4 to replace the above. Any suggestion?


First of all, why do you have all those variables for HSM status? Why not just use the HSM status in your rule?

Second, your trigger would be Certain time, 9am, Certain time 11pm, and HSM status changed.

Then you define your rule the same as you have it, except use the REAL HSM status instead of your variable. it's a lot easier.

I still don't understand what you're trying to do though....based on time of day you want to arm HSM to be armed home? Why would you do that?


Is there some miniumum time between events that is needed to be recognized? In my ongoing efforts to improve my presence handling I created a rule in RM4 to do some testing. I set up the trigger as either of 2 presence (phones) leaves. Then in the actions I look to see if both are gone or not. Every once in a while it will miss one of the triggers. It seems to be related to when both phones leave at the same time, but the triggers are not at the exact same time I'm sure. Not sure if the second trigger is missed while the rule is evaluating the first one or what is happening.

I have some ideas for a work around if that is the problem, but just trying to figure it out.



I think I found a bug or limitation with "Wait For Events" that is reproducible.
It is related to having wait for multiple "Certain Time" events.

Here is my test rule:

The app status page only shows one scheduled job:

And the event subscriptions are set for sunset

Does "Wait for Events" support multiple time events?
The idea here is similar to have "the earlier of the two events" trigger the rule to continue.
But I have the feeling that the first schedule will be overwritten by the second schedule...


I have this rule and it not fully working?

Name this Rule*

Select Trigger Events
Presence Side, Presence2 Side any *changed

Select Actions to Run
Set Fan Speed: Master Bedroom Fan Fan to medium IF (Presence Side, Presence2 Side all not present(T) [TRUE]) THEN Set Fan Speed: Master Bedroom Fan Fan to off

In this rule it should work as presence sensors are changed then fan comes on and when they leave turns off. It works when they arrived but not when they leave? but when I go into device on the presence and turn off and on it works? is there something that I'm missing?


This would turn the bedroom fan to medium whenever the presence changed at all, to present or not present. You have the action of setSpeed twice.


So i should change to arrive instead of using changed? I had this in rule 3.0 but wanted to start moving over to 4.0 and when I create the rule I cannot get to present or not present it is not on the screen when I choose presence only arrive, leaves or changed in 3.0 the present and not present were there?


@bravenel I have a rule that I was never able to make work in 3.0 and now seems does not work in 4.0 as well. It is very simple.

If thermostat cooling setpoint changes to less than 78 -
set the thermostat mode to auto, fan to auto, and cooling setpoint back to 78.

this to prevent my kids from freezing the place out.

here is the rule

here are my logs saying it happened.

and here is my thermostat showing it never changed after several refreshes

The thermostat is ct101 using the stock driver.


You are not using your condition.

Right now, your rule will always set it to the selected entries.

You need something like this in the Actions:

IF (Cool setPoint < 78) THEN Set Thermostat

Just having it under "Conditions" doesn't do something. This is just a repository of conditions that you can use in rules


@dan.t thank you.

new rule

logs with an error now

device page with device not changing


Maybe try doing 1 of those 3 actions at a time and see specifically which one generates the error?

And what thermostat/driver is it? Custom driver or in-box?


In regard to the error, I think the thermostat gives you an Integer value that you are trying to compare to a double.

Can you make the condition to look like

Cool setpoint of House Air is < 78

and not

Cool setpoint of House Air is < 78.0

See that .0 at the end? That throws it off.... I don't have a thermostat to test with, the virtual thermostat behaves differently....


well the error stopped on subsequent attempts of trying to get the rule to run. I will try though.

No errors if I mash any of those buttons directly in the driver. adjusting rule now


got rid of the extra commands and chose coolingsetpoint to 78.

It worked

edit. -

does not seem I can.

@bravenel do you see any reason this would fail with the other commands?