How do I send several simple messages in one function node?

I want to have different nodes to run different groups of RollerTrols with the RFXtrx. I am looking for something like this:

var msg1 =  { topic: "BLINDS_T0/0x3939/4", payload:"Open" };
var msg2 =  { topic: "BLINDS_T0/0x3939/5", payload:"Open" };
var msg3 =  { topic: "BLINDS_T0/0x3939/6", payload:"Open" };
var msg4 =  { topic: "BLINDS_T0/0x3939/7", payload:"Open" };
var msg5 =  { topic: "BLINDS_T0/0x3939/8", payload:"Open" };
var msg6 =  { topic: "BLINDS_T0/0x3939/9", payload:"Open" };
return [ msg1, msg2, msg3, msg4, msg5, msg6 ];

This of does not work, it only sends the first message. The problem is that in the multiple messages section of the documentation it can't find out how to send different messages with different topics, only mesages with different payloads, so I don't see what my fault is. Can somebody please help me out?

Hi @Mastiff

when you return an array of messages like that, the Function node will pass the first message to the first output, the second message to the second output, and so on.

If you want the node to send all of those messages from the first output, you need to do:

return [ [ msg1, msg2, msg3, msg4, msg5, msg6 ] ];

Thank you very much! :slight_smile: Works perfectly!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.