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?
Please help me
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
ps please excuse the typo in my uploaded picture!
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.
[{"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.
thank you, work for me
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.