I have a Fibaro Wall Plug connected to my Z-Way.
It reports the power consumption every 5 seconds
I would like to store the info every 5 seconds in a database or something in order to make some graphs and to know average consumption for a 24 hour period
Maybe there is something already done?
Statistics
Re: Statistics
You can create a module which does exactly this. I made one a while ago it works but I don´t know if its the right way to do it. This is part of my index.js code.
function MySql (id, controller) {
MySql.super_.call(this, id, controller);
this.eventLog = {};
}
// Module inheritance and setup
_module = MySql;
inherits(MySql, AutomationModule);
// Module methods
MySql.prototype.init = function (config) {
MySql.super_.prototype.init.call(this, config);
var self = this;
this.controller.eventlog = {};
this.controller.onAny(function () {
var newArgs = get_values(arguments);
newArgs.unshift(this.event);
self.logEventMysql.apply(self, newArgs);
});
};
MySql.prototype.logEventsMySql = function(){
//Log events here.
}
function MySql (id, controller) {
MySql.super_.call(this, id, controller);
this.eventLog = {};
}
// Module inheritance and setup
_module = MySql;
inherits(MySql, AutomationModule);
// Module methods
MySql.prototype.init = function (config) {
MySql.super_.prototype.init.call(this, config);
var self = this;
this.controller.eventlog = {};
this.controller.onAny(function () {
var newArgs = get_values(arguments);
newArgs.unshift(this.event);
self.logEventMysql.apply(self, newArgs);
});
};
MySql.prototype.logEventsMySql = function(){
//Log events here.
}
Re: Statistics
Can u send me the whole code ? im not into js
Regards
Regards
Re: Statistics
@ollfa:
Nice to see you using modules. You can make your module more "universal", add confgurable parameters and propose it as pull request on github. Or we can add it ourself if yousend it to us.
Nice to see you using modules. You can make your module more "universal", add confgurable parameters and propose it as pull request on github. Or we can add it ourself if yousend it to us.
Re: Statistics
Whats the status for this MySql thing. Did it become a module?