
For years I used X10 for all my remote controlled sockets but the unreliability eventually drove me to RF based sockets, the Home Easy ones in particular as you can’t beat the price, often available for circa £20 for a pack of 3 with a remote control and easily integrated into Node-RED and the likes with a simple 433MHz transmitter and receiver, the downside being there is no security.
Anyway, there are lots of affordable WiFi controlled sockets on the market now and a common one is the Orvibo S20, £15.99 on Amazon, a bit less from some sellers on ebay or under £11 from Banggood (be sure to select the right model for your country there).
They seem to be pretty well made and are small unobtrusive units. They are designed to work only with their proprietary Android and iPhone apps but there has been severalpieces of work done on reverse engineering the protocol and some libraries for various platforms already exist but it looked easy enough to knock something up in Node-RED so that’s what I did as it is the heart of my home automation system these days. This is just simple on/off control here, no point in messing with the built in timers when we have better control than that in Node-RED itself.
Communicating with the socket
First of all the socket needs to be configured to connect to your WiFi network, the easiest way to do this is just to install the Orvibo WiWo app and set it up there, check the socket actually works while you are at it and make a note of the sockets uid. No need to use the app again now, you can uninstall it if you like.
Communication with the socket is done via UDP broadcasts on port 10000 and first of all a packet needs to be sent to register with it, this registration times out after 5 minutes so I’m sending it before every command with a 300ms delay before the actual on/off command, less than this seemed a bit hit an miss and you may need to tweak this.
For simple on/off usage like this the packet format can be simplified to:
Subscribe: 6864001e636c[mac address]202020202020[mac address in little endian]202020202020
On/Off: 686400176463[mac address]20202020202000000000[00 for off, 01 for on]
You can grab a copy of my Node-RED flow to do that here.

I am using an MQTT topics of the format orvibo/0123456789ab where 0123456789ab is the MAC address of the particular socket (grab it from your router or it is also available as the first 12 digits of the uid displayed in the WiWo app) and the payload is just on or off as required. In Node-RED I then remap more readable names like appliances/heater to the relevant socket topic just as I do for the Home Easy and X10 modules.
Here is the code from the Node-RED function block:
// Get mac address from topic and place in array msg.topic = msg.topic.replace('orvibo/',''); var mac = []; for (var i = 0; i < msg.topic.length;) { mac.push("0x" + msg.topic.charAt(i) + msg.topic.charAt(i+1)); i = i+2; } var padding = [0x20,0x20,0x20,0x20,0x20,0x20]; var uid = mac.concat(padding); var uidLE = mac.reverse().concat(padding); // Build subscribe packet var command = [0x68,0x64,0x00,0x1e,0x63,0x6c]; var subscribe = command.concat(uid).concat(uidLE); // Build command packet command = [0x68,0x64,0x00,0x17,0x64,0x63]; if (msg.payload == "on") { var data = [0x00,0x00,0x00,0x00,0x01]; } else if (msg.payload == "off") { var data = [0x00,0x00,0x00,0x00,0x00]; } var packet = command.concat(uid).concat(data); msg = { payload: new Buffer(subscribe) }; var msg2 = { payload: new Buffer(packet) }; return [msg, msg2];
Anything else of interest?
As mentioned communication with the Orvibo sockets is over UDP so there is no guarantee that the packets arrive but it seems reliable so far and it does look like it is possible to query the status of the socket so that is something to look at as well.
It listens on port 10000 for the UDP broacast packets, I checked to see if there were any open TCP ports that might reveal something else but there was nothing open. It does connects to a couple of IP addresses though, 52.28.25.255 (an Amazon AWS instance) on port 10000 which seems to be part of the “cloud” service that allows you to use it from outside your own network as well as a (currently unreachable) Chinese IP 61.164.36.105 on port 123 which is SNTP so it could be part of the timer function but who knows what it really is. I don’t like things on my network connecting to unknown Chinese IPs and as I won’t be using the Orvibo app either I’ve blocked both of these IPs on my router and will monitor to see if it tries any others.