Join node and order of messages

Heya!

So I have 6 modbus sensors that are polled each, 1 sec apart. They run into a join node that outputs an array after 6 consecutive messages, and this is written to a CSV file. I have added a function node to each before the array just to track their location (the sensors are measuring zero on all so the output ends up being the sensor address).

Now.... What is the chance that this could all get out of whack and they be read in a different/incorrect order? Is there a way I can add an ID and check it in the sequence to ensure the array is written in the correct order?

I ask because upon deploying some changes and only deploying modified nodes, I saw them in an incorrect order. So far starting it from a full deploy seems to have it running in order

[{"id":"aafa39e0.273538","type":"modbus-flex-getter","z":"fb27fd6.2ca3f","name":"Get UV","showStatusActivities":false,"showErrors":false,"logIOActivities":false,"server":"daab589a.cd8e08","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":900,"y":3600,"wires":[["aadece6c.dd2fb","94f2adcf.82469"],[]]},{"id":"3660beb1.cc3882","type":"function","z":"fb27fd6.2ca3f","name":"function","func":"msg.payload = { \n    'fc': 3, \n    'unitid': 1, \n    'address': 1002, \n    'quantity': 2\n} ;\nreturn msg;","outputs":1,"noerr":0,"x":740,"y":3600,"wires":[["aafa39e0.273538"]]},{"id":"aadece6c.dd2fb","type":"modbus-response","z":"fb27fd6.2ca3f","name":"","registerShowMax":20,"x":1110,"y":3600,"wires":[]},{"id":"d9a7c68a.5a4878","type":"comment","z":"fb27fd6.2ca3f","name":"Read UV Range Registers","info":"Poll each Modbus sensor once every 'x'\nExtract/rearrange needed info\nJoin the results into an array\nWrite to file\n","x":410,"y":3520,"wires":[]},{"id":"94f2adcf.82469","type":"split","z":"fb27fd6.2ca3f","name":"","splt":"\\n","spltType":"str","arraySplt":"1","arraySpltType":"len","stream":false,"addname":"","x":750,"y":3680,"wires":[["638d8e5e.4df99"]]},{"id":"638d8e5e.4df99","type":"switch","z":"fb27fd6.2ca3f","name":"","property":"parts.index","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"eq","v":"1","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":870,"y":3680,"wires":[["2f413bb1.4d85c4"],[]]},{"id":"2f413bb1.4d85c4","type":"change","z":"fb27fd6.2ca3f","name":"","rules":[{"t":"set","p":"object","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1020,"y":3680,"wires":[["201e5a37.4b2d56"]]},{"id":"3435f4f2.be98ec","type":"function","z":"fb27fd6.2ca3f","name":"function","func":"msg.payload = { \n    'fc': 3, \n    'unitid': 2, \n    'address': 1002, \n    'quantity': 2\n} ;\nreturn msg;\n","outputs":1,"noerr":0,"x":740,"y":3780,"wires":[["93a1cc5e.1a245"]]},{"id":"89428524.e34d18","type":"delay","z":"fb27fd6.2ca3f","name":"","pauseType":"delay","timeout":"100","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":570,"y":3780,"wires":[["3435f4f2.be98ec","d30ff769.e95ac8"]]},{"id":"93a1cc5e.1a245","type":"modbus-flex-getter","z":"fb27fd6.2ca3f","name":"Get UV","showStatusActivities":false,"showErrors":false,"logIOActivities":false,"server":"daab589a.cd8e08","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":900,"y":3780,"wires":[["ac5917a9.02c738","1ed573e7.2da11c","25e941fa.4bc0be"],[]]},{"id":"39a49247.56083e","type":"change","z":"fb27fd6.2ca3f","name":"","rules":[{"t":"set","p":"object","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1020,"y":3860,"wires":[["68527cb7.5451c4"]]},{"id":"41aa29d8.1c9b58","type":"switch","z":"fb27fd6.2ca3f","name":"","property":"parts.index","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"eq","v":"1","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":870,"y":3860,"wires":[["39a49247.56083e"],[]]},{"id":"ac5917a9.02c738","type":"split","z":"fb27fd6.2ca3f","name":"","splt":"\\n","spltType":"str","arraySplt":"1","arraySpltType":"len","stream":false,"addname":"","x":750,"y":3860,"wires":[["41aa29d8.1c9b58"]]},{"id":"1ed573e7.2da11c","type":"modbus-response","z":"fb27fd6.2ca3f","name":"","registerShowMax":20,"x":1110,"y":3780,"wires":[]},{"id":"50f17bc5.a99c14","type":"comment","z":"fb27fd6.2ca3f","name":"Change Function node to set Unit-ID. Leave Unit-ID blank in server setup","info":"","x":560,"y":3560,"wires":[]},{"id":"33dd74fc.beda3c","type":"join","z":"fb27fd6.2ca3f","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"6","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":1310,"y":4180,"wires":[["df66ac01.ec7e2"]]},{"id":"480b6457.06aa7c","type":"csv","z":"fb27fd6.2ca3f","name":"","sep":",","hdrin":true,"hdrout":false,"multi":"mult","ret":"\\n","temp":"time, payload","skip":"0","x":1490,"y":4180,"wires":[["978855d9.2568b8"]]},{"id":"978855d9.2568b8","type":"file","z":"fb27fd6.2ca3f","name":"\\log.csv","filename":"log.csv","appendNewline":false,"createDir":true,"overwriteFile":"false","x":1400,"y":4260,"wires":[[]]},{"id":"df66ac01.ec7e2","type":"function","z":"fb27fd6.2ca3f","name":"Generate Timestamp","func":"var date;\ndate = new Date();\ndate = (date.getFullYear() + '-' + ('00' + (date.getMonth()+1)).slice(-2) + '-' + ('00' + date.getDate()).slice(-2) + ' ' + ('00' + date.getHours()).slice(-2) + ':' + ('00' + date.getMinutes()).slice(-2) + ':' + ('00' + date.getSeconds()).slice(-2));\n\nmsg.payload.unshift(date);\nreturn msg;","outputs":1,"noerr":0,"x":1400,"y":4080,"wires":[["480b6457.06aa7c"]]},{"id":"fac248f.7645fb8","type":"delay","z":"fb27fd6.2ca3f","name":"","pauseType":"delay","timeout":"100","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":570,"y":3600,"wires":[["3660beb1.cc3882","89428524.e34d18"]]},{"id":"687dd572.05ed5c","type":"function","z":"fb27fd6.2ca3f","name":"function","func":"msg.payload = { \n    'fc': 3, \n    'unitid': 3, \n    'address': 1002, \n    'quantity': 2\n} ;\nreturn msg;\n","outputs":1,"noerr":0,"x":740,"y":3960,"wires":[["dcb124cf.aa0588"]]},{"id":"d30ff769.e95ac8","type":"delay","z":"fb27fd6.2ca3f","name":"","pauseType":"delay","timeout":"100","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":570,"y":3960,"wires":[["687dd572.05ed5c","536547f.fd6e8b8"]]},{"id":"dcb124cf.aa0588","type":"modbus-flex-getter","z":"fb27fd6.2ca3f","name":"Get UV","showStatusActivities":false,"showErrors":false,"logIOActivities":false,"server":"daab589a.cd8e08","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":900,"y":3960,"wires":[["a9e7e279.5e426","683aafc1.3937b"],[]]},{"id":"b4ee0d76.ecc46","type":"change","z":"fb27fd6.2ca3f","name":"","rules":[{"t":"set","p":"object","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1000,"y":4060,"wires":[["9ad325c3.8b40a8"]]},{"id":"218db094.83cca","type":"switch","z":"fb27fd6.2ca3f","name":"","property":"parts.index","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"eq","v":"1","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":850,"y":4060,"wires":[["b4ee0d76.ecc46"],[]]},{"id":"a9e7e279.5e426","type":"split","z":"fb27fd6.2ca3f","name":"","splt":"\\n","spltType":"str","arraySplt":"1","arraySpltType":"len","stream":false,"addname":"","x":730,"y":4060,"wires":[["218db094.83cca"]]},{"id":"683aafc1.3937b","type":"modbus-response","z":"fb27fd6.2ca3f","name":"","registerShowMax":20,"x":1110,"y":3960,"wires":[]},{"id":"351047ea.65c4f8","type":"inject","z":"fb27fd6.2ca3f","name":"","topic":"","payload":"","payloadType":"date","repeat":"1","crontab":"","once":true,"onceDelay":"2","x":370,"y":3600,"wires":[["fac248f.7645fb8"]]},{"id":"904a719b.3123e","type":"comment","z":"fb27fd6.2ca3f","name":"SENSOR TWO","info":"","x":760,"y":3740,"wires":[]},{"id":"491b89d9.3abeb8","type":"comment","z":"fb27fd6.2ca3f","name":"SENSOR ONE","info":"","x":760,"y":3520,"wires":[]},{"id":"25e941fa.4bc0be","type":"debug","z":"fb27fd6.2ca3f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1230,"y":3720,"wires":[]},{"id":"376e8acf.0e2be6","type":"comment","z":"fb27fd6.2ca3f","name":"SENSOR THREE","info":"","x":760,"y":3920,"wires":[]},{"id":"dd9919e.6e057e8","type":"function","z":"fb27fd6.2ca3f","name":"function","func":"msg.payload = { \n    'fc': 3, \n    'unitid': 4, \n    'address': 1002, \n    'quantity': 2\n} ;\nreturn msg;\n","outputs":1,"noerr":0,"x":740,"y":4180,"wires":[["e10653d3.f21e3"]]},{"id":"536547f.fd6e8b8","type":"delay","z":"fb27fd6.2ca3f","name":"","pauseType":"delay","timeout":"100","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":570,"y":4180,"wires":[["dd9919e.6e057e8","3bea821f.b4165e"]]},{"id":"e10653d3.f21e3","type":"modbus-flex-getter","z":"fb27fd6.2ca3f","name":"Get UV","showStatusActivities":false,"showErrors":false,"logIOActivities":false,"server":"daab589a.cd8e08","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":900,"y":4180,"wires":[["6e1d6f80.b0047","c2d9b122.a4adf"],[]]},{"id":"93e51cf0.16eda","type":"change","z":"fb27fd6.2ca3f","name":"","rules":[{"t":"set","p":"object","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1000,"y":4280,"wires":[["366c9b8a.a50a94"]]},{"id":"3df7349e.ea8eac","type":"switch","z":"fb27fd6.2ca3f","name":"","property":"parts.index","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"eq","v":"1","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":850,"y":4280,"wires":[["93e51cf0.16eda"],[]]},{"id":"6e1d6f80.b0047","type":"split","z":"fb27fd6.2ca3f","name":"","splt":"\\n","spltType":"str","arraySplt":"1","arraySpltType":"len","stream":false,"addname":"","x":730,"y":4280,"wires":[["3df7349e.ea8eac"]]},{"id":"c2d9b122.a4adf","type":"modbus-response","z":"fb27fd6.2ca3f","name":"","registerShowMax":20,"x":1110,"y":4180,"wires":[]},{"id":"4549d1d3.d5687","type":"comment","z":"fb27fd6.2ca3f","name":"SENSOR FOUR","info":"","x":760,"y":4140,"wires":[]},{"id":"71db49ed.24fa38","type":"function","z":"fb27fd6.2ca3f","name":"function","func":"msg.payload = { \n    'fc': 3, \n    'unitid': 5, \n    'address': 1002, \n    'quantity': 2\n} ;\nreturn msg;\n","outputs":1,"noerr":0,"x":740,"y":4400,"wires":[["ccfa6d0d.ca0d6"]]},{"id":"3bea821f.b4165e","type":"delay","z":"fb27fd6.2ca3f","name":"","pauseType":"delay","timeout":"100","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":570,"y":4400,"wires":[["71db49ed.24fa38","2dce938f.0d0aec"]]},{"id":"ccfa6d0d.ca0d6","type":"modbus-flex-getter","z":"fb27fd6.2ca3f","name":"Get UV","showStatusActivities":false,"showErrors":false,"logIOActivities":false,"server":"daab589a.cd8e08","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":900,"y":4400,"wires":[["7544d971.4ad5f8","83bf1309.f758b"],[]]},{"id":"bf62f091.25658","type":"change","z":"fb27fd6.2ca3f","name":"","rules":[{"t":"set","p":"object","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1000,"y":4500,"wires":[["305e4f3a.92eff"]]},{"id":"72464204.4b86ac","type":"switch","z":"fb27fd6.2ca3f","name":"","property":"parts.index","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"eq","v":"1","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":850,"y":4500,"wires":[["bf62f091.25658"],[]]},{"id":"7544d971.4ad5f8","type":"split","z":"fb27fd6.2ca3f","name":"","splt":"\\n","spltType":"str","arraySplt":"1","arraySpltType":"len","stream":false,"addname":"","x":730,"y":4500,"wires":[["72464204.4b86ac"]]},{"id":"83bf1309.f758b","type":"modbus-response","z":"fb27fd6.2ca3f","name":"","registerShowMax":20,"x":1110,"y":4400,"wires":[]},{"id":"801ddcee.4cbdb","type":"comment","z":"fb27fd6.2ca3f","name":"SENSOR FIVE","info":"","x":760,"y":4360,"wires":[]},{"id":"6ace56d3.6e6328","type":"function","z":"fb27fd6.2ca3f","name":"function","func":"msg.payload = { \n    'fc': 3, \n    'unitid': 6, \n    'address': 1002, \n    'quantity': 2\n} ;\nreturn msg;\n","outputs":1,"noerr":0,"x":740,"y":4620,"wires":[["eac0f55b.956618"]]},{"id":"2dce938f.0d0aec","type":"delay","z":"fb27fd6.2ca3f","name":"","pauseType":"delay","timeout":"100","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":570,"y":4620,"wires":[["6ace56d3.6e6328"]]},{"id":"eac0f55b.956618","type":"modbus-flex-getter","z":"fb27fd6.2ca3f","name":"Get UV","showStatusActivities":false,"showErrors":false,"logIOActivities":false,"server":"daab589a.cd8e08","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":900,"y":4620,"wires":[["ca64ff84.5318b","98a5cbb4.96b768"],[]]},{"id":"80bcfe8f.e53ac","type":"change","z":"fb27fd6.2ca3f","name":"","rules":[{"t":"set","p":"object","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1000,"y":4720,"wires":[["13126d21.f1abf3"]]},{"id":"88d6bbc5.cc3358","type":"switch","z":"fb27fd6.2ca3f","name":"","property":"parts.index","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"eq","v":"1","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":850,"y":4720,"wires":[["80bcfe8f.e53ac"],[]]},{"id":"ca64ff84.5318b","type":"split","z":"fb27fd6.2ca3f","name":"","splt":"\\n","spltType":"str","arraySplt":"1","arraySpltType":"len","stream":false,"addname":"","x":730,"y":4720,"wires":[["88d6bbc5.cc3358"]]},{"id":"98a5cbb4.96b768","type":"modbus-response","z":"fb27fd6.2ca3f","name":"","registerShowMax":20,"x":1110,"y":4620,"wires":[]},{"id":"a38e29e2.fadaf8","type":"comment","z":"fb27fd6.2ca3f","name":"SENSOR SIX","info":"","x":750,"y":4580,"wires":[]},{"id":"201e5a37.4b2d56","type":"function","z":"fb27fd6.2ca3f","name":"function","func":"var payload = msg.payload;\nvar id = 1;\nmsg.payload = payload + id;\nreturn msg;","outputs":1,"noerr":0,"x":1260,"y":3680,"wires":[["33dd74fc.beda3c"]]},{"id":"13126d21.f1abf3","type":"function","z":"fb27fd6.2ca3f","name":"function","func":"var payload = msg.payload;\nvar id = 6;\nmsg.payload = payload + id;\nreturn msg;","outputs":1,"noerr":0,"x":1240,"y":4720,"wires":[["33dd74fc.beda3c"]]},{"id":"68527cb7.5451c4","type":"function","z":"fb27fd6.2ca3f","name":"function","func":"var payload = msg.payload;\nvar id = 2;\nmsg.payload = payload + id;\nreturn msg;","outputs":1,"noerr":0,"x":1200,"y":3860,"wires":[["33dd74fc.beda3c"]]},{"id":"9ad325c3.8b40a8","type":"function","z":"fb27fd6.2ca3f","name":"function","func":"var payload = msg.payload;\nvar id = 3;\nmsg.payload = payload + id;\nreturn msg;","outputs":1,"noerr":0,"x":1160,"y":4060,"wires":[["33dd74fc.beda3c"]]},{"id":"366c9b8a.a50a94","type":"function","z":"fb27fd6.2ca3f","name":"function","func":"var payload = msg.payload;\nvar id = 4;\nmsg.payload = payload + id;\nreturn msg;","outputs":1,"noerr":0,"x":1160,"y":4280,"wires":[["33dd74fc.beda3c"]]},{"id":"305e4f3a.92eff","type":"function","z":"fb27fd6.2ca3f","name":"function","func":"var payload = msg.payload;\nvar id = 5;\nmsg.payload = payload + id;\nreturn msg;","outputs":1,"noerr":0,"x":1180,"y":4500,"wires":[["33dd74fc.beda3c"]]},{"id":"daab589a.cd8e08","type":"modbus-client","z":"","name":"modbus","clienttype":"serial","bufferCommands":true,"stateLogEnabled":false,"tcpHost":"127.0.0.1","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyS2","serialType":"RTU-BUFFERD","serialBaudrate":"19200","serialDatabits":"8","serialStopbits":"1","serialParity":"even","serialConnectionDelay":"1","unit_id":"","commandDelay":"10","clientTimeout":"1000","reconnectTimeout":"1000"}]

Use the join node in key/value pair mode (making sure you have different topics for each value). Then you will get all the values in an object individually identified. If you then want them in an array you can build the array in the right order.

Awesome! Thanks for that. Took me a bit but I got there in the end