I have an input node that gives me a JSON with lots of keys and values. I'm able to extract the "deveui" value and the "payload" value. I'd like to publish this as a new MQTT message that is has a topic name of the value for "deveui" and a message that is the value for "payload".
I'm able to extract the two individually. But I'm unsure about how to create a new payload as input to the MQTT publish node so that the MQTT node takes dynamic topic and payloads.
I hope this image explains is well enough.
I tried something like this for the input function to the MQTT node, but it's incorrect.
var mynewout; mytopic = msg.deveui; mypayload = msg.payload; mynewout.topic = mytopic; mynewout.payload = mypayload; return mynewout;
Edit: Closing the loop in case someone else runs into this, I initialize the new variable to msg and the MQTT publishes work correctly now. So like this
var mynewout=msg; mytopic = msg.deveui; mypayload = msg.payload; mynewout.topic = mytopic; mynewout.payload = mypayload; msg.topic = mytopic; msg.payload = mypayload; return msg;