I've gone through several different solutions over the years, one that was in for a while was X10 which used signals over the mains powerline through the house. This worked but had many flaws, ultimately the devices self-destructed as they couldn't cope with power spikes, etc, and because the equipment used the mains supply to transmit/receive it couldn't be protected using surge protectors, etc. So this was dropped.
I then experimented with the 433Mhz generic off the shelf controllable sockets. These are available from most retailers as Energenie sockets and generally come with a remote control and a combination of sockets. They work, but have limited range on the 433Mhz, again cannot be queried to find out if they are on or off and a lot of the commands are fire-and-forget (or hope for the best). I interfaced them with an Arduino using the 433Mhz transceiver pair but this still is a fire-and-forget so not really an ideal solution.
Onto my current idea, the TP-Link HS100 wireless switches:
Researching them, there has been a very good reverse engineering job at https://www.softscheck.com/en/reverse-engineering-tp-link-hs110/ and the author has also provided a python script that will let you query and talk to the devices. This fits exactly with my home automation system.
Now, don't get me wrong, there is a flaw here, these units when you set them up, you install their app to your phone and configure their details using the TP-Link 'cloud' system, which means giving the app your wifi SSID and password, which sends it to the smart switch using a temporary unsecured WIFI AP in setup mode. The unit then talks to the internet/TP-Link cloud for it's command and control. So far nothing here looks too bad, other than it having the ability to snoop your home network and talk to TP-Link! However, since we won't use the TP-Link cloud for our control we could simply drop this and not use it even for initial configuration. Furthermore we can send a command to the sockets to change the server they talk to, in theory cutting them off from TP-Link completely, which if you're paranoid you can do. I'm not too worried about this, so will probably just leave them at default.
So now I have a socket that I can setup a static IP in my DHCP scope, and then use the python utility to query and send commands.
To grab the python code you need, take a look at https://github.com/softScheck/tplink-smartplug
So I setup a script to query my socket and write the current state to a state-file on my home automation server, the script was very simple:
tplink-smartplug.py -t 192.168.xx.xx -c info | grep "Received" | cut -d ":" -f 23 | cut -d "," -f 1 > /tmp/tplink_plug1.outThat gives me either a 1 or a 0 depending on the current state of the socket. To set the state you simply use the python script again:
tplink-smartplug.py -t 192.168.xx.xx -c onIt's as simple as that.
I cannot comment on the longevity of the devices, but so far they are built well, easy to setup and super-easy to use. So I think this might be a new winner for home automation, the only thing I'd like to see is cost drop a little more, but when you think everything that's in the box £25 is pretty cheap!
Let me know your thoughts in the comments please or if you've found alternatives too.