I tried making a rule to turn off my HVAC when I open a window, but ONLY if the HVAC was set to on before. When I created the rule my HVAC was OFF and a window was OPEN. I closed the window. At that point, the rule executed and turned on my HVAC. Why? I thought it only evaluated rules if the rule's truthyness changed. It didn't because the HVAC was NOT set to auto. Can someone explain to me why it executed and how I can do what I'm trying?
Did any of your windows open?
If so, the rule will be evaluated.
As the HVAC was off the rule will be false and your false actions will run. It will turn on the HVAC.
This is a fundamental problem with how you have the rule at the moment.
The "mode of auto" in your rule will immediately evaluate to false when the rule runs and changes your HVAC to off.
Generally you don't want the thing you are changing to be part of the rule level conditions. You can use it in action level conditions to decide if you want to change something or not.
I literally just did almost the exact same thing a few minutes ago, except mine was shutting off my HVAC when there is a smoke alarm. In order to restore the system to the previous state, store that state in a variable. Then use conditional actions comparing to that variable to restore the HVAC to that state.
So basically it's checking for a change in the CONDITIONS to decide which action to run, not a change in the rule? Meaning, I thought it only even did anything if the rule had a new value. Are you saying it is actually if one of the conditions has a new value?
Have an example of conditional actions? Haven't done that yet
All I'm saying is that if one of your windows open that condition will become true. The rule will then be evaluated and as your HVAC is off the rule will be evaluated as false.
The rule is re-evaluated if any of the device attributes in the conditions list change. It then decides to do the true or false step based on that output.
Your logic is:
if (any thing is open) AND (hvac is auto) then
So you open a window and now your two tests evaluate to
true AND true so you set a 5 minute timer to turn HVAC to off.
HVAC turns to off and now your two tests evaluate to
true AND false so you turn HVAC back to auto. That then triggers the rule to run again and your rule is now 'true AND true` and now you're stuck in a loop.
Here's my rule for managing my HVAC when HSM alerts smoke. Now, what I would do is divide this up in a regular rule with the top actions (above the wait) in True for window open and the bottom actions (below the wait) in the false actions for window closed.
And don't use the wait.
@dman2306, on your rule, if I don't want my HVAC turn On when I closed the windows, I delete Actions for False ( let it blank ).
I created another conditions rule :
- All windows are closed And
- Thermostats : Mode Off
Actions for True : Delay " X " minutes / Thermostats --> Mode: Auto
It work well with me.
My rule I just worked on.
This may help. I have 16 windows and 3 doors. I use two rules to manage this. The first is to set a variable if one of the doors/windows is open (this also helps with my alarm rules). I excluded the front door as that may only be open for a minute or so. The second has a trigger of that variable changing. The Actions are two Simple Conditional Actions.
I would recommend adding some delays to your rule to avoid cycling the state too quickly.
Mine looks like this
I have never had an issue with it. I never open and close my windows rapidly. In the event I do open and close them in succession (e.g. to yell at the neighbors dog), the unit will stop, wait's is appropriate time to cycle and then start again. Most (not all) thermostats have a setting to prevent damaging cycling to the compressor.
Stupid question @homeauto2112 but how do I enter the variable Set win_open to ‘open’ (or closed) for use within RM. Do I have to define the variable before I can use/select it in RM. I found I local variable within the 4.0 Rule I was creating and gave it a name and sting called open but do I have to creat a second string with the same name and a string closed too? Am I missing something or where can I find documentation for setting these variable in the Hubitat documentation.
@homeauto2112 just figured the setting the variable issue out... Thanks, but maybe you can tell be how I can make the current value of the variable visible in the dashboard for testing. That way I don’t have to keep updating the page in rule machine or looking at the logs to see it things are working as expected when I open/close a combination of doors for testing
I'm glad you got it working. I never put a variable on a dashboard, but you can try this: