Giter Club home page Giter Club logo

tplink-plug-exporter's Introduction

tplink-plug-exporter

Export TP-Link Smart Plug metrics to grafana dashboard

Install

Download from releases or run from docker

docker run -d -p 9233:9233 fffonion/tplink-plug-exporter

Usage

Use the -h flag to see full usage:

$ tplink-plug-exporter -h
Usage of tplink-plug-exporter:
  -metrics.listen-addr string
        listen address for tplink-plug exporter (default ":9233")

Grafana dashboard

Search for Kasa inside grafana or install from https://grafana.com/grafana/dashboards/10957 img

Sample prometheus config

# scrape kasa devices
scrape_configs:
  - job_name: 'kasa'
    static_configs:
    - targets:
      # IP of your smart plugs
      - 192.168.0.233
      - 192.168.0.234
    metrics_path: /scrape
    relabel_configs:
      - source_labels : [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        # IP of the exporter
        replacement: localhost:9233

# scrape kasa_exporter itself
  - job_name: 'kasa_exporter'
    static_configs:
      - targets:
        # IP of the exporter
        - localhost:9233

Docker Build Instructions

Build for both arm64 and amd64:

docker build -t <image-name>:latest-arm64 --platform linux/arm64 --build-arg GOARCH=arm64 .
docker build -t <image-name>:latest-amd64 --platform linux/amd64 --build-arg GOARCH=amd64 .

Merge them in one manifest:

docker manifest create <image-name>:latest --amend <image-name>:latest-arm64 --amend <image-name>:latest-amd64
docker manifest push <image-name>:latest

See also

tplink-plug-exporter's People

Contributors

dpunkturban avatar dswarbrick avatar fffonion avatar jangrewe avatar m0nsterrr avatar muvaf avatar rhermes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tplink-plug-exporter's Issues

Support for HS300 Power Strip

Loving this exporter, but I'm targeting it against my HS300 Power Strip and it appears to only be pulling one plugs power wattage. Is there a way to make it pull either each one individually (like its 6 HS110s) or just pull an aggregate for the whole strip?

Does not work on Kasa KP125M

This does not seem to work with Kasa KP125M.

time="2023-12-27T03:59:47Z" level=error msg="error collecting 192.168.3.13 : system.get_sysinfo: dial tcp 192.168.3.13:9999: connect: connection refused" source="exporter.go:97"
time="2023-12-27T03:59:48Z" level=error msg="error collecting 192.168.3.14 : system.get_sysinfo: dial tcp 192.168.3.14:9999: connect: connection refused" source="exporter.go:97"
time="2023-12-27T04:00:02Z" level=error msg="error collecting 192.168.3.13 : system.get_sysinfo: dial tcp 192.168.3.13:9999: connect: connection refused" source="exporter.go:97"
time="2023-12-27T04:00:03Z" level=error msg="error collecting 192.168.3.14 : system.get_sysinfo: dial tcp 192.168.3.14:9999: connect: connection refused" source="exporter.go:97"
time="2023-12-27T04:00:17Z" level=error msg="error collecting 192.168.3.13 : system.get_sysinfo: dial tcp 192.168.3.13:9999: connect: connection refused" source="exporter.go:97"

Hardware version 1.0
Firmware version 1.1.4 Build 231019 Rel 174214

Google search reveals TP-Link blocked off API access or changed the API?

Not Really An Issue - But What Is emeter["power"]?

I have an HS110 that still has old firmware and I can monitor it off port 9999. I get the emeter information:

{"emeter":{"get_realtime":{"current":0.020707,"voltage":124.223949,"power":0.371734,"total":1.040000,"err_code":0}}}

and understand the following to be the case:

current is amps,
voltage is volts,
total is kwHs.

But what is power? I thought it was watts. But I am not sure at all now as I cannot seem to compute the values I see from the current and voltage I see in the same entry. This would seem to be single phase, 120v, USA utility power. So it would seen this formula would apply:

P = PF × I × U
where:
P – Power or wattage;
PF – Power factor;
I – Electrical current; and
U – Voltage.

And I understand that the power factor varies from 0 to 1 where 1 represents the most efficient use of power and 0 means the opposite.

So if "power" is in watts, the value displayed should be 0.020707 *124.223949 * something between 0 and 1.

But I can only get close to the power result being displayed by using PF of .15 which would seem rather low (but I am not sure of this). So is that the PF the unit is employing? Does this make sense? I am monitoring a deep freezer.

Thanks

Not getting any metrics

Hi,

One of my smart plugs (H110, hardware version 4.1, firmware version 1.1.0) is not returning on any metrics. It used to work before, but I had to move the plug and when I plugged it back in, I stopped receiving metrics for it.

Here is what I see on Prometheus.

# HELP kasa_online Device online.
# TYPE kasa_online gauge
kasa_online 0

I am currently using the tplink-plug-exporter_0.4.0_linux_armv7.tar.gz of the exporter on a Raspberry PI 4. my other two plugs seem to be fine ( I can see metrics for them). But they are on hardware version 1.0 and firmware version 1.2.6, not sure if that has a impact. All three plugs are on the same 2.4GH network.

In the logs I see the following

level=error msg="error collecting 192.168.1.181 : system.get_sysinfo: dial tcp 192.168.1.181:9999: connect: connection refused" source=

I can see data for all free plus when using the Kasa app on my Android device,

Does this work with the new plugs such as P110?

I am not sure if this has been tested but since Kasa plugs are mostly discontinued, do you know if this is compatible with P110 plugs which are the new "replacements"? This is not available in all regions and I used one that I could find that has the full specs.

server returned HTTP status 404 Not Found

@fffonion

I configured prometheus with your prometheus.yml configs. I have updated the IP addresses to my TP link smart plugs.

Prometheus starts but I'm getting "server returned HTTP status 404 Not Found" for my 2 plugs. They are the HS110 model with latest firmware.

Any ideas?

Energy consumptions problem

Hello,

When I want to check metrics datas on my hs110 devices, I use :
curl -L http://localhost:9233/scrape?target=192.168.0.12

This is what he shows

curl -L http://localhost:9233/scrape?target=192.168.0.12
# HELP kasa_current Current flowing through device in Ampere.
# TYPE kasa_current gauge
kasa_current{alias="vidéoprojecteur"} 0
# HELP kasa_on_time Time in seconds since online.
# TYPE kasa_on_time counter
kasa_on_time{alias="vidéoprojecteur"} 357610
# HELP kasa_online Device online.
# TYPE kasa_online gauge
kasa_online 1
# HELP kasa_power_load Power of load in Watt.
# TYPE kasa_power_load gauge
kasa_power_load{alias="vidéoprojecteur"} 0
# HELP kasa_power_total Power of load and device itself in Watt.
# TYPE kasa_power_total gauge
kasa_power_total{alias="vidéoprojecteur"} 0
# HELP kasa_relay_state Relay state (switch on/off).
# TYPE kasa_relay_state gauge
kasa_relay_state{alias="vidéoprojecteur"} 1
# HELP kasa_rssi Wifi received signal strength indicator.
# TYPE kasa_rssi gauge
kasa_rssi{alias="vidéoprojecteur"} -35
# HELP kasa_voltage Current voltage connected to device in Volt.
# TYPE kasa_voltage gauge
kasa_voltage{alias="vidéoprojecteur"} 0

Do you know why I don't have all the datas ?
My plugs send well all the consumption informations on the android app.

Grafana: Total Power stat

Hi, thanks for the exporter and dashboard!
I noticed that in the "Total Power" singlestat (top right) you're adding the load (in Watts) to the total power (in Kilowatthours), which kinda doesn't make much sense, as the value would go down with a lower load. Maybe use just the total power in there? 🙂

Not all metrics are being picked up in grafana/prometheus

I've got the TPLink Extension plug KP303 and not all the panels have data.
Total Power, Power, Current, Voltage, and Energy Usage don't have any data and I've gone to check the metrics in Prometheus and they don't exist.

It might be worth mentioning I manually downloaded the file and created a system file to get it running. I've installed it on a RPi which doesn't have docker installed.

It's picking up data for the other panels so I know the exporter is some-what working.

Has anyone else experienced this?

Also, great job on putting this repo together!

image

License / copyright information

This project currently doesn't have a license declared or mention of who owns the copyright. Is there any chance you could bundle a file describing the license?

Thanks :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.