On/off control of the Orvibo S20 Smart Sockets. More info here.
-
-
Save nathanchantrell/7dd0f897e7ea7c600165 to your computer and use it in GitHub Desktop.
Orvibo S20 WiFi Mains Sockets
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
[{"id":"32a2fac0.cd5d06","type":"mqtt-broker","broker":"localhost","port":"1883","clientid":""},{"id":"5c877283.a3788c","type":"udp out","z":"3c0defcd.c3f21","name":"","addr":"255.255.255.255","iface":"","port":"10000","ipv":"udp4","outport":"","base64":false,"multicast":"broad","x":718,"y":831,"wires":[]},{"id":"9ec80023.6138","type":"delay","z":"3c0defcd.c3f21","name":"","pauseType":"delay","timeout":"300","timeoutUnits":"milliseconds","rate":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":502,"y":858,"wires":[["5c877283.a3788c"]]},{"id":"3d8d399.fc272c6","type":"function","z":"3c0defcd.c3f21","name":"Orvibo S20 WiFi Sockets","func":"// Read my blog post about this here: https://nathan.chantrell.net/20160101/orvibo-s20-wifi-mains-socket-with-node-red\n\n// Get mac address from topic and place in array\nmsg.topic = msg.topic.replace('orvibo/','');\nvar mac = [];\nfor (var i = 0; i < msg.topic.length;) {\n mac.push(\"0x\" + msg.topic.charAt(i) + msg.topic.charAt(i+1));\n i = i+2;\n}\nvar padding = [0x20,0x20,0x20,0x20,0x20,0x20];\nvar uid = mac.concat(padding);\nvar uidLE = mac.reverse().concat(padding);\n\n// Build subscribe packet\nvar command = [0x68,0x64,0x00,0x1e,0x63,0x6c];\nvar subscribe = command.concat(uid).concat(uidLE);\n\n// Build command packet\ncommand = [0x68,0x64,0x00,0x17,0x64,0x63];\nif (msg.payload == \"on\") {\n var data = [0x00,0x00,0x00,0x00,0x01];\n} else if (msg.payload == \"off\") {\n var data = [0x00,0x00,0x00,0x00,0x00];\n}\nvar packet = command.concat(uid).concat(data);\n\nmsg = { payload: new Buffer(subscribe) };\nvar msg2 = { payload: new Buffer(packet) };\n\nreturn [msg, msg2];\n","outputs":"2","noerr":0,"x":299,"y":839,"wires":[["5c877283.a3788c"],["9ec80023.6138"]]},{"id":"881a23a6.77e5e","type":"mqtt in","z":"3c0defcd.c3f21","name":"","topic":"orvibo/#","broker":"32a2fac0.cd5d06","x":109,"y":839,"wires":[["3d8d399.fc272c6"]]}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment