Commits

Jason R. Coombs committed ef53e0b

Added support for data parameters and the reboot command

Comments (0)

Files changed (1)

jaraco/home/thermostat.py

 import optparse
 import json
 import urlparse
+import urllib
 import urllib2
 from pprint import pprint
 
 thermostat = 'http://10.0.11.20'
 
-def request(path):
+def request(path, **params):
 	"""
 	Path is something like
 	/sys/info
 	/sys/network
 	/tstat/info
 	"""
+	data = urllib.urlencode(params) if params else None
 	url = urlparse.urljoin(thermostat, path)
-	req = urllib2.urlopen(url)
+	req = urllib2.urlopen(url, data)
 	res = json.load(req)
 	return res
 
 	path = args.pop(0)
 	pprint(request(path))
 
-	
+def reboot():
+	# from http://thermostat/update.shtml
+	pprint(request('/sys/cmd', command='reboot'))