Home Automation with TP-Link HS 100 plug

IoT, Raspberry PI and Amazon Lambda

Posted by Melania Andrisan    on July 26, 2017 in Dev tagged with Serverless, Cloud

A couple of weeks ago I got a plug, the TP-Link HS 100, from Holger to play with it and see what data can we use from it and if there is an use case we can integrate it in.

In case you are wondering what this plug does or how you can make use of it in your home you can have a look at their website. And if you decided to give it a try and measure your energy consumption with it you can configure it like this using the Kasa app from the Apple AppStore or Google Play.

Once you passed the normal user phase and want to take the power in your hands and create your own app being it to start the plug, to stop it or read the consumption elsewhere then their app, then you need to use an API. Unfortunatelly there is no API officially, but unofficialy you can use the one from George Vassilis which you can find on GITHUB. They even created a docker container to discover the plugs from your home and the docker container has this API deployed on it.

Ok, now we have a docker container and we need to deploy it somewhere in the house to make it available from our app. What I decided to do was to deploy it on my Raspberry Pi. To be able to install docker on your Raspberry Pi you need to follow this tutorial.

Ok, now I have this small application which is able to find all the plugs and deliver the current consumption if needed. Next I need to send this data somewhere and to make it available everywhere I am with my phone. What I did was to make a small node.js server which does this. And you can find it on Github. What it does is get the data from the plug using the previous docker container and send it to a service which is implemented using a Amazon Lambda function which gets this data and saves it in a Dynamo DB table.

And in this way, I have my plug info in my DB and from there I can take it whenever I need to: I can make reports or notifications or nice graphs.

Architecture Overview

Hope this helps you, till next time!