sunny
sunny

Reputation: 51

Node Red. Spilt/Break message from mqtt broker(mosca)

How do I break/split the message received from mqtt broker(mosca)? The whole message come with packet, topic, messageid, payload, etc. I just need the payload {"T":"t"} displayed at the debug node. I tried the split and switch node, it doesn't seem to work, no response at the output.

mqtt device enter image description here

mqtt broker enter image description here

Upvotes: 0

Views: 449

Answers (1)

hardillb
hardillb

Reputation: 59618

You should probably be using the MQTT-in node to subscribe to the topics you want rather than the output of the Mosca broker node, which will include EVERY message sent to the broker (with all the internal detail that you don't want.

But you can move the msg.packet.payload to msg.payload with the change node. Then run that output through the JSON node which will parse the String representation of the JSON object back into a proper object.

(If you use the MQTT-in node you will still need to use the JSON node)

Upvotes: 1

Related Questions