Calculate the energy consumed for each hour

Hello ,
do you have any idea how i can calculate the energy consumed for each hour ?

If you have a power feed (Watts), I wrote a contrib node to convert it to energy (kWh) if that helps.

I used interval length

[{"id":"2886e15.c177f9e","type":"file","z":"2fa46193.dd9866","name":"","filename":"E:/EG_energie/node_Local_Compresseurs/energie.txt","appendNewline":true,"createDir":true,"overwriteFile":"false","encoding":"utf8","x":810,"y":960,"wires":[[]]},{"id":"dc3978e0.776b2","type":"function","z":"2fa46193.dd9866","name":"Front Montant","func":"let previous = context.get(\"previous\") || 0\ncontext.set(\"previous\", msg.payload)\nif (  msg.payload   > previous) {\n    var d  = new Date();\n  \n var datetime =d.getFullYear()+\"-\"+ (\"0\"+(d.getMonth()+1)).slice(-2)+ \"-\"+(\"0\" + d.getDate()).slice(-2) +\n      \";\" + (\"0\" + d.getHours()).slice(-2) + \":\" + (\"0\" + d.getMinutes()).slice(-2);\n       energie=msg.payload - previous;\n       if(  !isNaN(energie)){\n  msg .payload = energie.toFixed(2)+';'+'0'+';'+datetime ;\n   \n    return msg;\n}\n\n    \n    \n}","outputs":1,"noerr":0,"initialize":"","finalize":"","x":690,"y":880,"wires":[["2886e15.c177f9e"]]},{"id":"21c88831.474508","type":"interval-length","z":"2fa46193.dd9866","format":"mills","bytopic":false,"minimum":"","maximum":"","window":"30","timeout":false,"msgTimeout":"","windowunit":"mins","reset":false,"startup":false,"msgField":"extrafield","timestampField":"timestamp","repeatTimeout":false,"name":"","x":600,"y":820,"wires":[["dc3978e0.776b2"],[]]},{"id":"48e0688e.552c2","type":"function","z":"2fa46193.dd9866","name":"Buffer 64 bits","func":"const buf=msg.payload.buffer;\n//const buf=msg.payload;\nconst value=buf.readDoubleBE(0)\nvar val=value/100;\nmsg.payload=val.toFixed(2);;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":390,"y":820,"wires":[["21c88831.474508"]]},{"id":"6dd4d246.bb2ee4","type":"modbus-read","z":"2fa46193.dd9866","name":"Energy L_compresserus","topic":"e1","showStatusActivities":false,"logIOActivities":false,"showErrors":false,"unitid":"1","dataType":"HoldingRegister","adr":"801","quantity":"4","rate":"3","rateUnit":"s","delayOnStart":false,"startDelayTime":"","server":"11854432.bc87ec","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"x":180,"y":820,"wires":[[],["48e0688e.552c2"]]},{"id":"11854432.bc87ec","type":"modbus-client","z":"","name":"L. compresseurs","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"queueLogEnabled":false,"tcpHost":"172.22.61.62","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":"1","commandDelay":"1","clientTimeout":"1000","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":true}]

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.