Device Type Input Quirk

Hello, I am new to the forums and smartthings development. I have added the unsupported Nest device, and it works great, but wanted a way to automatically set the status based on the location’s mode. I created a simple app to watch for the mode.

/**
 *  Modify Nest Presence with Hub Status
 *
 *  Copyright 2014 Dan VanWinkle
 *
 *  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:
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  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.
 *
 */
 
definition(
    name: "Modify Nest Presence with Hub Status",
    namespace: "danvanwinkle",
    author: "Dan VanWinkle",
    description: "Modify Nest Presence with Hub Status",
    category: "My Apps",
    iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
    iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png"
)

preferences {
    section("Change the status of the following Nest...") {
    	input("nest", "device.nest", required: true)
    }
    section("To home with the following mode...") {
        input("presentMode", "mode", title: "Mode?", required: false)
    }
    section("And to away with the following mode...") {
        input("awayMode", "mode", title: "Mode?", required: false)
    }
}

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

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

	unsubscribe()
	initialize()
}

def initialize() {
    subscribe(location, locationChanged)
    log.debug("Starting to update ${nest.displayName} to home with mode ${presentMode} and to away with mode ${awayMode}.")
}

def locationChanged(evt) {
    def currentPresence = nest.currentPresence
    
    if (currentPresence != "present" && presentMode == evt.value) {
        log.debug("Changing ${nest} to home")
        nest.present()
    } else if (currentPresence != "away" && awayMode == evt.value) {
        log.debug("Changing ${nest} to away")
        nest.away()
    }
}

Everything with this code works amazingly in the Simulator, and even works with my physical device. The problem occurs when I try adding the SmartApp to my iOS app, it does not list the physical nest device in the input options.

Is this a known bug or am I doing something incorrectly to make this work on device?

Thanks,

Dan

@dvanwinkle - Check that when you installed the nest device, did you check the thermostat capability?

Assuming you did this then try changing your nest selection in the preferences to:

    section("Change the status of the following Nest...") {
    	input("nest", "capability.thermostat", required: true)
    }

Thanks for the suggestion @stevesell!

Yes, the nest does have the capability of Thermostat, but with the Smart app, I was hoping that I could limit it to a Nest (assuming that one day Smartthings will have a store similar to MCV’s).

I was able to install the smart app just fine through the Simulator, and it seems to be working somehow, even though it is not installed through the smartphone app.

Do you know if there is an issue tracker for smartthings?

Hey @dvanwinkle, thanks for this code! After just a little bit of tweaking, I was able to get it working perfectly for me.

Did you ever get it working?

@jthurston422, I have it working, but I still cannot add the app through my phone, I can only add it through the simulator. It is not able to see “device.nest”. I know that I could do what @stevesell suggested and change the code to read “compatibility.thermostat”, but the issue with that is that it would work on any thermostat, not just the nest, and the nest. A normal thermostat does not have the methods “away” and “present”, so this would be bad coding in my opinion.

What tweaks did you make to get it working?

@dvanwinkle The main change I made was what @stevesell suggested. Then I just added some notifications so that it would show up on my dashboard.

Here’s what I’ve got:

/**

  • Set Nest Mode
  • Copyright 2014 Jordan Thurston
  • 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:
  •  http://www.apache.org/licenses/LICENSE-2.0
    
  • 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.

*/
definition(
name: “Set Nest Mode”,
author: “Jordan Thurston”,
namespace: “”,
description: “Set Nest mode (Home/Away) based on hub mode.”,
category: “My Apps”,
iconUrl: “https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png”,
iconX2Url: “https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png
)

preferences {
section(“Change the status of the following Nest…”)
{
input (“nest”, “capability.thermostat”)
}
section(“To home with the following mode…”)
{
input(“presentMode”, “mode”, title: “Mode?”, required: false)
}
section(“And to away with the following mode…”)
{
input(“awayMode”, “mode”, title: “Mode?”, required: false)
}
}

def installed() {
log.debug(“Installed with settings: ${settings}”)
initialize()
}

def updated() {
log.debug(“Updated with settings: ${settings}”)
unsubscribe()
initialize()
}

def initialize() {
subscribe(location, locationChanged)
log.debug(“Starting to update ${nest.displayName} to home with mode ${presentMode} and to away with mode ${awayMode}.”)
}

def locationChanged(evt) {
def currentPresence = nest.currentPresence

if (currentPresence != “present” && presentMode == evt.value) {
log.debug(“Changing ${nest} to home”)
nest.present()
sendNotificationEvent(“And I changed ${nest} to Home.”)
} else if (currentPresence != “away” && awayMode == evt.value) {
log.debug(“Changing ${nest} to away”)
nest.away()
sendNotificationEvent(“And I changed ${nest} to Away.”)
}
}

I have an upstairs and a downstairs Nest. Does this code support multiple Nest in one house? I could be wrong but it doesn’t look like it?

Technically, you could just install this smart app on each. You could however make a simple change to allow you to select multiple Nest devices then loop through them in the code.

I’ve made the needed changes. Everything is working well. Thanks for starting the code off :wink:

Feel free to contribute on Github if you’re up for it!

Am I up for it? Hell yeah!!! :grin: Some cleanup still needed but here it is.