jamesbarnett91 / tplink-energy-monitor

An energy monitoring dashboard for TP-Link smart plugs
GNU General Public License v3.0
463 stars 102 forks source link

Pulling historical data from the switches #27

Open slvrscoobie opened 5 years ago

slvrscoobie commented 5 years ago

Is there a way to pull that Monthly data down to export it to excel? id love to have the Daily records of power usage to log against temps for my freezer and heater.. but running the console seems to slow my network down (noticed a significant number of re-requests and sluggishness with my KASA app since starting it.) Id love to be able to log in once a month, capture the previous 30 days data for both devices and put them in an XLS or JSON file to record keeping.

jamesbarnett91 commented 5 years ago

Hi, sorry for the slow reply. I’m afraid there's no build in way to do this currently.

As a workaround, you can open your browsers dev tools (usually F12, or ctrl+shift+i) and paste this into the console:

var csv = "date,usage"
dash.dailyUsageChart.data.labels.forEach(function(val,idx) {
var usage = dash.dailyUsageChart.data.datasets[0].data[idx];
csv += "\n"+val+","+usage;
});
console.log(csv);

This will export the last 30 days usage as a CSV string. You can then copy the output from the console and paste it into excel.

It's a bit convoluted but hopefully that will work for your use case. I'll look at enhancing the currently logging capability to include the daily usage. Thanks

slvrscoobie commented 5 years ago

Easy enough!!!

slvrscoobie commented 5 years ago

Got it! Sweet!! now i just log in at least every 30 days and Ive got my data.

slvrscoobie commented 5 years ago

Is there a way to pull more than just the last 30 days with the console method above? 60/90/120? 365??

slvrscoobie commented 5 years ago

Is there a way to pull data from a specific date or date range? I missed 3 days between my 30 day downloads and theres a gap.