I just mashed together a simple websocket client in python. It works!
Here’s the output after using my Hue dim remote
# on
{"e":"changed","id":"1","r":"lights","state":{"on":true},"t":"event"}
{"e":"changed","id":"1","r":"sensors","state":{"buttonevent":1002,"lastupdated":"2017-07-24T17:11:16"},"t":"event"}
{"e":"changed","id":"1","r":"groups","state":{"any_on":true},"t":"event"}
{"e":"changed","id":"21098","r":"groups","state":{"any_on":true},"t":"event"}
# off
{"e":"changed","id":"1","r":"sensors","state":{"buttonevent":4000,"lastupdated":"2017-07-24T17:11:18"},"t":"event"}
{"e":"changed","id":"1","r":"sensors","state":{"buttonevent":4002,"lastupdated":"2017-07-24T17:11:18"},"t":"event"}
# brighter
{"e":"changed","id":"1","r":"sensors","state":{"buttonevent":2000,"lastupdated":"2017-07-24T17:12:16"},"t":"event"}
{"e":"changed","id":"1","r":"sensors","state":{"buttonevent":2002,"lastupdated":"2017-07-24T17:12:16"},"t":"event"}
# dimmer
{"e":"changed","id":"1","r":"sensors","state":{"buttonevent":3000,"lastupdated":"2017-07-24T17:12:17"},"t":"event"}
{"e":"changed","id":"1","r":"sensors","state":{"buttonevent":3002,"lastupdated":"2017-07-24T17:12:17"},"t":"event"}
Here’s the script. Nothing fancy:
import websocket
def on_message(ws, message):
print(message)
def on_error(ws, error):
print(error)
def on_close(ws):
print("### closed ###")
def on_open(ws):
print("### opened ###")
if __name__ == "__main__":
websocket.enableTrace(True)
ws = websocket.WebSocketApp(
"ws://192.168.178.23:443/",
on_message = on_message,
on_error = on_error,
on_close = on_close
)
ws.on_open = on_open
ws.run_forever()