View unanswered posts | View active topics It is currently Sun May 19, 2013 12:02 pm



Reply to topic  [ 42 posts ]  Go to page: Previous  1, 2, 3
 Nest Learning Thermostat 
Author Message

Joined: Oct 08, 2011
Posts: 74
Post 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.


Sun May 27, 2012 6:36 pm
Profile

Joined: Oct 17, 2004
Posts: 1107
Location: Rochester, Ny
Post 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


Mon May 28, 2012 1:38 pm
Profile WWW

Joined: Oct 08, 2011
Posts: 74
Post 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.


Mon May 28, 2012 1:58 pm
Profile

Joined: Oct 17, 2004
Posts: 1107
Location: Rochester, Ny
Post 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


Tue May 29, 2012 8:21 am
Profile WWW

Joined: Oct 08, 2011
Posts: 74
Post 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


Thu May 31, 2012 10:47 pm
Profile

Joined: Apr 15, 2012
Posts: 28
Post Re: Nest Learning Thermostat
Has anyone made any further progress with controlling the Nest?


Wed Jun 13, 2012 11:30 pm
Profile
User avatar

Joined: Sep 07, 2009
Posts: 39
Location: Seattle, WA
Post 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.


Tue Jun 19, 2012 5:53 pm
Profile WWW

Joined: Feb 01, 2012
Posts: 54
Post 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!


Wed Jun 20, 2012 9:42 pm
Profile

Joined: Apr 15, 2012
Posts: 28
Post 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?


Thu Jun 21, 2012 12:31 am
Profile

Joined: Feb 01, 2012
Posts: 54
Post 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.


Thu Jun 21, 2012 4:25 pm
Profile
User avatar

Joined: Sep 07, 2009
Posts: 39
Location: Seattle, WA
Post 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.


Thu Jun 21, 2012 5:50 pm
Profile WWW
User avatar

Joined: Sep 07, 2009
Posts: 39
Location: Seattle, WA
Post 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.


Tue Jun 26, 2012 5:50 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 42 posts ]  Go to page: Previous  1, 2, 3

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.   Template designed by STSoftware.