RETURN a Payload and a Topic with Function like a injectnode

Hello everyone, With an inject node as shown in the photo I manage to send a payload with the content 139790555651 and at the same time a topic with the content 120 (the values don't matter)
Here is a picture of the functioning Injectnode and the contents of the debug
injectnode
injectnoderesult

If I use the inject node then my function behind it works perfectly.
Now I would like to replace the injectnode with a function.
However, only the payload arrives at the end. I don't get the topic name.
Here is my function node and the contents of the debug
As you can see, the topic is not transferred!?


functionnoderesult

So it seems to be an error in my function. Can someone tell me how to change my function so that both the contents of Payload and Topic are sent?
Thank you in advance as always

here is the code to change:

var DerStatus = msg.payload;
if (DerStatus === "Geöffnet") {
    return [
        { payload: 300 },
        { topic: '139790555651'}
    ]
}
else {
    return [
        { payload: 0 },
        { topic: '139790555651'}
    ]
}

Hi @einfach112

That is sending an array of messages.

To send 1 message with both properties.

return  { payload: 300, topic: '139790555651'}

THANK YOU for your Backup ! IT WORKS!

image

image

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