Philips Hue: Difference between revisions
Jump to navigation
Jump to search
(→OSGi) |
(→Python) |
||
Line 25: | Line 25: | ||
===Python=== |
===Python=== |
||
* https://github.com/studioimaginaire/phue |
* https://github.com/studioimaginaire/phue |
||
<pre> |
|||
pip install phue |
|||
</pre> |
|||
<pre> |
|||
def do_PUT_HUE(self,driverParametersList,controlAskDict): |
|||
try: |
|||
if (controlAskDict["on"]=="true"): |
|||
controlAskDict["on"]=True |
|||
else: |
|||
controlAskDict["on"]=False |
|||
message=json.dumps(controlAskDict) |
|||
url = "192.168.1.80" |
|||
action= "/api/1234567890/lights/2/state" |
|||
headers = {"Content-type": "application/x-www-form-urlencoded","Accept": "text/plain"} |
|||
connection = HTTPConnection(url) |
|||
connection.request("PUT", action, message, headers) |
|||
response = connection.getresponse().read().decode('utf-8') |
|||
#print("response=%s status=%s"%(response.status, response.reason)) |
|||
print("Server's response : %s"%response) |
|||
connection.close() |
|||
</pre> |
|||
===OSGi=== |
===OSGi=== |
Revision as of 05:11, 31 January 2014
Set d'ampoules LED RGB zigbee avec un pont zigbee <--> ethernet.
Le pont peut piloter jusqu'à 50 ampoules.
L'API du pont est REST / JSON.
Liens
API
CURL
Node.js
Java
Python
pip install phue
def do_PUT_HUE(self,driverParametersList,controlAskDict): try: if (controlAskDict["on"]=="true"): controlAskDict["on"]=True else: controlAskDict["on"]=False message=json.dumps(controlAskDict) url = "192.168.1.80" action= "/api/1234567890/lights/2/state" headers = {"Content-type": "application/x-www-form-urlencoded","Accept": "text/plain"} connection = HTTPConnection(url) connection.request("PUT", action, message, headers) response = connection.getresponse().read().decode('utf-8') #print("response=%s status=%s"%(response.status, response.reason)) print("Server's response : %s"%response) connection.close()