Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing Presence to work with iOS app update #33

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 2 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,5 @@
# Nest Device Type
http://build.smartthings.com/projects/smartnest/
Please use the updated SmartApp found here:

Now SmartThings can talk to your Nest thermostat.
https://github.com/tonesto7/nest-manager

Note: this is technically against the Nest TOS. So use at your own risk.

## Installation

1. Create a new device type (https://graph.api.smartthings.com/ide/devices)
* Name: Nest
* Author: [email protected]
* Namespace: smartthings-users
* Capabilities:
* Polling
* Relative Humidity Measurement
* Thermostat
* Temperature Measurement
* Presence Sensor
* Sensor
* Custom Attributes:
* temperatureUnit
* Custom Commands:
* away
* present
* setPresence
* heatingSetpointUp
* heatingSetpointDown
* coolingSetpointUp
* coolingSetpointDown
* setFahrenheit
* setCelsius

1. Publish the device type (next to Save button) > For Me

1. If you want to switch from slider controls to buttons, comment out the slider details line and uncomment the button details line.

1. Create a new device (https://graph.api.smartthings.com/device/list)
* Name: Your Choice
* Device Network Id: Your Choice
* Type: Nest (should be the last option)
* Location: Choose the correct location
* Hub/Group: Leave blank

1. Update device preferences
* Click on the new device to see the details.
* Click the edit button next to Preferences
* Fill in your information.
* To find your serial number, login to http://home.nest.com. Click on the thermostat you want to control. Under settings, go to Technical Info. Your serial number is the second item.

1. That's it, you're done.
33 changes: 16 additions & 17 deletions nest.devicetype.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* Custom Commands:
* away
* present
* setPresence
* setNestPresence
* heatingSetpointUp
* heatingSetpointDown
* coolingSetpointUp
Expand Down Expand Up @@ -78,12 +78,11 @@ metadata {
capability "Relative Humidity Measurement"
capability "Thermostat"
capability "Temperature Measurement"
capability "Presence Sensor"
capability "Sensor"

command "away"
command "present"
command "setPresence"
command "setNestPresence"
command "heatingSetpointUp"
command "heatingSetpointDown"
command "coolingSetpointUp"
Expand Down Expand Up @@ -153,7 +152,7 @@ metadata {
state "default", label:'${currentValue}%', unit:"Humidity"
}

standardTile("presence", "device.presence", inactiveLabel: false, decoration: "flat") {
standardTile("nestPresence", "device.nestPresence", inactiveLabel: false, decoration: "flat") {
state "present", label:'${name}', action:"away", icon: "st.Home.home2"
state "not present", label:'away', action:"present", icon: "st.Transportation.transportation5"
}
Expand Down Expand Up @@ -197,8 +196,8 @@ metadata {
// To expose buttons, comment out the first detials line below and uncomment the second details line below.
// To expose sliders, uncomment the first details line below and comment out the second details line below.

details(["temperature", "thermostatOperatingState", "humidity", "thermostatMode", "thermostatFanMode", "presence", "heatingSetpoint", "heatSliderControl", "coolingSetpoint", "coolSliderControl", "temperatureUnit", "refresh"])
// details(["temperature", "thermostatOperatingState", "humidity", "thermostatMode", "thermostatFanMode", "presence", "heatingSetpointDown", "heatingSetpoint", "heatingSetpointUp", "coolingSetpointDown", "coolingSetpoint", "coolingSetpointUp", "temperatureUnit", "refresh"])
//details(["temperature", "thermostatOperatingState", "humidity", "thermostatMode", "thermostatFanMode", "nestPresence", "heatingSetpoint", "heatSliderControl", "coolingSetpoint", "coolSliderControl", "temperatureUnit", "refresh"])
details(["temperature", "thermostatOperatingState", "humidity", "thermostatMode", "thermostatFanMode", "nestPresence", "heatingSetpointDown", "heatingSetpoint", "heatingSetpointUp", "coolingSetpointDown", "coolingSetpoint", "coolingSetpointUp", "temperatureUnit", "refresh"])

// ============================================================

Expand Down Expand Up @@ -400,18 +399,18 @@ def setThermostatFanMode(mode) {
}

def away() {
setPresence('away')
sendEvent(name: 'presence', value: 'not present')
setNestPresence('away')
sendEvent(name: 'nestPresence', value: 'not present')
}

def present() {
setPresence('present')
sendEvent(name: 'presence', value: 'present')
setNestPresence('present')
sendEvent(name: 'nestPresence', value: 'present')
}

def setPresence(status) {
def setNestPresence(status) {
log.debug "Status: $status"
api('presence', ['away': status == 'away', 'away_timestamp': new Date().getTime(), 'away_setter': 0]) {
api('nestPresence', ['away': status == 'away', 'away_timestamp': new Date().getTime(), 'away_setter': 0]) {
poll()
}
}
Expand Down Expand Up @@ -480,15 +479,15 @@ def poll() {
break;
}

switch (device.latestValue('presence')) {
switch (device.latestValue('nestPresence')) {
case "present":
if (data.structure.away == 'away') {
sendEvent(name: 'presence', value: 'not present')
sendEvent(name: 'nestPresence', value: 'not present')
}
break;
case "not present":
if (data.structure.away == 'present') {
sendEvent(name: 'presence', value: 'present')
sendEvent(name: 'nestPresence', value: 'present')
}
break;
}
Expand Down Expand Up @@ -517,7 +516,7 @@ def api(method, args = [], success = {}) {
'fan_mode': [uri: "/v2/put/device.${settings.serial}", type: 'post'],
'thermostat_mode': [uri: "/v2/put/shared.${settings.serial}", type: 'post'],
'temperature': [uri: "/v2/put/shared.${settings.serial}", type: 'post'],
'presence': [uri: "/v2/put/structure.${data.structureId}", type: 'post']
'nestPresence': [uri: "/v2/put/structure.${data.structureId}", type: 'post']
]

def request = methods.getAt(method)
Expand Down Expand Up @@ -597,4 +596,4 @@ def cToF(temp) {

def fToC(temp) {
return ((temp - 32) / 1.8).toDouble()
}
}