forked from smbaker/pynest
-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
27 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,6 +115,11 @@ def show_curtemp(self): | |
|
||
print "%0.1f" % temp | ||
|
||
def show_curmode(self): | ||
mode = self.status["shared"][self.serial]["target_temperature_type"] | ||
|
||
print mode | ||
|
||
def set_temperature(self, temp): | ||
temp = self.temp_in(temp) | ||
|
||
|
@@ -141,6 +146,14 @@ def set_fan(self, state): | |
|
||
print res | ||
|
||
def set_mode(self, state): | ||
data = '{"target_temperature_type":"' + str(state) + '"}' | ||
req = urllib2.Request(self.transport_url + "/v2/put/shared." + self.serial, 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", | ||
|
@@ -175,11 +188,13 @@ def help(): | |
print " (use --serial or --index, but not both)" | ||
print "commands: temp, fan, show, curtemp, curhumid" | ||
print " temp <temperature> ... set target temperature" | ||
print " fan [auto|on] ... set fan state" | ||
print " show ... show everything" | ||
print " curtemp ... print current temperature" | ||
print " curhumid ... print current humidity" | ||
print " temp <temperature> ... set target temperature" | ||
print " fan [auto|on] ... set fan state" | ||
print " mode [cool|heat|range|off] ... set fan state" | ||
print " show ... show everything" | ||
print " curtemp ... print current temperature" | ||
print " curhumid ... print current humidity" | ||
print " curmode ... print current mode" | ||
print "examples:" | ||
print " nest.py --user [email protected] --password swordfish temp 73" | ||
|
@@ -218,10 +233,17 @@ def main(): | |
print "please specify a fan state of 'on' or 'auto'" | ||
sys.exit(-1) | ||
n.set_fan(args[1]) | ||
elif (cmd == "mode"): | ||
if len(args)<2: | ||
print "valid modes are cool, heat, range, and off" | ||
sys.exit(-1) | ||
n.set_mode(args[1]) | ||
elif (cmd == "show"): | ||
n.show_status() | ||
elif (cmd == "curtemp"): | ||
n.show_curtemp() | ||
elif (cmd == "curmode"): | ||
n.show_curmode() | ||
elif (cmd == "curhumid"): | ||
print n.status["device"][n.serial]["current_humidity"] | ||
else: | ||
|