Nest Learning Thermostat

Posted on
Sun May 27, 2012 6:36 pm
ryanbuckner offline
Posts: 1074
Joined: Oct 08, 2011
Location: Northern Virginia

Re: Nest Learning Thermostat

I wound up using the shell do command and realized that json was not installed on my Python 2.5 version.

Posted on
Mon May 28, 2012 1:38 pm
bschollnick2 offline
Posts: 1355
Joined: Oct 17, 2004
Location: Rochester, Ny

Re: Nest Learning Thermostat

ryanbuckner wrote:
I wound up using the shell do command and realized that json was not installed on my Python 2.5 version.


JSON is easy enough to enable for the python install, but you can't do it as an embedded python script. You have to do it as an external script....

------
My Plugins for Indigo (v4, v5, and v6) - http://bit.ly/U8XxPG

Security Script for v4 - http://bit.ly/QTgclf
for v5 - http://bit.ly/T6WBKu

Support Forum(s) - http://www.perceptiveautomation.com/userforum/viewforum.php?f=33

Posted on
Mon May 28, 2012 1:58 pm
ryanbuckner offline
Posts: 1074
Joined: Oct 08, 2011
Location: Northern Virginia

Re: Nest Learning Thermostat

bschollnick2 wrote:
ryanbuckner wrote:
I wound up using the shell do command and realized that json was not installed on my Python 2.5 version.


JSON is easy enough to enable for the python install, but you can't do it as an embedded python script. You have to do it as an external script....


Ok. Once I get the commands working from terminal I'll creaet an external script. I understand that JSON was included with 2.6 and I have 2.5. Better to upgrade Python or find and install the JSON module? Sorry, not a python guy.

Posted on
Tue May 29, 2012 8:21 am
bschollnick2 offline
Posts: 1355
Joined: Oct 17, 2004
Location: Rochester, Ny

Re: Nest Learning Thermostat

ryanbuckner wrote:
bschollnick2 wrote:
ryanbuckner wrote:
I wound up using the shell do command and realized that json was not installed on my Python 2.5 version.


JSON is easy enough to enable for the python install, but you can't do it as an embedded python script. You have to do it as an external script....


Ok. Once I get the commands working from terminal I'll creaet an external script. I understand that JSON was included with 2.6 and I have 2.5. Better to upgrade Python or find and install the JSON module? Sorry, not a python guy.


Download Simplejson v2.52 (which is the same as included in v2.7), and unarchive the package. Take the simplejson folder and place it into your python scripts folder. From your script, you would then "import simplejson". That will import the simplejson package, so that you can use it within your script.

------
My Plugins for Indigo (v4, v5, and v6) - http://bit.ly/U8XxPG

Security Script for v4 - http://bit.ly/QTgclf
for v5 - http://bit.ly/T6WBKu

Support Forum(s) - http://www.perceptiveautomation.com/userforum/viewforum.php?f=33

Posted on
Thu May 31, 2012 10:47 pm
ryanbuckner offline
Posts: 1074
Joined: Oct 08, 2011
Location: Northern Virginia

Re: Nest Learning Thermostat

Tonight I was able to get Nest values populated into Indigo variables with some simple Applescript and Scott Baker's nest.py python tool.

I'm sure there are much better ways to do what I have accomplished below. As you can see I have 2 Nest thermostats. 1 for the upstairs zone and another for the downstairs. I'm happy to modify this process for something more efficient:

Code: Select all
set nestDSTemp to do shell script "/usr/local/bin/nest.py --user joe@example.com --password swordfish --serial <your_serial> curtemp"
set nestDSHumid to do shell script "/usr/local/bin/nest.py --user joe@example.com --password swordfish --serial <your_serial> curhumid"
set nestUSTemp to do shell script "/usr/local/bin/nest.py --user joe@example.com --password swordfish --serial <your_seria2l> curtemp"
set nestUSHumid to do shell script "/usr/local/bin/nest.py --user joe@example.com --password swordfish --serial <your_serial2> curhumid"

tell application "IndigoServer"
   set value of variable "downstairsNestTemp" to nestDSTemp
   set value of variable "upstairsNestTemp" to nestUSTemp
   set value of variable "upstairsNestHumid" to nestUSHumid
   set value of variable "downstairsNestHumid" to nestDSHumid
end tell

Posted on
Wed Jun 13, 2012 11:30 pm
CaliChris offline
Posts: 38
Joined: Apr 15, 2012

Re: Nest Learning Thermostat

Has anyone made any further progress with controlling the Nest?

Posted on
Tue Jun 19, 2012 5:53 pm
Chompy offline
User avatar
Posts: 84
Joined: Sep 07, 2009
Location: Seattle, WA

Re: Nest Learning Thermostat

Thanks for posting the script you used, Ryan. I modified it slightly to pull the temperature & humidity from my nest.

It would be nice to see someone create a plugin that reads more of the nest's states, such as whether it's in away mode or if the AC is currently running.

Posted on
Wed Jun 20, 2012 9:42 pm
Fishysan offline
Posts: 86
Joined: Feb 01, 2012

Re: Nest Learning Thermostat

Chompy, don't have a Nest yet - lack of API/Indigo connectivity a big reason, but might change with Scott's py

particularly as I want to have the "circ" mode - enable the fan for 10min/hr, etc.

from his site; http://www.smbaker.com/a-python-api-for ... thermostat

would some of the true/false states maybe give you information about whether it's running?

auto_away.......................: 0

fan_cooling_state...............: False
or one of these?
hvac_ac_state...................: False
hvac_fan_state..................: False
hvac_heater_state...............: False

Since I don't have one I can't try it. :)

Do let us know if these states change based on whether it's active!

Thanks for posting about what you've been doing Ryan!

Posted on
Thu Jun 21, 2012 12:31 am
CaliChris offline
Posts: 38
Joined: Apr 15, 2012

Re: Nest Learning Thermostat

Chompy wrote:
Thanks for posting the script you used, Ryan. I modified it slightly to pull the temperature & humidity from my nest.

It would be nice to see someone create a plugin that reads more of the nest's states, such as whether it's in away mode or if the AC is currently running.


Can you post it?

Posted on
Thu Jun 21, 2012 4:25 pm
Fishysan offline
Posts: 86
Joined: Feb 01, 2012

Re: Nest Learning Thermostat

Seems like on/off states are indeed retrievable (thanks Scott for that work!!)

Might have to get one too, instead of an Insteon based one (though would prefer full api, but haven't been a fan yet of Insteon ones - the new one is nicer, but need to wait it out likely)

From this blog, Aaron (thanks too!) confirms the on off state of the heat;
http://www.wiredprairie.us/blog/index.php/archives/1442
Next, a payload is returned with the new status:

"status": 200,
"headers": {
"X-nl-skv-key": "shared.#DEVICE 2 SERIAL NUMBER#",
"X-nl-skv-version": 1689916148,
"X-nl-skv-timestamp": 1326038378000,
"X-nl-service-timestamp": 1326038379151
},
"payload": {
"hvac_fan_state": false,
"name": "TWO",
"hvac_heat_x2_state": false,
"hvac_ac_state": false,
"can_cool": true,
"auto_away": 0,
"compressor_lockout_enabled": false,
"target_temperature_low": 16.66667,
"current_temperature": 19.53,
"target_temperature_high": 26.66667,
"compressor_lockout_timeout": 0,
"target_change_pending": false,
"hvac_aux_heater_state": false,
"target_temperature": 20.55556,
"can_heat": true,
"target_temperature_type": "heat",
"hvac_heater_state": true
}
Here, the hvac_heater_state is set to true. The furnace is on.

A little while later, that value is set to false.

Posted on
Thu Jun 21, 2012 5:50 pm
Chompy offline
User avatar
Posts: 84
Joined: Sep 07, 2009
Location: Seattle, WA

Re: Nest Learning Thermostat

Thanks guys. I figured out that if I added lines with keys from nest.py's show command near the bottom of the script, I could pull any of the keys defined. Some keys require "device" rather than "shared" though.

For example:
Code: Select all
    elif (cmd == "coolstate"):
        print n.status["shared"][n.serial]["hvac_ac_state"]
    elif (cmd == "heatstate"):
        print n.status["shared"][n.serial]["hvac_heater_state"]
    elif (cmd == "fanstate"):
        print n.status["shared"][n.serial]["hvac_fan_state"]


It just needs to go in the elif statements near the bottom of the script body. Afterward, just "chmod 755 nest.py" in Terminal to make it executable again.

I hope this helps anyone else that's trying to pull variables from their nest.

Posted on
Tue Jun 26, 2012 5:50 pm
Chompy offline
User avatar
Posts: 84
Joined: Sep 07, 2009
Location: Seattle, WA

Re: Nest Learning Thermostat

Chris: Here's the modified nest.py file: http://www.4shared.com/folder/utuGOkuL/_online.html Click "nest.py" off to the right of that page. I'm sure I'll eventually incorporate all possible values from the nest, but this does what I want for now.

You will need to place nest.py in /usr/local/bin/ and create the following variables in Indigo:

nestCooling
nestFan
nestHeating
nestHumid
nestLeaf
nestTargetTemp
nestTemp

My ugly applescript to populate the variables is below. I run this script every 15 minutes. I'm thinking about adding a synchrolinc to my AC unit to have it poll the nest every time the AC kicks on or off.
Code: Select all
set nestTemp to do shell script "/usr/local/bin/nest.py --user NESTLOGIN --password NESTPASSWORD curtemp"
set nestHumid to do shell script "/usr/local/bin/nest.py --user NESTLOGIN --password NESTPASSWORD curhumid"
set nestCooling to do shell script "/usr/local/bin/nest.py --user NESTLOGIN --password NESTPASSWORD coolstate"
set nestHeating to do shell script "/usr/local/bin/nest.py --user NESTLOGIN --password NESTPASSWORD heatstate"
set nestFan to do shell script "/usr/local/bin/nest.py --user NESTLOGIN --password NESTPASSWORD fanstate"
set nestTargetTemp to do shell script "/usr/local/bin/nest.py --user NESTLOGIN --password NESTPASSWORD targettemp"
set nestLeaf to do shell script "/usr/local/bin/nest.py --user NESTLOGIN --password NESTPASSWORD leaf"

if nestCooling is "False" then set nestCooling to "false"
if nestCooling is "True" then set nestCooling to "true"

if nestHeating is "False" then set nestHeating to "false"
if nestHeating is "True" then set nestHeating to "true"

if nestFan is "False" then set nestFan to "false"
if nestFan is "True" then set nestFan to "true"

if nestLeaf is "False" then set nestLeaf to "false"
if nestLeaf is "True" then set nestLeaf to "true"

set nestTargetTemp to (round nestTargetTemp rounding as taught in school)

tell application "IndigoServer"
   set value of variable "nestTemp" to nestTemp
   set value of variable "nestHumid" to nestHumid
   set value of variable "nestCooling" to nestCooling
   set value of variable "nestHeating" to nestHeating
   set value of variable "nestFan" to nestFan
   set value of variable "nestTargetTemp" to nestTargetTemp
   set value of variable "nestLeaf" to nestLeaf
end tell


This script has nest.py run 7 times. (once per variable) I need to figure out how to make it populate all the variables in one run, but I'm not that great at python or applescript.

Who is online

Users browsing this forum: No registered users and 9 guests