tplink-energy-monitor icon indicating copy to clipboard operation
tplink-energy-monitor copied to clipboard

power consumption last 24 hours

Open robvos opened this issue 6 years ago • 16 comments

Thanks for this tool.

I use it on a windows pc. Programming is not one of my skills.

Would it be possible too see the power consumption off the last 24 hours? So I have an idee when there are peaks in the consumption.

Thanks

robvos avatar Aug 27 '18 17:08 robvos

Hi, thanks for using the project!

The plugs don't natively report the energy consumption in a format other than the total daily usage (as a single value), or the current real-time usage for that second it was requested.

To get a usage history for the last 24 hours, the app could request the real-time usage every minute seconds or so, and log the result to disk. Then when the user requests the dashboard, query this log and build up the last 24 hrs of usage stats to display.

It shouldn't be too much work to implement, and it sounds like a useful feature so I'll look to add it when I get some spare time. Equally if anyone wants to try to implement this feel free!

jamesbarnett91 avatar Aug 30 '18 11:08 jamesbarnett91

Hi, very nice work, i second robvos wish for a 24H chart. But i'I have the same problem i'm not a programmer. I'm also using this program on WIN10 machine. It would also be nice if it was possible to swap between power or current readings Thank you

bullolle avatar Sep 11 '18 17:09 bullolle

Just posting for a quick thanks, while also "thirding" to show my interest in this feature. I'll also consider writing the feature, but my js is pretty terrible.

ghost avatar Sep 21 '18 08:09 ghost

Thank you, this is great. I want to add my vote to the last 24 hours feature.

squish102 avatar Oct 05 '18 00:10 squish102

Thanks for all the feedback! I've made a start on implementing this feature so hopefully I'll get it into a build within a week or 2

jamesbarnett91 avatar Oct 08 '18 09:10 jamesbarnett91

When I saw this code, I decided to buy the TP-link HS110 👍

squish102 avatar Oct 08 '18 23:10 squish102

I've added this logging functionality into the latest build (v0.6) available here.

By default the app will log every minute and keep 24hrs worth of history, but if you want to log more often or store more entries you can change the logger-config.json file in the root of the project, and then restart the app.

The logged data is shown on a new 'Logged Usage' graph on the dashboard.

I haven’t tested it too much so let me know if there are any bugs/issues.

jamesbarnett91 avatar Oct 21 '18 19:10 jamesbarnett91

Looks great. Love that all the configuration and logging works on the precompiled version as well.

Only one issue I've noticed so far...

What I'd like to do is log pretty frequently, but not flog my drive. So, I'd like to store the result in /tmp/ . Your tool only considers the local directory, which is fine - i can just use a wrapper set up the right symlink (with the correct local filename) before launching the monitor.

However, I found a catch - the energy monitor (correctly) tries to use an existing file, but if it encounters a 0-length file, it errors out on json syntax. Perhaps it should be comfortable overwriting a zero-length file? (Especially given the unique filename that is used)

In any case, I sorted it out for myself - I just keep a single-entry json file on-hand to copy to /tmp/ to kick everything off.

ghost avatar Oct 26 '18 08:10 ghost

For those that care... sed -e 's/},{/\\\n/g' -e 's/[]["tspw:}{\\]//g' <input.json> will produce an Excel-processable csv file.

ghost avatar Oct 27 '18 23:10 ghost

@ballachango I'll take a look at the 0 length/byte file issue. It currently assumes that if a file exists it must have created it itself, and so expects it will contain at least an empty JSON array []. Like you say there could be an extra step where it checks if the file is empty as well, and overwrites if so.

Thanks for the sed command, very useful. I've added it to the Readme.

jamesbarnett91 avatar Oct 30 '18 21:10 jamesbarnett91

Thanks @jamesbarnett91 , good to know what the minimum requirement for the file is.

ghost avatar Nov 03 '18 11:11 ghost

Hello @jamesbarnett91 , I really appreciate your program it gives me a perfect view of the current consumtion on different items exactly is I wanted. I run the latest version on win10 pc (24/7) and i have a problem. The program turns itself off so i have to restart it when i want to monitor something then after a few seconds the program shuts itself off again. Any ideas on what the problem can be? How can i find out the problem/correct it?

Best regards Bullolle

bullolle avatar Nov 23 '18 08:11 bullolle

Hi I have similar problems to bullolle but it only occurs when I am logging from 2 devices. 1 device works correctly but if the server detects both HS110 devices it shuts down (after about 1 minute - I think it is when it is writing the log file).

I do not have the issue with V0.6 and currently running this version without problems (except incorrect voltage measurement due to RMS issue). Could this issue be related to the scanning and registering plugs to monitor feature included in V0.7?

I have also found that kWh totals displayed are different from my calculations using log files. Are these read directly from teh HS110 as I have found teh Kasa app reports these incorrectly also.

Many thanks for a great program

b0lders avatar Nov 25 '18 18:11 b0lders

Hi, thanks for the reports. I'll have a look and see if anything in v0.7 could have caused this, or if its always been a problem and needs a fix.

jamesbarnett91 avatar Dec 06 '18 12:12 jamesbarnett91

Hello, Thanks for the lovely tool,

I was wondering if there is an existing plugin or a way for exporting the real-time data into csv format.

Thanks a million.

AbNeil avatar Sep 20 '20 19:09 AbNeil

Hello, Thanks for the lovely tool,

I was wondering if there is an existing plugin or a way for exporting the real-time data into csv format.

Thanks a million.

There are a few ways to do this. From the front page of the project (and higher up in this thread), if you have access to the command line tool sed, you can use something like this: sed -e 's/},{/\\\n/g' -e 's/[]["tspw:}{\\]//g' <input.json> > log.csv (Above command is for a linux shell)

It may look complicated, but it's just finding and replacing characters.

padevel avatar Sep 21 '20 00:09 padevel