Control thermostat fan based on temperature difference

Is it possible to turn the fan on in my thermostat when the upstairs temperature is x degrees higher than the downstairs? I have the lyric thermostat which does have the fan control

Maybe with CoRE?


I do this with CoRE. But not with Lyrics.

Try this code, I actually just worked with this (first smartapp) last night. Have a motion sensor that detects temp, and the thermostat. Run the fan when the temp is off by so many degrees.


  • Duane’s Thermostat Fan Director
  • Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except
  • in compliance with the License. You may obtain a copy of the License at:
  • Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
  • on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
  • for the specific language governing permissions and limitations under the License.


// Automatically generated. Make future change here.

name: “Duanes Thermostat Fan Director”,
namespace: “smartthings”,
author: “Tim Slagle Modified by: Duane Helmuth”,
description: “Adjust your thermostat fan based on the temperature of a secondary temperature sensor”,
category: “Green Living”,
iconUrl: “”,
iconX2Url: “”

input “thermostat”, “capability.thermostat”, title: “Which Thermostat?”, multi: false, required: true
input “tempSensor”, “capability.temperatureMeasurement”, title: “Which temperature sensor?”, multi: false, required: true
input “tempDiff”, “number”, title: “Temperature Difference to turn fan on?”, required: true, defaultValue: 2
input “sendPushMessage”, “bool”, title: “Send a push notification?”, required: false, defaultValue: true
input “sendSMS”, “phone”, title: “Send as SMS?”, required: false, defaultValue: false


def installed(){
log.debug "Installed called with ${settings}"

def updated(){
log.debug "Updated called with ${settings}"

def init(){
runIn(60, “temperatureHandler”)
subscribe(tempSensor, “temperature”, temperatureHandler)
subscribe(thermostat, “temperature”, temperatureHandler)

def temperatureHandler(evt) {

log.debug "Temperature Handler"
//get the latest temp readings and compare
def currentThermostatTemp = thermostat.latestValue("temperature")
def currentSensorTemp = tempSensor.latestValue("temperature")

def currentThermFan = thermostat.latestValue("thermostatFanMode")

log.debug "Thermostat: ${currentThermostatTemp}"
log.debug "Temp Sensor: ${currentSensorTemp}"
log.debug "Current Fan Mode: ${currentThermFan}"

def difference = (currentThermostatTemp - currentSensorTemp)

//log.debug "Temp Difference: ${difference}"

if(difference < 0){
	difference *= -1
 //log.debug "Temp Difference Now: ${difference}"

if( difference >= tempDiff ){	
	if(currentThermFan != "fanOn")
		//set the therm fan state to ON
		def msg = "I changed your ${thermostat} fan mode to ON because temperature is out of range from ${tempSensor}"
		log.debug msg
	if(currentThermFan != "fanAuto")
		//set the therm fan state to AUTO
		def msg = "I changed your ${thermostat} fan mode to AUTO because temperature difference is in range of ${tempSensor}"
		log.debug msg


private sendMessage(msg){
if (sendPushMessage == true) {
if (sendSMS != null) {
sendSms(sendSMS, msg)



Thanks I will give it a try! Do you use this as well?

@Danimous, yes, currently using this 2x in my house; Have thermostat and separate sensor on my top floor, and same on main floor that seems to be helping equalize the temp across the floors.