Turning Nest Thermostat off with SmartThings


(Joe) #1

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.


(Jordan Thurston) #2

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


(Brian Steere) #3

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


(Joe) #4

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


(Joe) #5

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.


(Brian Steere) #6

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


(Joe) #7

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.


(Joe) #8

Yup. works as you said! lol

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


(Marc) #9

@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?


(Jordan Thurston) #10

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.")
}

(Joe) #11

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.


(Joe) #12

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


(Joe) #13

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


(Jordan Thurston) #14

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')
        }
    }
}
}