Comments (14)
I somehow missed this notification, will get you some info soon.
from tplink-plug-exporter.
Hi @tideline3d I don't have a HS300 on my side to test, but I read that it uses same kasa protocol and probably have an extra rpc function to pull power consumption for whole strip. Any dump will be helpful like using tools from https://github.com/softScheck/tplink-smartplug.
from tplink-plug-exporter.
Here's the output of a couple of the commands from that tool. Let me know if you need something else?
-c energy output
"emeter": {
"get_realtime": {
"voltage_mv": 121487,
"current_ma": 785,
"power_mw": 92388,
"total_wh": 16769,
"err_code": 0
}
}
-c info output
"system": {
"get_sysinfo": {
"sw_ver": "1.0.19 Build 200224 Rel.090814",
"hw_ver": "1.0",
"model": "HS300(US)",
"deviceId": "80065BD45F0CE05BE7807BA186CCB7871B25D4B2",
"oemId": "5C9E6254BEBAED63B2B6102966D24C17",
"hwId": "34C41AA028022D0CCEA5E678E8547C54",
"rssi": -57,
"longitude_i": 0,
"latitude_i": -778794,
"alias": "TP-LINK_Power Strip_0786",
"status": "new",
"mic_type": "IOT.SMARTPLUGSWITCH",
"feature": "TIM:ENE",
"mac": "D8:0D:17:D8:07:86",
"updating": 0,
"led_off": 0,
"children": [
{
"id": "80065BD45F0CE05BE7807BA186CCB7871B25D4B200",
"state": 1,
"alias": "E3-Green",
"on_time": 843976,
"next_action": {
"type": -1
}
},
{
"id": "80065BD45F0CE05BE7807BA186CCB7871B25D4B201",
"state": 1,
"alias": "RPi-Red",
"on_time": 822261,
"next_action": {
"type": -1
}
},
{
"id": "80065BD45F0CE05BE7807BA186CCB7871B25D4B202",
"state": 0,
"alias": "E3-Blue",
"on_time": 0,
"next_action": {
"type": -1
}
},
{
"id": "80065BD45F0CE05BE7807BA186CCB7871B25D4B203",
"state": 0,
"alias": "Air Filter",
"on_time": 0,
"next_action": {
"type": -1
}
},
{
"id": "80065BD45F0CE05BE7807BA186CCB7871B25D4B204",
"state": 1,
"alias": "RPi-Blue",
"on_time": 1380538,
"next_action": {
"type": -1
}
},
{
"id": "80065BD45F0CE05BE7807BA186CCB7871B25D4B205",
"state": 1,
"alias": "E3-Red",
"on_time": 1380537,
"next_action": {
"type": -1
}
}
],
"child_num": 6,
"err_code": 0
}
}
}
from tplink-plug-exporter.
@tideline3d Thanks! With that I guess we can at least have the children
status. I'm wondering if HS300 support per socket energy meter function. Are you able to view that using the Kasa app?
from tplink-plug-exporter.
Yes, I can see individual power on the app. I use this plugin for OctoPrint that will pull energy from an individual plug for its statistics. But would much rather have all that flowing into Prometheus.
Here's the plugin code that does it, forgive me for not really knowing python well enough to point you any further :)
from tplink-plug-exporter.
@tideline3d nvm, I find a similar one https://github.com/python-kasa/python-kasa/blob/master/kasa/smartstrip.py which appears to be more readable. I will draft a PR now.
from tplink-plug-exporter.
@tideline3d wanna try #9 😄 ?
I attached a linux-amd64 build below as well:
tplink-plug-exporter.gz
from tplink-plug-exporter.
@fffonion I threw it on DockerHub so I could test it easier (for me at least). It seems to work, but a few oddities. Here's the output that seems to be working!
Potential Issues I found:
1 - Duplicate plug names throw an error. I assume since they were just a string, they shouldn't be used for anything? Here I had two of my plugs labeled 'Empty'. Changing one to 'Empty2' got around this.
2 - I'm getting spotty results from the scrape. It seems to scrape fine, but after a few tries I'll get empty results. My scrape interval is ambitious at 5s. Though I can cause this reliably by just refreshing a browser. Is that a 'feature' of the Kasa device just not liking that much traffic?
3 - The 'TPLink _PowerStrip' item appears to be the aggregate, but that causes totals in your default dashboard to get weird. Not sure if this will cause problems later. I'd personally be fine ignoring the total from the device and only presenting the 6 plugs, ignoring the parent. But not sure if that works for all?
from tplink-plug-exporter.
Occasionally I'll get a partial response when hitting the scrape endpoint as well.
Instead of
from tplink-plug-exporter.
@tideline3d Woohoo it works! Thanks for taking time testing this!
- Yeah that's an issue we need to address. I'll probably add the child_id as a label to child plugs. Since for HS1xx the IP address is also attached as label automatically, so they are not affected before.
- It appears from my test that the TCP server on those plugs are single-threaded, if the previous scrape didn't end, then your next scrape will hang. It's a good idea to consult "Targets" page of your prometheus, and see how long does prometheus finish a scrape for one target, then use a scrape interval longer than the single scrape. But it could also be some bug with exporter, I'll log out the err in next commit.
- That's a good point, I was thinking this yesterday as well.
It probably makes sense to use a different metrics for the total if it's a powerstrip.Since we now have child_id label on child plugs, we can just exclude them children and only use the powerstrip for computing total. I will update the dashboard.
from tplink-plug-exporter.
I have made some improvement to the exporter. Now every metrics has an id
label, when calculating total, we should use sum(kasa_power_load{id=~".{40}")
to exclude child plugs.
from tplink-plug-exporter.
I'll try this later today, but I'm not sure using the strip's power usage is actually accurate? Most of the time, mine doesn't add up to the sum of its children. However I'm running 3D printers here which fluctuate power ALOT in turning on/off the heaters, so its possible that its just an artifact of the really quick power spikes they generate?
An example from your dashboard. Note the orange is never the sum of the other items, its only as large as one of them at a given time? This is all from the original PR, not the update. Curious if that update approach is actually accurate given the data here? Another option might be to just ignore the parent and treat the strip as 6 HS110 plugs?
And another example from power total dashboard element. I would expect the purple line here to be a sum of all the other ones (and then as it stands, green being an aggregation of both of those)
from tplink-plug-exporter.
Hmmmm that's interesting, I'd double check does the power number adds up in the Kasa app? If it does, then there must be either the strip or the child plugs has wrong number: could you share on which one doesn't match to that exports to prometheus?
from tplink-plug-exporter.
@tideline3d I merged the PR and it closes this issue. Feel free to reopen or create a new issue if the feature is not working.
from tplink-plug-exporter.
Related Issues (10)
- Energy consumptions problem HOT 10
- Not getting any metrics HOT 3
- Does this work with the new plugs such as P110? HOT 9
- Not Really An Issue - But What Is emeter["power"]?
- Not all metrics are being picked up in grafana/prometheus
- Does not work on Kasa KP125M
- server returned HTTP status 404 Not Found HOT 5
- Grafana: Total Power stat HOT 1
- License / copyright information HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tplink-plug-exporter.