Help parsing out MQTT message

Hey everyone, I'm getting into node red and have an ESP32 broadcasting some MQTT messages for a Ruuvitag and they are received by Mosquitto broker. I then read these values into node-red via the MQTT subscribe node. I managed to get some data which looks like the following payload:


I'm wondering if anyone can suggest a way to parse out this data such that I can use the values individually to control a flow, for example just reading the temperature value and sending that through as a payload.

Any help is much appreciated!

First thing to know is whether you've managed to work out that the MQTT-in node will deliver that MQTT message as a long string instead of an object (which is what you want). You can fix that by changing the settings so that it automatically converts the string to JSON.

Then you have a JavaScript object on the msg.payload that you can work with. If, for example, you want the temperature, msg.payload.temperature is the property name.

By putting in a debug node onto the output of the mqtt-in node, you will be able to see exactly the property names you need. Indeed, the debug panel has small icons against each property line that will copy the full property name (though without the msg. bit since change and other nodes have that as a drop-down selection already.

1 Like

Thank you very much kind sir! Changing the MQTT subscribe node to a parsed JSON object did the trick, I was then able to use the debug node to reference the individual objects by copying the path in the debug window.

1 Like