Last active
January 15, 2019 03:46
-
-
Save EnriqueV/a78ca9fe4fc6c4e97171dad6d9797b49 to your computer and use it in GitHub Desktop.
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
import websocket | |
import json | |
import time | |
timer = '30000' | |
url = "ws://172.25.242.118/ws" | |
def on_message(ws, message): | |
obj = json.loads(message) | |
dev = obj['dev'] | |
circuit = obj['circuit'] | |
value = obj['value'] | |
print message | |
def on_error(ws, error): | |
print error | |
def on_close(ws): | |
print "Connection closed" | |
#recibe pulso | |
ws = websocket.WebSocketApp(url, on_message = on_message, on_error = on_error, on_close = on_close, timer) | |
ws.run_forever() | |
#envia parametro | |
ws = websocket.WebSocket() | |
ws.connect(url) | |
ws.send('{"cmd":"set","dev":"relay","circuit":"","value":""}') | |
ws.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment