Hi everyone!!
I hope you are very well!
I have the following problem, I am receiving data via modbus in array, but I need the transformed value.
The problem is that I am dividing the message into parts to be able to convert it into float(le), the issue is that now 3 final messages are being sent instead of just 1.
I need these 3 messages:
It is sent in 1 single message that contains the 3 previous ones
[{"id":"854e244f9c1b4b19","type":"function","z":"4c530122d318c3f2","name":"Frecuencia","func":"var a1 = msg.payload.data[7]; var b1 = msg.payload.data[8]; var c1 = msg.payload.data[9];var d1 = msg.payload.data[10];\nvar CT1=[a1,b1,c1,d1];\nvar CT1buffer = Buffer.from(CT1);\nmsg.payload.ct1 = CT1buffer;\n\nvar a2 = msg.payload.data[11]; var b2 = msg.payload.data[12]; var c2 = msg.payload.data[13];var d2 = msg.payload.data[14];\nvar CT2=[a1,b1,c1,d1];\nvar CT2buffer = Buffer.from(CT2);\nmsg.payload.ct2 = CT2buffer;\n\nvar a3 = msg.payload.data[15]; var b3 = msg.payload.data[16]; var c3 = msg.payload.data[17];var d3 = msg.payload.data[18];\nvar CT3=[a3,b3,c3,d3];\nvar CT3buffer = Buffer.from(CT3);\nmsg.payload.ct3 = CT3buffer;\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":470,"y":820,"wires":[["d56805e5f6a844d6","18f7bc5f1de5ecf8","e4619edf3324a272"]]},{"id":"d56805e5f6a844d6","type":"buffer-parser","z":"4c530122d318c3f2","name":"CT1","data":"payload.ct1","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"floatle","name":"CT1","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"swap32","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload.ct1","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"output","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":610,"y":820,"wires":[["326f72ac55c3dbc5"]]},{"id":"326f72ac55c3dbc5","type":"function","z":"4c530122d318c3f2","name":"Frecuencia","func":"function financial(x) {\n return Number.parseFloat(x).toFixed(2);\n}\ndate = new Date();\ntimestamp = date.getTime();\ntimestamp= date.setMilliseconds(0,0,0);\ntimestamp= date.setSeconds(0,0,0);\n\n\nvar ct1=msg.payload.ct1; \nvar ct2=msg.payload.ct2; \nvar ct3=msg.payload.ct3; \n\n\nmsg.payload = { \n ct1: {\"value\": ct1, \"timestamp\": timestamp},\n ct2: {\"value\": ct2, \"timestamp\": timestamp},\n ct3: {\"value\": ct3, \"timestamp\": timestamp}, \n \n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":750,"y":820,"wires":[["04b29b0976c1e487"]]},{"id":"04b29b0976c1e487","type":"debug","z":"4c530122d318c3f2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":910,"y":820,"wires":[]},{"id":"18f7bc5f1de5ecf8","type":"buffer-parser","z":"4c530122d318c3f2","name":"CT2","data":"payload.ct2","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"floatle","name":"CT2","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"swap32","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload.ct2","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"output","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":610,"y":860,"wires":[["326f72ac55c3dbc5"]]},{"id":"e4619edf3324a272","type":"buffer-parser","z":"4c530122d318c3f2","name":"CT3","data":"payload.ct3","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"floatle","name":"CT3","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"swap32","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload.ct3","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"output","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":610,"y":900,"wires":[["326f72ac55c3dbc5"]]},{"id":"fd0ee945857ec0a9","type":"function","z":"4c530122d318c3f2","name":"","func":"var testArray = [66,80,148,245,66,80,148,245,66,80,148,245,66,80,148,245,148,245];\n \n\nmsg.payload.data = testArray;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":320,"y":820,"wires":[["854e244f9c1b4b19"]]},{"id":"1fdc43af654096f9","type":"inject","z":"4c530122d318c3f2","name":"","props":[{"p":"payload.data","v":"","vt":"date"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":190,"y":820,"wires":[["fd0ee945857ec0a9"]]}]