// initialise the counter to 0 if it doesn't exist already
var count = context.global.get("count")||0;
// store the value back
context.global.
set("count",count);
// make it part of the outgoing msg object
msg.count = count;
var temp = msg.count;
var result = msg.payload.result.map(x => parseInt(x,16));
var curr_value = result[1];
var new_value= value
-temp;
context.global.set('count',new_value);
--
http://nodered.org
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
For more options, visit https://groups.google.com/d/optout.
functionGlobalContext: {
// os:require('os')
// fs: require("fs")
// bonescript:require('bonescript'),
// jfive:require("johnny-five"),
// j5board:require("johnny-five").Board({repl:false})
},
functionGlobalContext: {
os:require('os')
// fs: require("fs")
// bonescript:require('bonescript'),
// jfive:require("johnny-five"),
// j5board:require("johnny-five").Board({repl:false})
},
// initialise the counter to 0 if it doesn't exist already
var count = context.global.get("lastkwh")||0;
// store the value back
context.global.set("lastkwh",count);
// make it part of the outgoing msg object
return msg;
var temp = context.global.get("lastkwh");
var result = msg.payload.result.map(x => parseInt(x,16));
var dev1 = result[1];
var curr_kwh = dev1-temp;
context.global.set('lastkwh',curr_kwh);