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

I am experiencing a similar problem relating to the order of items using the "Join" node.
I have tried the suggestion to use key/value pair mode, but get an error "message missing key property 'msg.topic' - cannot add to object"

I am reading two values from a Modbus device. I have named each "Topic" in the Modbus Node, but I then put the values through a Range Node and a Smooth Node. Could these be loosing the "Topic"?

If I were to get the Topic to work, I have no idea how I would create the CSV line I am currently saving to file?

Add a debug node after the node in question and set it to display complete message object.

Thank you,

Debug complete message doesn't show "Topic" so it looks like I will need to use a Function Node to get a Topic into the flow.

I will do some experimenting. This is taking me from the easy level of Node-Red to what to me seems difficult. Lets see how I go.

Take a look at what i ended up doing and it works. May be of some help

[{"id":"2d907ade.e3dbd6","type":"subflow","name":"BLINK OFF","info":"","category":"","in":[{"x":60,"y":80,"wires":[{"id":"bff8199f.aa7d08"}]}],"out":[]},{"id":"877299f.1e3ce68","type":"mraa-gpio-dout","z":"2d907ade.e3dbd6","name":"","pin":"7","set":true,"level":"0","x":570,"y":80,"wires":[]},{"id":"783a32ab.a7910c","type":"function","z":"2d907ade.e3dbd6","name":"light OFF","func":"payload = msg.payload;\nmsg.payload = 0;\nreturn msg;","outputs":1,"noerr":0,"x":400,"y":80,"wires":[["877299f.1e3ce68"]]},{"id":"bff8199f.aa7d08","type":"delay","z":"2d907ade.e3dbd6","name":"DELAY","pauseType":"delay","timeout":"300","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":200,"y":80,"wires":[["783a32ab.a7910c"]]},{"id":"c5d3b695.7310e8","type":"subflow","name":"BLINK ON","info":"","category":"","in":[{"x":60,"y":60,"wires":[{"id":"d6c0a50f.153b98"}]}],"out":[]},{"id":"ee4d6a53.2ff7e8","type":"mraa-gpio-dout","z":"c5d3b695.7310e8","name":"","pin":"7","set":true,"level":"0","x":410,"y":60,"wires":[]},{"id":"d6c0a50f.153b98","type":"function","z":"c5d3b695.7310e8","name":"light ON","func":"payload = msg.payload;\nmsg.payload = 1;\nreturn msg;","outputs":1,"noerr":0,"x":200,"y":60,"wires":[["ee4d6a53.2ff7e8"]]},{"id":"f03c1dc.223d1e","type":"modbus-flex-getter","z":"47a61c3d.18afe4","name":"Get UV","showStatusActivities":false,"showErrors":false,"logIOActivities":false,"server":"daab589a.cd8e08","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":680,"y":140,"wires":[["4b8bcd7b.d89614","a9d472f8.d12da"],[]]},{"id":"f91a6763.862338","type":"function","z":"47a61c3d.18afe4","name":"READ","func":"msg.payload = { \n 'fc': 3, \n 'unitid': 7, \n 'address': 1002, \n 'quantity': 2\n} ;\nreturn msg;","outputs":1,"noerr":0,"x":510,"y":140,"wires":[["f03c1dc.223d1e"]]},{"id":"4b8bcd7b.d89614","type":"modbus-response","z":"47a61c3d.18afe4","name":"","registerShowMax":20,"x":890,"y":140,"wires":[]},{"id":"9e62545a.48ebd8","type":"comment","z":"47a61c3d.18afe4","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":190,"y":60,"wires":[]},{"id":"a9d472f8.d12da","type":"split","z":"47a61c3d.18afe4","name":"","splt":"\\n","spltType":"str","arraySplt":"1","arraySpltType":"len","stream":false,"addname":"","x":510,"y":220,"wires":[["a78a4120.d16ea"]]},{"id":"a78a4120.d16ea","type":"switch","z":"47a61c3d.18afe4","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":630,"y":220,"wires":[["10efb63e.52160a"],[]]},{"id":"10efb63e.52160a","type":"change","z":"47a61c3d.18afe4","name":"","rules":[{"t":"set","p":"object","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":780,"y":220,"wires":[["58e811c3.37e93"]]},{"id":"b60b8e03.2639c","type":"function","z":"47a61c3d.18afe4","name":"READ","func":"msg.payload = { \n 'fc': 3, \n 'unitid': 2, \n 'address': 1002, \n 'quantity': 2\n} ;\nreturn msg;\n","outputs":1,"noerr":0,"x":510,"y":320,"wires":[["949d8de0.6d095"]]},{"id":"d296e2e9.127c3","type":"delay","z":"47a61c3d.18afe4","name":"","pauseType":"delay","timeout":"50","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":350,"y":320,"wires":[["b60b8e03.2639c","ed62a4e3.489028"]]},{"id":"949d8de0.6d095","type":"modbus-flex-getter","z":"47a61c3d.18afe4","name":"Get UV","showStatusActivities":false,"showErrors":false,"logIOActivities":false,"server":"daab589a.cd8e08","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":680,"y":320,"wires":[["9d836ed.2e7ed9","9cbf9a2c.fe8d38"],[]]},{"id":"fcee6d75.cd544","type":"change","z":"47a61c3d.18afe4","name":"","rules":[{"t":"set","p":"object","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":780,"y":400,"wires":[["4b092079.eab5f"]]},{"id":"832a4fd7.300c3","type":"switch","z":"47a61c3d.18afe4","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":630,"y":400,"wires":[["fcee6d75.cd544"],[]]},{"id":"9d836ed.2e7ed9","type":"split","z":"47a61c3d.18afe4","name":"","splt":"\\n","spltType":"str","arraySplt":"1","arraySpltType":"len","stream":false,"addname":"","x":510,"y":400,"wires":[["832a4fd7.300c3"]]},{"id":"9cbf9a2c.fe8d38","type":"modbus-response","z":"47a61c3d.18afe4","name":"","registerShowMax":20,"x":890,"y":320,"wires":[]},{"id":"6215cdef.8241a4","type":"comment","z":"47a61c3d.18afe4","name":"Change Function node to set Unit-ID. Leave Unit-ID blank in server setup","info":"","x":340,"y":100,"wires":[]},{"id":"71877f1e.e927a","type":"join","z":"47a61c3d.18afe4","name":"GET ALL VALUES","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"6","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":1210,"y":720,"wires":[["f3ab5d64.80e45"]]},{"id":"d577618d.f63df","type":"csv","z":"47a61c3d.18afe4","name":"CSV","sep":",","hdrin":true,"hdrout":false,"multi":"mult","ret":"\\n","temp":"time, payload","skip":"0","x":1430,"y":780,"wires":[["92f2da6c.723a88"]]},{"id":"92f2da6c.723a88","type":"file","z":"47a61c3d.18afe4","name":"WRITE TO FILE","filename":"log.csv","appendNewline":false,"createDir":true,"overwriteFile":"false","x":1220,"y":840,"wires":[[]]},{"id":"180c0ebf.fb2161","type":"function","z":"47a61c3d.18afe4","name":"ADD TIME","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;\n\n//Timestamp added to each set of readings","outputs":1,"noerr":0,"x":1210,"y":780,"wires":[["d577618d.f63df"]]},{"id":"fabafae0.8e1b98","type":"delay","z":"47a61c3d.18afe4","name":"","pauseType":"delay","timeout":"50","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":350,"y":140,"wires":[["f91a6763.862338","d296e2e9.127c3"]]},{"id":"6642e90a.829578","type":"function","z":"47a61c3d.18afe4","name":"READ","func":"msg.payload = { \n 'fc': 3, \n 'unitid': 3, \n 'address': 1002, \n 'quantity': 2\n} ;\nreturn msg;\n","outputs":1,"noerr":0,"x":510,"y":500,"wires":[["7bdd99e2.7f45a8"]]},{"id":"ed62a4e3.489028","type":"delay","z":"47a61c3d.18afe4","name":"","pauseType":"delay","timeout":"50","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":350,"y":500,"wires":[["6642e90a.829578","4fcade2c.eceed"]]},{"id":"7bdd99e2.7f45a8","type":"modbus-flex-getter","z":"47a61c3d.18afe4","name":"Get UV","showStatusActivities":false,"showErrors":false,"logIOActivities":false,"server":"daab589a.cd8e08","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":680,"y":500,"wires":[["ed616a6.6105098","6d3c3a03.732954"],[]]},{"id":"3efbfd51.4a1a22","type":"change","z":"47a61c3d.18afe4","name":"","rules":[{"t":"set","p":"object","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":780,"y":600,"wires":[["ae015178.96303"]]},{"id":"629a2850.164298","type":"switch","z":"47a61c3d.18afe4","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":630,"y":600,"wires":[["3efbfd51.4a1a22"],[]]},{"id":"ed616a6.6105098","type":"split","z":"47a61c3d.18afe4","name":"","splt":"\\n","spltType":"str","arraySplt":"1","arraySpltType":"len","stream":false,"addname":"","x":510,"y":600,"wires":[["629a2850.164298"]]},{"id":"6d3c3a03.732954","type":"modbus-response","z":"47a61c3d.18afe4","name":"","registerShowMax":20,"x":890,"y":500,"wires":[]},{"id":"f1205725.a37478","type":"inject","z":"47a61c3d.18afe4","name":"","topic":"","payload":"","payloadType":"date","repeat":"0.5","crontab":"","once":true,"onceDelay":"15","x":150,"y":140,"wires":[["fabafae0.8e1b98","2070114d.dcd13e","fc19946a.b0e928"]]},{"id":"91f0141c.467df8","type":"comment","z":"47a61c3d.18afe4","name":"SENSOR TWO","info":"","x":540,"y":280,"wires":[]},{"id":"68165012.24307","type":"comment","z":"47a61c3d.18afe4","name":"SENSOR SEVEN","info":"","x":540,"y":60,"wires":[]},{"id":"d6599e5f.a8f3d","type":"comment","z":"47a61c3d.18afe4","name":"SENSOR THREE","info":"","x":540,"y":460,"wires":[]},{"id":"8f8d3063.f5b54","type":"function","z":"47a61c3d.18afe4","name":"READ","func":"msg.payload = { \n 'fc': 3, \n 'unitid': 4, \n 'address': 1002, \n 'quantity': 2\n} ;\nreturn msg;\n","outputs":1,"noerr":0,"x":510,"y":720,"wires":[["1fea37c0.3b8948"]]},{"id":"4fcade2c.eceed","type":"delay","z":"47a61c3d.18afe4","name":"","pauseType":"delay","timeout":"50","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":350,"y":720,"wires":[["8f8d3063.f5b54","12d64de7.a6ba22"]]},{"id":"1fea37c0.3b8948","type":"modbus-flex-getter","z":"47a61c3d.18afe4","name":"Get UV","showStatusActivities":false,"showErrors":false,"logIOActivities":false,"server":"daab589a.cd8e08","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":680,"y":720,"wires":[["615641de.1a8a4","a68e4366.3bed3"],[]]},{"id":"fac2c355.c942e","type":"change","z":"47a61c3d.18afe4","name":"","rules":[{"t":"set","p":"object","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":780,"y":820,"wires":[["5cb5c574.1ed7ec"]]},{"id":"75293520.8e3d8c","type":"switch","z":"47a61c3d.18afe4","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":630,"y":820,"wires":[["fac2c355.c942e"],[]]},{"id":"615641de.1a8a4","type":"split","z":"47a61c3d.18afe4","name":"","splt":"\\n","spltType":"str","arraySplt":"1","arraySpltType":"len","stream":false,"addname":"","x":510,"y":820,"wires":[["75293520.8e3d8c"]]},{"id":"a68e4366.3bed3","type":"modbus-response","z":"47a61c3d.18afe4","name":"","registerShowMax":20,"x":890,"y":720,"wires":[]},{"id":"11fabbad.33bae4","type":"comment","z":"47a61c3d.18afe4","name":"SENSOR FOUR","info":"","x":540,"y":680,"wires":[]},{"id":"f0704e8e.196ba","type":"function","z":"47a61c3d.18afe4","name":"READ","func":"msg.payload = { \n 'fc': 3, \n 'unitid': 5, \n 'address': 1002, \n 'quantity': 2\n} ;\nreturn msg;\n","outputs":1,"noerr":0,"x":510,"y":940,"wires":[["26de5189.c9690e"]]},{"id":"12d64de7.a6ba22","type":"delay","z":"47a61c3d.18afe4","name":"","pauseType":"delay","timeout":"50","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":350,"y":940,"wires":[["f0704e8e.196ba","da1bcc81.6fff8"]]},{"id":"26de5189.c9690e","type":"modbus-flex-getter","z":"47a61c3d.18afe4","name":"Get UV","showStatusActivities":false,"showErrors":false,"logIOActivities":false,"server":"daab589a.cd8e08","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":680,"y":940,"wires":[["2a036de5.b912c2","a07d39ec.311928"],[]]},{"id":"a7e43f28.308e4","type":"change","z":"47a61c3d.18afe4","name":"","rules":[{"t":"set","p":"object","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":780,"y":1040,"wires":[["c4a45a6c.5cc9f8"]]},{"id":"7f96b5fd.d9a10c","type":"switch","z":"47a61c3d.18afe4","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":630,"y":1040,"wires":[["a7e43f28.308e4"],[]]},{"id":"2a036de5.b912c2","type":"split","z":"47a61c3d.18afe4","name":"","splt":"\\n","spltType":"str","arraySplt":"1","arraySpltType":"len","stream":false,"addname":"","x":510,"y":1040,"wires":[["7f96b5fd.d9a10c"]]},{"id":"a07d39ec.311928","type":"modbus-response","z":"47a61c3d.18afe4","name":"","registerShowMax":20,"x":890,"y":940,"wires":[]},{"id":"890ab007.60378","type":"comment","z":"47a61c3d.18afe4","name":"SENSOR FIVE","info":"","x":540,"y":900,"wires":[]},{"id":"13b43c76.738dc4","type":"function","z":"47a61c3d.18afe4","name":"READ","func":"msg.payload = { \n 'fc': 3, \n 'unitid': 6, \n 'address': 1002, \n 'quantity': 2\n} ;\nreturn msg;\n","outputs":1,"noerr":0,"x":510,"y":1160,"wires":[["ef02c44d.6b9de8"]]},{"id":"da1bcc81.6fff8","type":"delay","z":"47a61c3d.18afe4","name":"","pauseType":"delay","timeout":"50","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":350,"y":1160,"wires":[["13b43c76.738dc4"]]},{"id":"ef02c44d.6b9de8","type":"modbus-flex-getter","z":"47a61c3d.18afe4","name":"Get UV","showStatusActivities":false,"showErrors":false,"logIOActivities":false,"server":"daab589a.cd8e08","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":680,"y":1160,"wires":[["d5c2ef18.3d5fd","ec54717f.58851"],[]]},{"id":"dfff89d5.ed37c8","type":"change","z":"47a61c3d.18afe4","name":"","rules":[{"t":"set","p":"object","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":780,"y":1260,"wires":[["8535603a.c430d"]]},{"id":"8634db6e.0ce898","type":"switch","z":"47a61c3d.18afe4","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":630,"y":1260,"wires":[["dfff89d5.ed37c8"],[]]},{"id":"d5c2ef18.3d5fd","type":"split","z":"47a61c3d.18afe4","name":"","splt":"\\n","spltType":"str","arraySplt":"1","arraySpltType":"len","stream":false,"addname":"","x":510,"y":1260,"wires":[["8634db6e.0ce898"]]},{"id":"ec54717f.58851","type":"modbus-response","z":"47a61c3d.18afe4","name":"","registerShowMax":20,"x":890,"y":1160,"wires":[]},{"id":"55f454d9.6fb83c","type":"comment","z":"47a61c3d.18afe4","name":"SENSOR SIX","info":"","x":530,"y":1120,"wires":[]},{"id":"58e811c3.37e93","type":"change","z":"47a61c3d.18afe4","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"7","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":950,"y":220,"wires":[["71877f1e.e927a"]]},{"id":"4b092079.eab5f","type":"change","z":"47a61c3d.18afe4","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"2","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":950,"y":400,"wires":[["71877f1e.e927a"]]},{"id":"ae015178.96303","type":"change","z":"47a61c3d.18afe4","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"3","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":950,"y":600,"wires":[["71877f1e.e927a"]]},{"id":"5cb5c574.1ed7ec","type":"change","z":"47a61c3d.18afe4","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"4","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":950,"y":820,"wires":[["71877f1e.e927a"]]},{"id":"c4a45a6c.5cc9f8","type":"change","z":"47a61c3d.18afe4","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"5","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":950,"y":1040,"wires":[["71877f1e.e927a"]]},{"id":"8535603a.c430d","type":"change","z":"47a61c3d.18afe4","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"6","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":950,"y":1260,"wires":[["71877f1e.e927a"]]},{"id":"f3ab5d64.80e45","type":"function","z":"47a61c3d.18afe4","name":"BUILD ARRAY","func":"var seven = msg.payload[\"7\"];\nvar two = msg.payload[\"2\"];\nvar three = msg.payload[\"3\"];\nvar four = msg.payload[\"4\"];\nvar five = msg.payload[\"5\"];\nvar six = msg.payload[\"6\"];\n\nmsg.payload = [seven,two,three,four,five,six];\n\nreturn msg;\n\n//Array is buit based on order of sensors","outputs":1,"noerr":0,"x":1400,"y":720,"wires":[["180c0ebf.fb2161"]]},{"id":"6f319233.eff69c","type":"comment","z":"47a61c3d.18afe4","name":"EXTRACT READING FROM UVValueRegister_alias1","info":"UVValueRegister_alias1 is read\nand extracted from the array\nThis is a UV value of 0.1 W/m²\n\nUsing signed 16 bit integer for now as easier\nto process and likely accurate enough","x":820,"y":100,"wires":[]},{"id":"e93f60eb.62847","type":"comment","z":"47a61c3d.18afe4","name":"RECEIVE","info":"Join node merges the six sensors values using\nthe message topic to ensure only one of each\nis received and then passed on to function","x":1180,"y":680,"wires":[]},{"id":"2070114d.dcd13e","type":"subflow:c5d3b695.7310e8","z":"47a61c3d.18afe4","name":"BLINK ON","x":230,"y":180,"wires":[]},{"id":"fc19946a.b0e928","type":"subflow:2d907ade.e3dbd6","z":"47a61c3d.18afe4","name":"BLINK OFF","x":230,"y":220,"wires":[]}]

You already have a set of change nodes in each leg of the flow - just add another rule to them
image

1 Like