Converting MQTT Payload to Dashbard gauge


my name is Steffen, and I am new to Node Red and this board.

I am also not very used to this JSON stuff. Actually I am very blind. Maybe anyone can help me.

I got an MQTT message payload string which looks like this

"{"value": -161}"

How can I change it, so that a dashboard gauge can handle the value as int. So I am interested in the -161 only. it can have positive and negative values up to int32 range. I would like to use a function block or direct entry in dashboard gauge If possible.

I am sure, this is very simple, but I don't get it...

thanks in advance,

if it’s coming from MQTT it will be a string as you noticed. So use the JSON node to convert it back to a javascript object.

If you use a debug node after the JSON node you should see msg.payload.value is -161

Most nodes in Node-RED expect the important information to be in msg.payload

so you can then use a change node to Move msg.payload.value
to msg.payload

1 Like

Thanks a lot. This worked.