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

Add away functionality #3

Open
RandyLevensalor opened this issue Aug 18, 2012 · 1 comment
Open

Add away functionality #3

RandyLevensalor opened this issue Aug 18, 2012 · 1 comment

Comments

@RandyLevensalor
Copy link

Add this patch to set your structure as away or not.

diff --git a/nest.py b/nest.py
index 7fcf863..01de92d 100755
--- a/nest.py
+++ b/nest.py
@@ -17,6 +17,7 @@

Chris Burris's Siri Nest Proxy was very helpful to learn the nest's

authentication and some bits of the protocol.

+import time
import urllib
import urllib2
import sys
@@ -131,6 +132,7 @@ class Nest:

 def set_fan(self, state):
     data = '{"fan_mode":"' + str(state) + '"}'
  •   print data
     req = urllib2.Request(self.transport_url + "/v2/put/device." + self.serial,
                           data,
                           {"user-agent":"Nest/1.1.0.10 CFNetwork/548.0.4",
    
    @@ -141,6 +143,24 @@ class Nest:
    diff --git a/nest.py b/nest.py
    index 7fcf863..01de92d 100755
    --- a/nest.py
    +++ b/nest.py
    @@ -17,6 +17,7 @@

    Chris Burris's Siri Nest Proxy was very helpful to learn the nest's

    authentication and some bits of the protocol.

+import time
import urllib
import urllib2
import sys
@@ -131,6 +132,7 @@ class Nest:

 def set_fan(self, state):
     data = '{"fan_mode":"' + str(state) + '"}'
  •   print data
     req = urllib2.Request(self.transport_url + "/v2/put/device." + self.serial,
                           data,
                           {"user-agent":"Nest/1.1.0.10 CFNetwork/548.0.4",
    

    @@ -141,6 +143,24 @@ class Nest:

     print res
    
  • def set_away(self, state):

  •   time_since_epoch   = time.time()
    
  •   # time_since_epoch   = 1345299535
    
  •    if (state == "away"):
    
  •           data = '{"away_timestamp":' + str(time_since_epoch) + ',"away":true,"away_setter":0}'
    
  •   else:
    
  •           data = '{"away_timestamp":' + str(time_since_epoch) + ',"away":false,"away_setter":0}'
    
  •   print data
    
  •    req = urllib2.Request(self.transport_url + "/v2/put/structure." + self.structure_id,
    
  •                          data,
    
  •                          {"user-agent":"Nest/1.1.0.10 CFNetwork/548.0.4",
    
  •                           "Authorization":"Basic " + self.access_token,
    
  •                           "X-nl-protocol-version": "1"})
    
  •    res = urllib2.urlopen(req).read()
    
  •    print res
    

    def create_parser():
    parser = OptionParser(usage="nest [options] command [command_options] [command_args]",
    description="Commands: fan temp",
    @@ -161,7 +181,6 @@ def create_parser():
    parser.add_option("-i", "--index", dest="index", default=0, type="int",
    help="optional, specify index number of nest to talk to")

@RandyLevensalor
Copy link
Author

I also added changes to a fork.
https://github.com/RandyLevensalor/pynest.git

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant