Returning TWO msg.payloads?

#1

New problem.

(Of course)

With new knowledge I am re-writing a lot of my flows to simplify things. Or so I hope.

I have a “node” that detects if things are good or bad.
If good, all is … good.

If bad, it sends ONE message to wipe data from being displayed on Gauges and Charts.

And there is the problem.

To wipe a Gauge, I have to send it 0.
To wipe a Chart I have to send it NULL.

To cut down on nodes and types of nodes, I have one.
(Function block.)

if (msg.topic === 'RESET')
{
    //
    msg.payload = '0';
    return msg;
}
return msg;

I don’t know if I am getting “carried away” with this style of thinking or what, but please indulge me.

Alas that wipes Gauges, but not Charts (or graphs as I call them).
They need a NULL.

Is it I shall have to make a second version of this that sends msg.payload = [] rather than 0, or can I send two payloads?
Or make two outputs?

0 Likes

#2

Sorry, something is happening and it needs further investigation.

0 Likes

#3

You cannot return more than once from a function. Once you return the function stops.

The documentation covers how to send multiple messages from a function, as well as how to send messages without using return.

https://nodered.org/docs/writing-functions

0 Likes

#4

True,

But I did get around it with the trigger node.

So the problem as it is/was have been resolved.

0 Likes