TP Link HS110 smartplug linux monitoring with Grafana

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

TP-Link HS110 smart plug

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.

TP Link HS110 smart-plug general data : state, wireless signal, instant consumption, time running, total power consumption since start.

TP-Link HS110 smartplug current drawn

TP-Link HS110 smartplug voltage reading

TP-Link HS110 smartplug power consumption

TP-Link HS110 smartplug power consumption 2

TP-Link HS110 smartplug power consumption 3

15 comments

Skip to comment form

    • Jim on July 9, 2017 at 6:55 am
    • Reply

    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!

    • Chris on September 8, 2017 at 12:00 am
    • Reply

    I second the need for a tutorial. That would be really awesome!

    • doodie on September 27, 2017 at 6:37 am
    • Reply

    80/tcp HTTP
    9999/tcp TP-Link Smart Home Protocol
    1040/udp TP-Link Device Debug Protocol (TDDP)

    • tops on January 8, 2018 at 12:39 am
    • Reply

    Love to have a tutorial … the idea est so cool 🙂

    • anarchist18 on January 8, 2018 at 9:43 pm
    • Reply

    hello, can you please explain the setup of grafana?

      • anarchist18 on January 8, 2018 at 11:29 pm
      • Reply

      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

      1. 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

    • anarchist18 on January 24, 2018 at 12:38 am
    • Reply

    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?

    1. 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”

      Time span over 24 hours

        • romquenin on February 21, 2018 at 7:05 pm
        • Reply

        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

        1. 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

            • romquenin on February 23, 2018 at 6:38 pm

            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

    • 2KOA on July 13, 2018 at 7:49 pm
    • Reply

    Could you please share your dashboard anarchist18 ? 🙂

    • Svenja on September 2, 2018 at 3:23 pm
    • Reply

    Hello

    Unfortunately, I do not really understand what I have to do to record the values and get them in Grafana

    • Paul on October 15, 2018 at 6:26 pm
    • Reply

    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..

Leave a Reply

Your email address will not be published.

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.