Set of rules that I use to control my thermostat using external sensors

@zarthan had encouraged me to post the rule machine automations that I use for my thermostat in this thread, and I finally got around to it. Here are the rules that have worked pretty well for me.

I don't make use of a virtual thermostat, but use Private Booleans to make sure there are no rapid changes in set-points to prevent short-cycling.

Enjoy .....


My thermostat is not in a good location. While it is close to (and above) the return register, it does not accurately reflect the temperature in the living space. To get around this, I had used an ecobee3 with multiple room sensors for ~4.5 years until I switched to a z-wave thermostat about 2 months ago. I wanted to control the new thermostat based on temperature in living space, and dependent on mode.

So I got eight temperature/humidity sensors. Different subsets of these are averaged using @bravenel’s Average Temperatures app into an Away Temp, Home Temp, and Sleep Temp.

Based on ecobee data, I knew that my average compressor run times were about 16-18 minutes, and I wanted to recapitulate that with the new setup to avoid short-cycling and over-humidity.

Global variables:

My rules require 4 global variables.

AvTemp: the average sensor temperature (set based on Away, Home or Sleep Hubitat modes)

Temp: desired temperature for the specified Hubitat mode and either heating or cooling thermostat modes

TempMin: temperature used to turn off heating or turn on cooling

TempMax: temperature used to turn on heating or turn off cooling

TempMax and TempMin are calculated from Temp (as +/- 2)

So far, I’ve only tested the rules extensively for heating. The heat pump compressor run times are about 18-22 minutes (data from Sense monitor).

Sense Power Consumption Profile for Heat Pump

For heating, the average temperature in home and sleep Hubitat modes is about 0.25-0.5F higher than the desired temperature for that mode (i.e. GV Temp).

Here are the rules:

Rule 1:
Pause/resume rules based on the status of a virtual switch called “Thermostat Hold”. I use this when I have guests come over and need to change the temperature from whatever the current mode is set at. The temperature is set using Alexa and a virtual dimmer (see Rule 4). When “Thermostat Hold is turned off, Rule 3a/3b are run to return “Temp”, “TempMax”, and “TempMin” to the appropriate values for that mode.

Thermostat Rule 1

Rule 2:
This rule uses DarkSky temperature to set the thermostat into heat or cool mode. I use a private boolean to prevent rapid fluctuation in the setting.

Thermostat Rule 2

Rules 3a and 3b:
When the mode changes, these two rules set the GV Temp, TempMin, and TempMax. To prevent short-cycling, these variables are set with a delay of 15 minutes if the thermostat is not in idle mode.

Thermostat Rule 3a

Thermostat Rule 3b

Rule 4:
Alexa voice commands use this rule to set a local variable called Dimmer based on a virtual dimmer called “Virtual Dimmer - Thermostat Dimmer”. The LV Dimmer is used to set the GV Temp. There is a bound check on the LV Dimmer so that it is between 65-75F before setting the value of the GV Temp. “sms_payload” and “tts_payload” are just GV that I use to send notifications via SMS or TTS.

Thermostat Rule 4

Rule 5:
This rule sets the GV AvTemp when the calculated sensor averages change (on a per Hubitat mode basis).

Thermostat Rule 5

Rule 6:
Controls the thermostat in heat mode using TempMax to turn it on and TempMin to turn it off. I chose the values of TempMax and TempMin as “Temp +/- 2” based on values that work well to condition my house. The average temperature per Hubitat mode never gets below the setting of Temp, and the warmest it has gotten after a 20 minute run time is about 1.5-1.7 degrees above Temp.

Thermostat Rule 6

Rule 7:
This is the flip side of the heating rules. TempMin is used to turn on cooling and TempMax is used to turn it off. I have not used this as much as Rule 6. But the rules are easy to tweak.

Thermostat Rule 7


I really do hope other folks are able to take ideas from this for their own thermostat operations. I am still tweaking my rules and come back to your rules for inspiration.
Many thanks for posting this.

1 Like

And share improved versions.

1 Like

Yes!!! I tried before to get people to post what or if they use RM to control their thermostats. One, hoping you would post yours, but also to see if there are other creative things.

1 Like

My townhouse is upstairs/downstairs. I rarely have a large temperature difference, but with the averaging app, it is was easy to create averaged upstairs/downstairs temperatures.

This rule is should run if the difference between upstairs and downstairs is >=2 or <=-2. I'll probably change it to 1 later.

Switches the fan from auto to on for 10 minutes and then switches it back to auto.

I have a similar rule for my thermostat fan to run if the upstairs Temp is greater than 1.5° difference from the main floor but it's currently paused because I'm wondering if starting the fan for short periods uses more energy than just running it for longer periods on a set schedule and if the start/stops will wear out the fan quicker? What are your thoughts?

What kind of motor does your air-handler have? If it is an ECM motor then this is not of huge concern.

If its a PSC motor then its a little more worrisome, although 10 minutes is a reasonable length of time.

@cj_rezz I use ceiling fans and ecobee sensors for temp. control per room. Since most rooms are often vacant I disable the rule using Harmony and Roku virtual switches. I've also added humidity levels for a specific temo. range.

Short cycling the fan is fine if you know your average cycle time. My average cycle time is 16-18 minutes so I wouldn't run the fan less than say 8-9 min. per cycle.

1 Like

I'll have to check what type of fan is in my furnace. What about energy usage. Is it true that the most energy is used starting the fan motor up from stopped? Would frequent starts use more energy?

Again, much smaller issue for ECM blowers (which also consume way less energy btw).

Cool, I'll look into this!