Although there are plenty of smart plugs currently available on the market, my choice was, as usual, hugely constrained by the requirement of maximum hackability of such a device. So I've decided to pick up the TP-Link HS110 smart plug, mainly because of this article: Reverse Engineering the TP-Link HS110, which describes many aspects of the plug in great detail, and also shows how to operate the plug using just a simple Python script (tplink-smartplug.py), so the integration with the home automation system of your choice (Domoticz in my case) is going be pretty straightforward.

First thing you should do is to reserve an IP address for your smart plug on your router. For this, you'll need plug's MAC address, which is written on the backside of the device (alternatively you can figure out the MAC address inside the companion Kasa application).

Then you can use tplink-smartplug.py to turn on/off the plug simply like so:

The nice thing about this plug is that it is operated simply via sending JSON requests, so it can be easily commanded and queried for various information. For example, I'm going to use the above real-time power consumption info for monitoring when my washing machine finishes its job (I'll keep this for next time though).

The final step is to integrate the plug with Domoticz (in my case running on a Raspberry PI). For this you will need to copy the control script into '~/domoticz/scripts/' and make it executable. This can be achieved via:

Then you can open Domoticz in your web browser, go to "Setup/Hardware" and add a new virtual hardware of the "Dummy" type. After that click on "Create Virtual Sensors" of the newly created virtual hardware, the bellow popup will appear:

Name the newly created sensor, and select "Switch" as its type. After that you will need to edit the switch and add the on/off actions: