I am currently requesting data every second from 13 different sources using a raspberry pi. That data is then given a topic with All/ and then sent over MQTT to my computer. Using a switch node, I separate out the data, and send it to a join node where it is set to wait for 12 parts to send the message across.
The issue is that the msg gets passed on as two separate messages. This is the code I'm using:
[{"id":"3264a3dc.ef8b8c","type":"tab","label":"All","disabled":false,"info":""},{"id":"7145066a.dae008","type":"mqtt in","z":"3264a3dc.ef8b8c","name":"","topic":"All/#","qos":"2","datatype":"auto","broker":"7ac66e23.82af7","x":92.01736068725586,"y":133.0104579925537,"wires":[["db0982de.78d66"]]},{"id":"db0982de.78d66","type":"switch","z":"3264a3dc.ef8b8c","name":"","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"All/TotalVolume","vt":"str"},{"t":"eq","v":"All/OverallFlowRate","vt":"str"},{"t":"eq","v":"All/TempA","vt":"str"},{"t":"eq","v":"All/TempB","vt":"str"},{"t":"eq","v":"All/TempC","vt":"str"},{"t":"eq","v":"All/TempD1","vt":"str"},{"t":"eq","v":"All/TempD2","vt":"str"},{"t":"eq","v":"All/TempD3","vt":"str"},{"t":"eq","v":"All/TempD4","vt":"str"},{"t":"eq","v":"All/TempD5","vt":"str"},{"t":"eq","v":"All/GasBufferPressure","vt":"str"},{"t":"eq","v":"All/DewarPressure","vt":"str"}],"checkall":"true","repair":false,"outputs":12,"x":253.71094512939453,"y":132.0781593322754,"wires":[["c1423c17.32119"],["c1423c17.32119"],["c1423c17.32119"],["c1423c17.32119"],["c1423c17.32119"],["c1423c17.32119"],["c1423c17.32119"],["c1423c17.32119"],["c1423c17.32119"],["c1423c17.32119"],["c1423c17.32119"],["c1423c17.32119"]]},{"id":"9f3137d6.89d208","type":"debug","z":"3264a3dc.ef8b8c","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":593.0833778381348,"y":128.53473472595215,"wires":[]},{"id":"c1423c17.32119","type":"join","z":"3264a3dc.ef8b8c","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"12","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"num","reduceFixup":"","x":426.01739501953125,"y":133.01046085357666,"wires":[["9f3137d6.89d208"]]},{"id":"7ac66e23.82af7","type":"mqtt-broker","z":"","name":"","broker":"192.168.1.50","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
This seems strange, because I am using a similar code to do (what I thought) was the exact same thing in a different flow with a different flow, as shown below:
[{"id":"78e630b8.b4c73","type":"tab","label":"All User","disabled":false,"info":""},{"id":"77ea86f2.c48e48","type":"switch","z":"78e630b8.b4c73","name":"","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"AllUser/TotalVolume","vt":"str"},{"t":"eq","v":"AllUser/OverallFlowRate","vt":"str"},{"t":"eq","v":"AllUser/Time","vt":"str"},{"t":"eq","v":"AllUser/TempA","vt":"str"},{"t":"eq","v":"AllUser/TempB","vt":"str"},{"t":"eq","v":"AllUser/TempC","vt":"str"},{"t":"eq","v":"AllUser/TempD1","vt":"str"},{"t":"eq","v":"AllUser/TempD2","vt":"str"},{"t":"eq","v":"AllUser/TempD3","vt":"str"},{"t":"eq","v":"AllUser/TempD4","vt":"str"},{"t":"eq","v":"AllUser/TempD5","vt":"str"},{"t":"eq","v":"AllUser/GasBufferPressure","vt":"str"},{"t":"eq","v":"AllUser/DewarPressure","vt":"str"}],"checkall":"true","repair":false,"outputs":13,"x":302.7734489440918,"y":286.89066314697266,"wires":[["8296ff7.35204"],["8296ff7.35204"],["8296ff7.35204"],["8296ff7.35204"],["8296ff7.35204"],["8296ff7.35204"],["8296ff7.35204"],["8296ff7.35204"],["8296ff7.35204"],["8296ff7.35204"],["8296ff7.35204"],["8296ff7.35204"],["8296ff7.35204"]]},{"id":"5dfde8c.84a0418","type":"file","z":"78e630b8.b4c73","name":"","filename":"","appendNewline":true,"createDir":true,"overwriteFile":"false","encoding":"none","x":913.0199203491211,"y":290.7460823059082,"wires":[[]]},{"id":"7b3f3352.4169ec","type":"simpletime","z":"78e630b8.b4c73","name":"","x":627.5157127380371,"y":291.6718578338623,"wires":[["4998ac55.cd0c74"]]},{"id":"8296ff7.35204","type":"join","z":"78e630b8.b4c73","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"13","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":481.7812728881836,"y":291.5234441757202,"wires":[["7b3f3352.4169ec","b351fb51.33d928"]]},{"id":"4998ac55.cd0c74","type":"function","z":"78e630b8.b4c73","name":"","func":"var line = \"Temp A\"+\",\"+\n \"Temp B\"+\",\"+\n \"Temp C\"+\",\"+\n \"Temp D1\"+\",\"+\n \"Temp D2\"+\",\"+\n \"Temp D3\"+\",\"+\n \"Temp D4\"+\",\"+\n \"Temp D5\"+\",\"+\n \"Total Volume\"+\",\"+\n \"Overall Flow Rate\"+\",\"+\n \"Dewar Pressure\"+\",\"+\n \"Gas Buffer Pressure\"+\",\"+\n \"Time\";\nmsg.filename = \"C:\\\\DataLogs\\\\User\\\\All\\\\\"+\"All \"+\n msg.payload[\"AllUser/Time\"]+\".csv\";\nvar gateIsOpen = context.get(\"gateIsOpen\") || false;\n if(msg.topic === \"gate\"){\n gateIsOpen = msg.payload;\n context.set(\"gateIsOpen\",gateIsOpen);\n }\n else{\n if(gateIsOpen === \"true\"){\n var firstline = context.get('firstline') || 0\n if (firstline === 0){\n context.set('firstline',line);\n msg.payload = line;\n return msg;\n }\n else{\n var data = msg.payload[\"AllUser/TempA\"]+\",\"+\n msg.payload[\"AllUser/TempB\"]+\",\"+\n msg.payload[\"AllUser/TempC\"]+\",\"+\n msg.payload[\"AllUser/TempD1\"]+\",\"+\n msg.payload[\"AllUser/TempD2\"]+\",\"+\n msg.payload[\"AllUser/TempD3\"]+\",\"+\n msg.payload[\"AllUser/TempD4\"]+\",\"+\n msg.payload[\"AllUser/TempD5\"]+\",\"+\n msg.payload[\"AllUser/TotalVolume\"]+\",\"+\n msg.payload[\"AllUser/OverallFlowRate\"]+\",\"+\n msg.payload[\"AllUser/DewarPressure\"]+\",\"+\n msg.payload[\"AllUser/GasBufferPressure\"]+\",\"+\n msg.myrawdate;\n msg.payload = data;\n return msg;\n }\n }\n else{\n context.set(\"first_line\",null);\n }\n } ","outputs":1,"noerr":0,"x":776.0235462188721,"y":292.0390510559082,"wires":[["5dfde8c.84a0418"]]},{"id":"7e9bb883.8fdfc8","type":"mqtt in","z":"78e630b8.b4c73","name":"","topic":"AllUser/#","qos":"2","datatype":"auto","broker":"7ac66e23.82af7","x":130.07986450195312,"y":287.8229446411133,"wires":[["77ea86f2.c48e48"]]},{"id":"6aee2b14.a50454","type":"mqtt in","z":"78e630b8.b4c73","name":"","topic":"gate","qos":"2","datatype":"auto","broker":"7ac66e23.82af7","x":479.32951164245605,"y":131.90902709960938,"wires":[["4998ac55.cd0c74"]]},{"id":"b351fb51.33d928","type":"debug","z":"78e630b8.b4c73","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":637.0764198303223,"y":366.5278129577637,"wires":[]},{"id":"7ac66e23.82af7","type":"mqtt-broker","z":"","name":"","broker":"192.168.1.50","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
It should look like:
But instead it looks like:
Any help is appreciated!