Using a Switch Node to parse a Modbus Read Array

I'm reading 16 consecutive Modbus Input Contacts (i.e., function code 2) on a digital input card and the result from the Modbus node is an array of 16 elements. I'd like to use the Switch node to parse the 16 element array into 16 paths so I can use each pin of the Switch node to set tags with the associated Boolean values.
My Modbus array result:
Capture

My Switch Node Configuration which is not working:

If you want each element of the array sent to diffeent outputs.

here is an example.

[{"id":"449af8d3.050b68","type":"inject","z":"c74669a0.6a34f8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[false,false,false]","payloadType":"json","x":150,"y":2020,"wires":[["71bb8075.c7fc48"]]},{"id":"71bb8075.c7fc48","type":"split","z":"c74669a0.6a34f8","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":370,"y":2020,"wires":[["10edad9.21280d2"]]},{"id":"10edad9.21280d2","type":"switch","z":"c74669a0.6a34f8","name":"","property":"parts.index","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"str"},{"t":"eq","v":"1","vt":"str"},{"t":"eq","v":"2","vt":"str"}],"checkall":"false","repair":false,"outputs":3,"x":560,"y":2020,"wires":[["5369c443.3d6454"],["2863627c.de639e"],["a570b87f.d22fe8"]]},{"id":"5369c443.3d6454","type":"debug","z":"c74669a0.6a34f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":730,"y":2000,"wires":[]},{"id":"2863627c.de639e","type":"debug","z":"c74669a0.6a34f8","name":"out 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":730,"y":2040,"wires":[]},{"id":"a570b87f.d22fe8","type":"debug","z":"c74669a0.6a34f8","name":"out 3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":730,"y":2080,"wires":[]}]

Very cool solution - thank you very much E1cid!

E1cid,

Would you know how to prevent the first msg.payload from the Split node to not pass an object and only the boolean payload. All other sequential msg.payload work great and pass a boolean value. See below.

E1cid,
Sorry about that previous question. I see your code simply enabled the complete message object in the debug node. I'm all set. Thank you,

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