Funktion node with String msg

Hi to all,
see below Function block
Test 1.

if (msg.payload <=0)
{
return "Pressure too low";
} else {
return[""];
}
Test 2.
var msg1= "Pressure too low";
if (msg.payload <=0)
{
return msg1;
} else {
return[""];
}

The else case is working!
Result: Function tried to send a message of type string
I can do a work around with the change node, but I would like do it complete in the function node
Wolfgang

Please check the documentation.

Function node should return msg
Thus, you need to return something like:

return {payload:"Pressure too low"}

You can change it like:

if (msg.payload < 1){
    return {payload:"Pressure too low"};
} 

The else is not needed, unless you want to return something.

Yes, you are right! Sorry, but these is one of these days, where you should stop working and go home and drink a beer!
Thanks for clear it up

1 Like

Cheers to that ! :beers: