Search a Node for route the payload

Hi,

i'm searching for a node to route the payload switched from an externel signal.
for example:
send a payload "1" to the "route node" an all incoming payloads routed to OUT "1" / send a payload "2" to the "route node" an all incoming payloads routed to OUT "2"

so like a switch node with an external control input

thankx in advance

Hi @Flixm

You can achieve this with the core nodes, using a context value as the property the Switch node checks against.

  1. Configure the Switch node to check the value of flow.myRoute - add as many outputs as you need.
  2. Use a Change node to set the value of flow.myRoute to whatever value you want the Switch node to route for.
[{"id":"3cd91b448d4accf4","type":"switch","z":"98ff6cf1928b251c","name":"Switch on flow.myRoute","property":"myRoute","propertyType":"flow","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"2","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":630,"y":820,"wires":[["03df53234e82c0aa"],["c677a0ebfd976c4e"]]},{"id":"016748d2380cd914","type":"inject","z":"98ff6cf1928b251c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":400,"y":820,"wires":[["3cd91b448d4accf4"]]},{"id":"03df53234e82c0aa","type":"debug","z":"98ff6cf1928b251c","name":"debug 8","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":840,"y":800,"wires":[]},{"id":"c677a0ebfd976c4e","type":"debug","z":"98ff6cf1928b251c","name":"debug 9","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":840,"y":840,"wires":[]},{"id":"3099cdc2953c801f","type":"inject","z":"98ff6cf1928b251c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":400,"y":700,"wires":[["0966d770d6df4cb1"]]},{"id":"0966d770d6df4cb1","type":"change","z":"98ff6cf1928b251c","name":"Set to flow.myRoute to 1","rules":[{"t":"set","p":"myRoute","pt":"flow","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":630,"y":700,"wires":[[]]},{"id":"916af7e49843dd62","type":"inject","z":"98ff6cf1928b251c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":400,"y":740,"wires":[["c1c4a8e838d92ee2"]]},{"id":"c1c4a8e838d92ee2","type":"change","z":"98ff6cf1928b251c","name":"Set to flow.myRoute to 2","rules":[{"t":"set","p":"myRoute","pt":"flow","to":"2","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":630,"y":740,"wires":[[]]}]

Okay maybe i need need to explain it more detailed.

I have a payload which does not change but i want to route it to another target node.

So actually i use two gate nodes which working opposite to route the Payloads to another target.

hope that's better to understand

@knolleary's suggestion should do what you want. Alternatively look at node-red-contrib-msg-router (node) - Node-RED which has not been updated for several years, but is maintained by a regular contributer here (@BartButenaers) so I am sure it is well supported.

Okay, i'll try it. I never worked with flows ... So I need a bit more experience.

I'll check your suggestions.

Thx

That's what i need!

i was a bit confused about the two not wired Nodes. After i connected them to the Main Switch it works like i need it.

Thanks for the quick answers.

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