Set Temp Based on Another Thermostat?

I would like to have my upstairs thermostat always be 1 degree higher than the downstairs one. I would like it to automatically track the downstairs one so that if I lower the temp to 75, the upstairs will get set to 76.

Where/How would I go about writing this? In Vera I used PLEG to do some if/then/else type logic for controlling things but I haven’t seen anything like that yet.

Any help would be appreciated.
Bob

1 Like

Take the code from this post, change the code to set the temp on the thermostat instead of setting the fan to ‘on’. Should get you going

When I set the temp on thermostat1, I get my event happening 4 times for some reason. Any Ideas?

`// Automatically generated. Make future change here.

definition(
name: “Bobs Thermostat Syncer”,
namespace: “smartthings”,
author: “Tim Slagle Modified by: Duane Helmuth/Bob Snyder”,
description: “Adjust a thermostat based on the setting of another thermostat”,
category: “Green Living”,
iconUrl: “http://icons.iconarchive.com/icons/icons8/windows-8/512/Science-Temperature-icon.png”,
iconX2Url: “http://icons.iconarchive.com/icons/icons8/windows-8/512/Science-Temperature-icon.png
)

section
{
input “thermostat1”, “capability.thermostat”, title: “Which Master Thermostat?”, multi: false, required: true
input “thermostat2”, “capability.thermostat”, title: “Which Slave Thermostat?”, multi: false, required: true
input “tempDiff”, “number”, title: “Temperature Difference Between Master and Slave?”, 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}"
init()
}

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

def init(){
//nIn(60, “temperatureHandler”)
subscribe(thermostat1, “thermostatSetpoint”, temperatureHandler)
}

def temperatureHandler(evt) {

log.debug “Temperature Handler Begin”
//get the latest temp readings and compare
def MThermostatTemp = thermostat1.latestValue(“thermostatSetpoint”)
def SThermostatTemp = thermostat2.latestValue(“thermostatSetpoint”)
def difference = (SThermostatTemp - MThermostatTemp)

log.debug "Thermostat(M): ${MThermostatTemp}"
log.debug "Thermostat(S): ${SThermostatTemp}"
log.debug "Temp Diff: ${tempDiff}"
log.debug “Current Temp Difference: ${difference}”

if( difference != tempDiff ){
def NewTemp = (MThermostatTemp + tempDiff)
def msg = "${thermostat2} sync’ed with ${thermostat1} with of offset of ${tempDiff} degrees. Now at ${NewTemp}."
thermostat2.setCoolingSetpoint(NewTemp)
thermostat2.setHeatingSetpoint(NewTemp)
thermostat2.poll()
log.debug msg
sendMessage(msg)
}
}

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

}`

Well I uninstalled it and reinstalled it and that seems to have corrected that problem. It was like it was running 4 times or something.

Now to get it to actually set the temp. The log shows it being set to 75 for example, but the thermostat is not changing.

Seems like I need my new temp to be in the format of 75.0 instead of just 75.

Looks like I have it working now. The slave thermostat had a paramter to keep the cooling and heating temps a few degrees apart. When I set them both to the same value, the first one set was reset to a different temp.

Here’s the code if anyone wants it. Thanks for the help!

Thank you for this code…it is working great when using my Main floor thermostat as the primary. However, I would like it to work in reverse as well- if the upstairs thermostat is adjusted, I want the main floor to be automatically set to 2 degrees cooler.

I have played with the code a bit, however I can’t find a way to capture which thermostat is initiating the action. So basically what I want to do is
If main thermostat = temperature change then set upstairs thermostat = main thermostat temp + 2
Or
If upstairs thermostat =temperature change then set main thermostat = upstairs thermostat temp - 2

Is there a way to do this?
Thanks!

I guess you could but how would you know which one was altered manually. If the upstairs is 70 and the downstairs is 75, do I set the downstairs to 68 or the upstairs to 77?