How to send multiple values in node-red

Go and look at the link on sending messages again. You have written it to send each message to a different output (but have only allowed one). You want to send all the messages to one output.

I have connected debug node to this function node only
error5

Is that comment a reply to my point about the fact that have coded it to send one output to multiple outputs instead of multiple messages to one output? If so then I don't understand the relevance of it.

I want to send multiple values in a single function.otherwise I have to create multiple function nodes to send multiple values.

So you want to send multiple values in one message?
i.e just as they arrived in your function node?

Or do you want to send different values in different messages along one wire to the next node

Or do you want to send different values in different messages to different nodes?

Do you want to send multiple messages each containing one value, or one message containing multiple values? We have assumed here that you are trying to send multiple messages as that is what you seemed to be asking and what you coded into your function node. Your data coming in is already multiple values in one message so it is not at all clear what you are trying to do.

I want to create email alerts for a particular value of vibration and temperature.
But Vibration comes in different values like rms_x,rms_y,rms_z etc
error2

I have created a function for sending temperature value

like this i want to create alerts for different vibration values.
But the problem is i have to create multiple functions for each value.

So i want to create a single function for multiple values ,like above example

Hi @adamf

If you want each of those messages to be sent, one after the other, from the single output of the Function node, then all you need to do is change:

return [ RMS_X, ..., Temperature] ;

to

return  [ [ RMS_X, ..., Temperature ] ] ;

Alternatively, if you want to conditionally send some messages you could do:

if (msg.payload.temperature > 25) {
   node.send({
      topic: "Subject: System .... ",
      payload: "Temperature:" + msg.payload.temperature;
   });
}

if (msg.payload.otherProperty > 10) {
   node.send({
      topic: "Subject: Something something .... ",
      payload: "Something:" + msg.payload.otherProperty;
   });
};

return;

By the way - please try to avoid sharing screenshots of code. It makes it impossible for us to suggest changes without retyping your code. As longs as they are relatively short, paste in your code here with ``` on a new line before and after.

In that case you were nearly right in the function posted, except you have told it to send them to multiple outputs. As I said look again at the link posted. You need to send an array containing an array, so change the last line to something like

return [[ RMS_X, RMS_Y, ... ]]

Also please don't use the word values when you mean messages (each containing a value).

Thanx for the help, I'll try this.

This is good solution,but if 6 or 7 values are true at same time,then it shows error

SMTP Error: 454 4.7.0 Too many login attempts, please try again later

or

"Error: Invalid login: 454 4.7.0 Too many login attempts, please try again later. d6sm2996397pgf.55 - gsmtp"

but it is sending emails also
now the problem is,it is sending different mail to different value like rms_x,rms_y,min_x etc.

How can i send only mail containing all the values which are true

I also tried this code

if (msg.payload.rms_x >500 || msg.payload.rms_y >800 || msg.payload.rms_z >500 || msg.payload.max_x >50 || msg.payload.max_y >50 || msg.payload.max_z >500 || msg.payload.min_x <0 || msg.payload.min_y <50 || msg.payload.min_z <50 )
 {
     msg.topic = "Subject Vibration has been exceeded";
     msg.payload = "Vibration:" + String(msg.payload.rms_x,msg.payload.rms_y,msg.payload.rms_z,msg.payload.max_x,msg.payload.max_y,msg.payload.max_z,msg.payload.min_x,msg.payload.min_y,msg.payload.min_z);
 
     return msg;
 }

Output

object
topic: "Subject Vibration has been exceeded"
data: object
nodeId: 0
firmware: 1
battery: 3.2940600000000004
counter: 84
sensor_type: 8
sensor_data: object
sensor_name: "Vibration"
type: "sensor_data"
addr: "00:13:a2:00:41:91:25:d4"
received: 1567671204814
original: object
payload: "Vibration:134.47"
_msgid: "3a2270bc.fa72d"

only sending first value.
please help me with this

Thanx

Try changing your logical operators for or to and

https://www.w3schools.com/js/js_comparisons.asp

Yes Sir,I know that,I have used that one also,but it requires all the values to be true.

then only it will send mails

can we do with this solution to send all the values in one mail

Then you could test each one separately if it is true then add it to msg.payload.

At the end if msg.payload has any length then send ...

would you please write little example
thanx

Have a go, it's basic javascript...

I have written this

var Temprature = '';
var Humidity = '';
var RMS_x = '';
var RMS_y = '';
var RMS_z = '';
var MAX_x = '';
var MAX_y = '';
var MAX_z = '';
var MIN_x = '';
var MIN_y = '';
var MIN_z = '';

if (msg.payload.temperature > 28) //You can add value according to your need
{
     Temprature = "Temprature "+msg.payload.temperature;
   
}

if (msg.payload.humidity > 80) 
{
   Humidity = "Humidity: "+msg.payload.humidity;
   
}

if (msg.payload.rms_x > 100) 
{
     RMS_x = "RMS_x: "+msg.payload.rms_x;
   
}
if (msg.payload.rms_x > 100) 
{
     RMS_y = "RMS_y: "+msg.payload.rms_y;
   
}
if (msg.payload.rms_x > 100) 
{
    RMS_z = "RMS_z: "+msg.payload.rms_z;
   
}
if (msg.payload.max_x > 100) 
{
     MAX_x = "MAX_x: "+msg.payload.max_x;
   
}
if (msg.payload.max_y > 100) 
{
     MAX_y = "MAX_y: "+msg.payload.max_y;
   
}
if (msg.payload.max_z > 100) 
{
    MAX_z = "MAX_z: "+msg.payload.max_z;
   
}
if (msg.payload.min_x < -100 ) 
{
    MIN_x = "MIN_x: "+msg.payload.min_x;
   
}
if (msg.payload.min_y < -100) 
{
     MIN_y = "MIN_y: "+msg.payload.min_y;
   
}
if (msg.payload.min_z < -100) 
{
     MIN_z = "MIN_z: "+msg.payload.min_z;
   
}

node.send({
      topic: "Subject: System value has been exceeded ",
      payload: "Property:" + Temprature+ " " + Humidity + " " + RMS_x + " " + RMS_y + " " + RMS_z +" " + MAX_x+ " " + MAX_y+ " " + MAX_z + " " + MIN_x +" " + MIN_y +" " + MIN_z ,
   });

return;

but when there is no values,then also it is sending data

Just for clarification, are you saying it should only send the email when all the conditions are true?
So in text, when rms_x is bigger than 500, and rms_y is bigger than 800, and rms_z bigger than 500, and max_x bigger than 50, and ... and so on.

The code you posted below that will send an email every time one of those values is exceeding, and posts them for all. The suggestion @ukmoose then added would result in only getting an email when all of those values were true.

This suggestion, would solve your problem. Take a look at the documentation for dealing with messages first.

The basic idea is based on using msg.payload as object, so start with creating a copy of the contents of msg.payload so you can keep those in your checks.
Then create a new empty object to use as payload: var basePayload = {}.
Next you add those checks like you did in your last post, except instead of writing to separate values, you would write those to your new basePayload object. Since it's an object already, you won't have to define properties on it.
Finally, after all those if statements for the checks, test if your basePayload is still an empty object. If so, nothing exceeded, so nothing has to be send. If it isn't, use it to format your email with the values. They're in your basePayload, you can set them now to be send the way you would like.