# String value from mqtt to Node Red Dashboard

**URL:** <https://discourse.nodered.org/t/string-value-from-mqtt-to-node-red-dashboard/62000>\
**Category:** Dashboard\
**Tags:** node-red-dashboard, mqtt\
**Created:** [30 April 2022 13:43 UTC](https://discourse.nodered.org/t/string-value-from-mqtt-to-node-red-dashboard/62000 "2022-04-30T13:43:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rolandoartha](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rolandoartha/32/60834_2.png) [@rolandoartha](https://discourse.nodered.org/u/rolandoartha)\
**Post date:** [30 April 2022 13:43 UTC](https://discourse.nodered.org/t/string-value-from-mqtt-to-node-red-dashboard/62000/1 "2022-04-30T13:43:20Z")

</div>

Guys, i use mqtt to send data to node red, the values are string, how can i input the temperature and humidity value to the gauge dashboard separately?  
 ![json](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/a/7af9cad315d66dda81f58770d3dd11de1727189f.png)  
Please help me 🙂

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [30 April 2022 14:06 UTC](https://discourse.nodered.org/t/string-value-from-mqtt-to-node-red-dashboard/62000/2 "2022-04-30T14:06:47Z")

</div>

It would be much better to change the data you are sending, perhaps something like  
data { "temperature": 24.60, "temperatureunits": celsius, "humidity": 15.00, "humidityunits": "percent"}

That said, a change node can convert the specific example data you showed us

 ![Untitled 3](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/5/c54d8e1b1f7baea3501e03f69b7ea60075aa6f0a.jpeg)

ps please excuse the typo in my uploaded picture!

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [30 April 2022 14:29 UTC](https://discourse.nodered.org/t/string-value-from-mqtt-to-node-red-dashboard/62000/3 "2022-04-30T14:29:07Z")

</div>

The gauge will accept strings directly but it is then difficult to format.

Here is an example of using the strings directly, and an example of converting to floats. In the temp gauge i also show an example of formatting. I also include a simple function to convert from string to float.

```auto
[{"id":"cf5505da.f04fe8","type":"inject","z":"bf9e1e33.030598","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"data\":{\"temperature\":\"22.25 celcius\",\"humidity\":\"55 %\"}}","payloadType":"json","x":190,"y":60,"wires":[["33b4f522.cbefa2","f0fab085.f5066","416e35b9.2fcfbc"]]},{"id":"33b4f522.cbefa2","type":"ui_gauge","z":"bf9e1e33.030598","name":"String hum gauge","group":"8b5cde76.edd58","order":8,"width":0,"height":0,"gtype":"gage","title":"string hum","label":"","format":"{{msg.payload.data.humidity}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","className":"","x":470,"y":60,"wires":[]},{"id":"f0fab085.f5066","type":"ui_gauge","z":"bf9e1e33.030598","name":"string temp gauge","group":"8b5cde76.edd58","order":8,"width":0,"height":0,"gtype":"gage","title":"string temp","label":"","format":"{{msg.payload.data.temperature}}","min":"-10","max":"50","colors":["#21a1de","#5fad47","#ca3838"],"seg1":"0","seg2":"30","className":"","x":470,"y":100,"wires":[]},{"id":"416e35b9.2fcfbc","type":"function","z":"bf9e1e33.030598","name":"","func":"msg.payload.temp = parseFloat(msg.payload.data.temperature);\nmsg.payload.hum = parseFloat(msg.payload.data.humidity);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":290,"y":160,"wires":[["640fb6b3.9a2528","ab623610.b5cf58"]]},{"id":"640fb6b3.9a2528","type":"ui_gauge","z":"bf9e1e33.030598","name":"","group":"8b5cde76.edd58","order":8,"width":0,"height":0,"gtype":"gage","title":"number hum","label":"","format":"{{msg.payload.hum}} %","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","className":"","x":480,"y":180,"wires":[]},{"id":"ab623610.b5cf58","type":"ui_gauge","z":"bf9e1e33.030598","name":"","group":"8b5cde76.edd58","order":8,"width":0,"height":0,"gtype":"gage","title":"number temp formated","label":"","format":"{{msg.payload.temp | number : 1}} C","min":"-10","max":"50","colors":["#21a1de","#5fad47","#ca3838"],"seg1":"0","seg2":"30","className":"","x":520,"y":220,"wires":[]},{"id":"8b5cde76.edd58","type":"ui_group","name":"default","tab":"8f03e639.85956","order":1,"disp":false,"width":"12","collapse":false},{"id":"8f03e639.85956","type":"ui_tab","name":"Home","icon":"dashboard","order":2,"disabled":false,"hidden":false}]

```

Copy the flow json, then in editor press ctrl i and paste the json , then press import to see the example flow.

---

<div class="post-metadata">

**Author:** ![rolandoartha](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rolandoartha/32/60834_2.png) [@rolandoartha](https://discourse.nodered.org/u/rolandoartha)\
**Post date:** [30 April 2022 15:00 UTC](https://discourse.nodered.org/t/string-value-from-mqtt-to-node-red-dashboard/62000/4 "2022-04-30T15:00:33Z")

</div>

thank you, work for me 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [14 May 2022 15:00 UTC](https://discourse.nodered.org/t/string-value-from-mqtt-to-node-red-dashboard/62000/5 "2022-05-14T15:00:34Z")

</div>

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