A "reverse" switch?

I have 2 different payloads coming into a node. They have different topics. How do I switch what comes out of the output based on a property? So if a property = 1, then output the payload with topic 1, if 2, then output the payload with topic 2.

Acts like reverse switch, right? Switch node has 1 input, 2 output routes. What I'm thinking of is a node with 2 input, with 1 output route.

Could you post the two (complete) payloads?

It is just I think you are not quite understanding how to use a switch node to its capacity.

(And) you may need to use more than one switch node.

Use a Change node configured to Set msg.topic To msg.property.
So if msg.property = 1 then the msg.topic will be set to 1.

That's another way.

Good on you @Colin.

This is interesting.

Taking a step back and trying to see the bigger picture:
I'm guessing you want the topic to be set so the next stage of the flow can determine what to do with the message.

Why can't you use the property part of the message at the next stage?

Actually I think that @traderjoe needs to ask the question again in a way that is easier to understand, as I expect he/she can see now that he has not explained it very well.

@traderjoe
This flow does what I make of your question:

[{"id":"24597219.e27fbe","type":"inject","z":"703c61ac.837e1","name":"","props":[{"p":"payload"},{"p":"something_else","v":"blah","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"message one","payloadType":"str","x":1770,"y":230,"wires":[["29bc705.2a71b1"]]},{"id":"1e4f1eca.f73bc9","type":"inject","z":"703c61ac.837e1","name":"","props":[{"p":"payload"},{"p":"something_else","v":"foo","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"message two","payloadType":"str","x":1770,"y":280,"wires":[["29bc705.2a71b1"]]},{"id":"29bc705.2a71b1","type":"switch","z":"703c61ac.837e1","name":"something_else","property":"something_else","propertyType":"msg","rules":[{"t":"eq","v":"blah","vt":"str"},{"t":"eq","v":"foo","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1950,"y":260,"wires":[["6546362e.6e658"],["1c352175.76b1bf"]]},{"id":"6546362e.6e658","type":"debug","z":"703c61ac.837e1","name":"1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":2120,"y":230,"wires":[]},{"id":"1c352175.76b1bf","type":"debug","z":"703c61ac.837e1","name":"2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":2120,"y":290,"wires":[]}]

Very basic flow to get the idea through.

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