«

»

Apr 22 2017

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

14 comments

Skip to comment form

  1. Jim

    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!

  2. Chris

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

  3. doodie

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

  4. tops

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

  5. anarchist18

    hello, can you please explain the setup of grafana?

    1. anarchist18

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

        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

  6. anarchist18

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

      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

      1. romquenin

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

          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

          1. romquenin

            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

  7. 2KOA

    Could you please share your dashboard anarchist18 ? 🙂

  8. Svenja

    Hello

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

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*

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