Skip to content

Instantly share code, notes, and snippets.

@KelSolaar
Created November 19, 2012 08:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KelSolaar/4109616 to your computer and use it in GitHub Desktop.
Save KelSolaar/4109616 to your computer and use it in GitHub Desktop.
Philips Hue - On
import json
import urllib2
def hueOn(address, client, on=True):
for light in (1, 2, 3):
url = "http://%s/api/%s/lights/%s/state" % (address, client, light)
request = urllib2.Request(url, json.dumps({"on": on}))
request.get_method = lambda: "PUT"
response = urllib2.urlopen(request)
hueOn("192.168.0.5", "25bebfd9e3d966783278c476011e2321", True)
@natcl
Copy link

natcl commented Nov 19, 2012

Here's a working library if you want to explore a bit:
https://github.com/studioimaginaire/phue

@KelSolaar
Copy link
Author

Very clean!

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment