Turning Nest Thermostat off with SmartThings

Is there anyway to turn off the nest thermostat when a window sensor is opened? I would like to do something like:
if Nest mode is cool and window is open turn off nest.

@Dianoga made the SmartApp that I use for that, and it works great!

1 Like

I just realized I never submitted that to be published. That’s done now. We’ll see if it gets approved.

THANK YOU FOR THIS! I was starting to think I was going to need to write my own.

I found this one when I browsed for it:
Author: Brian Steere

It looks to do the same thing as the one you’re submitting. Are there any differences?

It would be cool if you closed your windows and the nest turned back on.

That is the one I’m submitting. And it does turn things back on when everything is closed.

Oops… I failed to past correctly. Anyway I browsed in the published apps and found this one:
Thermostat Window Check

Seems similar to yours but doesn’t turn things back on.

Yup. works as you said! lol

I may try to add notifications to it, but nice work!

@Dianoga whatever happened to the nest API they opened up a few weeks ago? What improvements will we see with ST/Nest integration compared against what we have today?

I added notifications to mine too. I just added one line to each of the functions:

def turnOff() {
    log.debug "Turning off thermostat due to contact open"
    state.thermostatMode = thermostat.currentValue("thermostatMode")
    thermostat.off()
    state.changed = true
    log.debug "State: $state"
    sendNotificationEvent("I changed ${thermostat} to off because ${state.sensor} was opened.")
}

def restore() {
    log.debug "Setting thermostat to $state.thermostatMode"
    thermostat.setThermostatMode(state.thermostatMode)
    state.changed = false
    sendNotificationEvent("I changed ${thermostat} back to ${state.thermostatMode} because everything is closed.")
}

I asked support about the api and here is their response:
“We are working on an official integration but Nest is fairly selective in who they work with so it will take some buy in on their part.”

So the hold up appears to be nest.

@jthurston422 - Did you have to republish the app after making the changes?

@jthurston422 - where is state.sensor being set? It return null

Yes I did have to republish after making the changes.

And apparently I changed more than I thought.

Here is where I defined state.sensor

def sensorChange(evt) {
log.debug "Desc: $evt.value , $state"
if(evt.value == 'open' && !state.changed) {
    unschedule()
    state.sensor = evt.displayName
    runIn(delay * 60, 'turnOff')
} else if(evt.value == 'open' && state.changed == true) {
	unschedule()
} else if(evt.value == 'closed') {
    // All closed?
    def isOpen = false
    for(sensor in sensors) {
        if(sensor.id != evt.deviceId && sensor.currentValue('contact') == 'open') {
            isOpen = true
        }
    }

    if(!isOpen) {
        unschedule()
        if (state.changed == true)
        {
        	runIn(delay * 60, 'restore')
        }
    }
}
}