Node-red repeat msg.payload in dashboard

Good evening,

I don't understand why.
Node-red repeat many times each msg.payload message in my dashbord.
eg:

Function
image

d = new Date() 
p = msg.payload.event
i = msg.payload.nodeid
// t = msg.payload.uuid
/* t = msg.topic */

if(p===0 && i == "4"){
    o = "Porte fermée";
}
if(p===255 && i == "4"){
    o = "Porte ouverte";
}
if(p===0 && i == "9"){
    o = "Aucun liquide detecte";
}
if(p===255 && i == "9"){
    o = "Liquide detecte";
}

msg.payload = o + " " + d;

return msg

And the result in Dashboard is:

Somebody could help me ?
Thank you

Add a debug to your zwave node to check that you aren’t getting duplicate messages.

You can also give your debug nodes a name to make it easier to see where they are coming from.

you're right..
image

Give..

If you change the debug to display the complete message object you should be able to filter the messages based on msg.topic and part of the msg.payload.object using switch nodes

If they are exact duplicates then the RBE node will remove the extra ones for you.

Thank you ukmoose and dceejay for your help, it's appreciate

ukmoose:
I tried that, but msg.topic and msg.payload.object seem to be identical between the detector of open/close door and the detector of water.

dceejay
Good suggestion, i didn't know that, but I have found another solution that seem to work.
I modified my function like:

d = new Date()
p = msg.payload.event
i = msg.payload.nodeid

if(p===0 && i == "4"){
o = "Porte fermée le " + d;
msg.payload = o;
return msg;
}
if(p===255 && i == "4"){
o = "Porte ouverte le " + d;
msg.payload = o;
return msg;
}
if(p===0 && i == "9"){
o = "Aucun liquide detecte le " + d;
msg.payload = o;
return msg;
}
if(p===255 && i == "9"){
o = "Liquide detecte " + d;
msg.payload = o;
return msg;
}

And it works well :wink:

1 Like