Created
November 23, 2013 10:16
-
-
Save andete/7612927 to your computer and use it in GitHub Desktop.
Checking if my lab Philips Hue lamp is on and turning it on if needed:
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
#!/usr/bin/env python | |
import json | |
import requests | |
from settings import host, key | |
data = requests.get('http://%s/api/%s/lights/2' % (host, key)).json() | |
lamp_on = data['state']['on'] | |
print data | |
if not lamp_on: | |
payload = { u'on': True } | |
requests.put('http://%s/api/%s/lights/2/state' % (host, key), data=json.dumps(payload)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment