Skip to content

Add away functionality #3

@RandyLevensalor

Description

@RandyLevensalor

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")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions