-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
It seems that the kWh field in powerinfo() contains the measurement over the last 8 seconds. It would be nice if plugwisejs uses this information to also offer a method to get the total usage since a certain moment.
In this case, the library should keep track of an accumulated kWh value, make sure measurement intervals have enough overlap to not miss any data and account for that overlap. (If I’m not mistaken – I still don’t fully understand the Plugwise protocol.)
The API could enable code like this:
var plugwise = require('plugwisejs').init({ serialport: '/dev/tty.usbserial-A80060FG' });
var circle = plugwise('000D6F0000AF7512');
var stopAt = 5.0; // kWh
circle.startAccumulating(); // set the accumulated value to 0 kWh, starts the loop
var interval = setInterval(function() {
circle.getEnergy(function(kWh) {
console.log('Energy since start:', kWh, 'kWh');
if (kWh > stopAt) {
circle.stopAccumulating();
clearInterval(interval);
}
});
}, 1000);
Metadata
Metadata
Assignees
Labels
No labels