Page 1 of 1
Statistics
Posted: 28 Feb 2014 04:38
by SirLouen
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?
Re: Statistics
Posted: 28 Feb 2014 12:01
by ollfa
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.
}
Re: Statistics
Posted: 28 Feb 2014 20:32
by SirLouen
Can u send me the whole code ? im not into js

Regards
Re: Statistics
Posted: 02 Mar 2014 13:21
by PoltoS
@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.
Re: Statistics
Posted: 13 May 2016 12:48
by gabrielb
Whats the status for this MySql thing. Did it become a module?