The TP-Link HS110 smartplug has a mobile app that is not very useful. Digging through the internet i found a few scripts that can read data from it. I used a script with Grafana and Prometheus and made a nice dashboard with the collected data.
BASH – link
Python – link
Details about HS110 smartplug (from TP-Link website) :
Description : Wi-Fi Smart Plug with Energy Monitoring
– Remote Access : Control devices connected to the Smart Plug wherever you have Internet using the free Kasa app on your smartphone.
– Scheduling : Schedule the Smart Plug to automatically power electronics on and off as needed, like setting lights to come on at dusk or turn off at sunrise.
– Energy Monitoring : Analyze a device’s real-time and historical power consumption.
– Away Mode : Turns your devices on and off at different times to give the appearance that someone is home.
I used the python version of the script with python prometheus exporter. Below are my results. I’m using the TP-Link HS110 smartplug to measure the consumption of my fridge.
Below there are some screens with the last 24 hours info in Grafana.
15 comments
Skip to comment form
Any chance you could write up a guide on how you set this up? I would love to graph my TP-Link HS110’s with the rest of my SmartThings data in Grafana.
I have the python script working, but I am unfamiliar with everything you did beyond that.
Thanks in advance!
I second the need for a tutorial. That would be really awesome!
80/tcp HTTP
9999/tcp TP-Link Smart Home Protocol
1040/udp TP-Link Device Debug Protocol (TDDP)
Love to have a tutorial … the idea est so cool 🙂
hello, can you please explain the setup of grafana?
I have installed grafana 4.4.3 according to https://developer-blog.net/raspberry-pi-monitoring-mit-grafana/
I acces it through http:/locaip:3000
Can you tell me how to add data source for hs110 smart plug so I can have the graphs?
Regards,
Lucian
Author
Grafana is just for showing graphs. For storing data, you need Prometheus. Prometheus is one of the data stores for Grafana.
It is gathering data by polling info from exporters. Exporters are usually executable files that expose data on a port.
See this as an example for your raspberry : Raspberry exporter
Thanks I have something working finally:
https://imgur.com/a/kaSLq
I don’t understand the ‘total’ metric very well, in my opinion this is supposed to be the power consumption since the plug is on.
Also I want to ask how did you do the last graph ‘watts per hour’. How did you get the rectangular shape?
Author
The query must be : sum(increase(totalw[1h]))*1000 for the graph that spans over 24 hours. Also in “Time Range” tab override the time by using “24 hours”
Hello, and thank you for sharing. I would like to replicate your query but i can’t find the way to make it work.
When i try to directly type your code it’s not working.
This is what i have done so far:
https://imgur.com/yLzYXU7
when i had the 1 day interval it give me wrong values.
https://imgur.com/9LVW0IQ
Any kind of help would be amazing.
Thanks
Author
For me the data source is Prometheus. I think you are using InfluxDB. Am I right ?
You will need to figure out how to write the increse function in MySQL as in here : https://community.grafana.com/t/how-to-add-time-series-queries-with-grafana-and-mysql/3170/2
Ok, thank you very much.
Yes you are right, im using Influxdb with home assistant.
I will have a close look at it, I really want to get the values.
Thanks
Could you please share your dashboard anarchist18 ? 🙂
Hello
Unfortunately, I do not really understand what I have to do to record the values and get them in Grafana
Can You be of actual use and write step by step guide with needed hardware how to set this thing up? I think a lot of people would be interested to have detailed graphs as well. I am programmer and still have hard time to understand your setup..