Function Node split message to more outputs

Hi Node-Red forum members,

I'm a german Node-Red beginner.
I read this topic again and again, but can't solve my problem.

I want to split a Database result in different outputs from a function node.

The database query works:

25.4.2019, 21:21:26node: 6acfe7c1.46d2c8SELECT * FROM tb_Pool_Variables : msg : Object


_msgid: "763b500d.377b"

topic: "SELECT * FROM tb_Pool_Variables"

payload: array[1]

0: object

Max_Pool_Temp: 30

Einschalthysterese: 6

Ausschalthysterese: 1

Now i try to seperate Max_Pool_Temp, Einschalthysterese and Ausschalthysterese to 3 outputs of an function node.
I always get the message:
Function tried to send a message of type number

Yes i want to send a message of type number?!?
I tried to cast it to string, then i get the error message : Fuction tried to send a message of type String.

I would be very grateful if someone could help me.
Please excuse my poor english.

Firstly, your English is fine. You really need to post your flow here so that we can have a look. It looks like you are trying to return just a number in your function but you need to return the message object!

This is my Init-Flow:

Here i want to feed the Gauge - Elements with the database data of the temperatures.

This is my seperate Values funtction node:

There’s a page in the documentation that explains how you can use the debug output to
identify the correct path to any item

Understanding javascript objects and arrays is critical to getting the most from Node-RED

1 Like

The fundamental issue is that you must always return an object (ie a message), not just a value or string. Often what you want to do is return a message with a value in the payload, so you may want the return to be something like

return [{payload: msg.payload[0].Max_Pool_Temp}, {payload:....},{..}]
1 Like