- Philips Hue API (api documentation)
- Hack the Hue (fine intro)
- Json put exaples (google)
Json
You can program Philips Hue via the Json based API and methods like GET, POST and PUT. The bridge has a nice API interface on:
http://192.168.0.xyz/api/YOUR-NUMBER-HERE/lights/1/state
Here you'll get a testing GUI to use when experimenting with the API methods.
Experiment with JavaScript and Json
Copypasted a json sample from W3 Schools, and console.logged the result. Surprisingly the console got the json object.
console.log result |
Python: Idle session
Python 2.7.9 (default, Apr 2 2015, 15:33:21)
[GCC 4.9.2] on linux2
>>> import requests
>>> import json
>>> taend = json.dumps({"on":False})
>>> r = requests.put("http://192.168.0.xxx/api/your-secret-code/groups/0/action", data=taend)
All lamps went out out, so a success it was.
Bash Experiment
curl -X PUT -d "{\"on\":true}" http://192.168.0.xxx/api/your-secret-code/groups/0/action
Since it's possible to use curl in PHP the same thing must be possible in PHP.
No comments:
Post a Comment