Correct use of switch

hello
I read a set of data from a DB, which is available to me as an array with 19 objects.

  1. payload[0].MO
    ..... up to
  2. payload[0].Z_Tone.

Can I split this with switch so that I have the 19 values at 19 outputs or do I have to use 19 functions.
I get all possible at the outputs of the switch, except the read value from database.
they can be true ore false; 1-100 and timestamps.

Not sure what you are asking.
if you want to split the message into 19 different messages, use the split node.

Maybe you can give more explanation of what you are attempting to do.

That is what I revive from maria DB:
2.11.2020, 15:28:33node: bd410f46.2525dSELECT * FROM Timer1 ORDER BY TIMESTAMP DESC LIMIT 1 : msg : Object
object
_msgid: "2b0bfc16.ca5dd4"
payload: array[1]
0: object
TIMESTAMP: "2020-11-01T22:59:53.000Z"
MO: 1
DI: 1
MI: 1
DO: 1
FR: 1
SA: 1
SO: 1
SRoff: 0
SRon: 0
SSoff: 0
SSon: 1
Toff: 1
Ton: 0
Auto: 0
Ausgang: 0
ZToff: "1604271600000"
ZTon: "0"
Z_Toff: "23:00"
Z_Ton: "00:00"
topic: "SELECT * FROM Timer1 ORDER BY TIMESTAMP DESC LIMIT 1"

instead of creating 19 functions I want to break up the array
I need to supply the 19 values to different switches or other functions. This is the status of the last saved state of the flow to bring node red after a restart back to work.
Because this does not work as an array for a switch, i have to break this into single steps
I am looking to find a nicer way as for using a bunch of functions.

example hope it helps

[{"id":"ec5fa027.d21158","type":"inject","z":"8d22ae29.7df6d","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"mo\":0},{\"sd\":1},{\"so\":0}]","payloadType":"json","x":170,"y":2900,"wires":[["26c2fb46.151804"]]},{"id":"26c2fb46.151804","type":"function","z":"8d22ae29.7df6d","name":"","func":"var msg1 =[];\nfor(var a in msg.payload){\n msg1.push([{\"payload\":msg.payload[a]}]) \n }\nreturn msg1;","outputs":3,"noerr":0,"initialize":"","finalize":"","x":310,"y":2880,"wires":[["8272e1e1.6298d8"],["511689ea.78f488"],["927b9d3c.c35e78"]]},{"id":"8272e1e1.6298d8","type":"debug","z":"8d22ae29.7df6d","name":"1111111111","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":580,"y":2860,"wires":[]},{"id":"927b9d3c.c35e78","type":"debug","z":"8d22ae29.7df6d","name":"3333333333","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":580,"y":2940,"wires":[]},{"id":"511689ea.78f488","type":"debug","z":"8d22ae29.7df6d","name":"222222222","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":580,"y":2900,"wires":[]}]
1 Like

Thanks
this helps me and I now understand how it works with multiple outputs in the function.
thank you very much for this

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