0% found this document useful (0 votes)
50 views1 page

Multiple Outputs: Banana

The function edit dialog in Node-RED allows functions to have multiple outputs, returning an array of messages. This makes it possible for a function to send different messages to each output depending on conditions, such as sending messages on a specific topic to the second output instead of the first. Functions can also return the original message on one output while transforming the message sent to the other output, such as sending the original message to one output while sending a message with the payload length to the second output.

Uploaded by

rshegde
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views1 page

Multiple Outputs: Banana

The function edit dialog in Node-RED allows functions to have multiple outputs, returning an array of messages. This makes it possible for a function to send different messages to each output depending on conditions, such as sending messages on a specific topic to the second output instead of the first. Functions can also return the original message on one output while transforming the message sent to the other output, such as sending the original message to one output while sending a message with the payload length to the second output.

Uploaded by

rshegde
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Multiple Outputs

The function edit dialog allows the number of outputs to be changed. If there is more
than one output, an array of messages can be returned by the function to send to the
outputs.

This makes it easy to write a function that sends the message to different outputs
depending on some condition. For example, this function would send anything on
topic banana to the second output rather than the first:

if (msg.topic === "banana") {


return [ null, msg ];
} else {
return [ msg, null ];
}

The following example passes the original message as-is on the first output and a
message containing the payload length is passed to the second output:

var newMsg = { payload: msg.payload.length };


return [msg, newMsg];

You might also like