Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

power consumption last 24 hours #6

Open
robvos opened this issue Aug 27, 2018 · 16 comments
Open

power consumption last 24 hours #6

robvos opened this issue Aug 27, 2018 · 16 comments
Labels
enhancement New feature or request

Comments

@robvos
Copy link

robvos commented Aug 27, 2018

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

@jamesbarnett91
Copy link
Owner

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!

@bullolle
Copy link

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

@ghost
Copy link

ghost commented Sep 21, 2018

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.

@squish102
Copy link

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

@jamesbarnett91
Copy link
Owner

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

@squish102
Copy link

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

@jamesbarnett91 jamesbarnett91 added the enhancement New feature or request label Oct 15, 2018
@jamesbarnett91
Copy link
Owner

jamesbarnett91 commented Oct 21, 2018

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.

@ghost
Copy link

ghost commented Oct 26, 2018

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
Copy link

ghost commented Oct 27, 2018

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

@jamesbarnett91
Copy link
Owner

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

@ghost
Copy link

ghost commented Nov 3, 2018

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

@bullolle
Copy link

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

@b0lders
Copy link

b0lders commented Nov 25, 2018

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

@jamesbarnett91
Copy link
Owner

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.

@AbNeil
Copy link

AbNeil commented Sep 20, 2020

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.

@padevel
Copy link

padevel commented Sep 21, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

7 participants