Convert MQTT Topic for Gauge

Hi,

i got a mqtt topic which provides a temp value.

p4d2mqtt/sensor/Aussentemperatur_0x4/state :
msg.payload : Object
object
value: 3.5

How can i get the 3.5 to a gauge? I try severell things without success. Connect the mqtt direct to the gauge, via json convert and also via switch node.

Thanks & Regards
gerribaldi

The gauge node expects the numeric value to be in msg.payload
yours seems to be in msg.payload.value
use a Change node to set it to the correct property

Example Flow:

[{"id":"23068c7ddf151c0e","type":"ui_gauge","z":"5847b7aa62131d37","name":"","group":"26ff5dd1b85714c0","order":0,"width":0,"height":0,"gtype":"gage","title":"gauge","label":"units","format":"{{value}}","min":0,"max":10,"colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","className":"","x":670,"y":500,"wires":[]},{"id":"d47baf5779f73ba6","type":"inject","z":"5847b7aa62131d37","name":"fake mqtt","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"p4d2mqtt/sensor/Aussentemperatur_0x4/state","payload":"{\"value\":3.5}","payloadType":"json","x":320,"y":500,"wires":[["0cf0c49e7ef553a5"]]},{"id":"0cf0c49e7ef553a5","type":"change","z":"5847b7aa62131d37","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.value","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":500,"wires":[["23068c7ddf151c0e"]]},{"id":"26ff5dd1b85714c0","type":"ui_group","name":"Default","tab":"a2b4d00e.93a548","order":1,"disp":true,"width":"6","collapse":false,"className":""},{"id":"a2b4d00e.93a548","type":"ui_tab","name":"Test","icon":"book","order":1,"disabled":false,"hidden":false}]

The gauge can accept the value in any property
instead of {{value}}
you can us {{msg.payload.value}}
e.g.

[{"id":"d47baf5779f73ba6","type":"inject","z":"b779de97.b1b46","name":"fake mqtt","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"p4d2mqtt/sensor/Aussentemperatur_0x4/state","payload":"{\"value\":3.5}","payloadType":"json","x":90,"y":3840,"wires":[["23068c7ddf151c0e"]]},{"id":"23068c7ddf151c0e","type":"ui_gauge","z":"b779de97.b1b46","name":"","group":"8b5cde76.edd58","order":0,"width":0,"height":0,"gtype":"gage","title":"gauge","label":"units","format":"{{msg.payload.value}}","min":0,"max":10,"colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":440,"y":3840,"wires":[]},{"id":"8b5cde76.edd58","type":"ui_group","name":"","tab":"8f03e639.85956","order":1,"disp":true,"width":"12","collapse":false},{"id":"8f03e639.85956","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

Thanks a lot to everybody for the hints. It works for me in this way

[{"id":"4d8d143f287e4cb3","type":"mqtt in","z":"a130db41.078cf8","name":"Fühler Außentemp Kessel","topic":"p4d2mqtt/sensor/Aussentemperatur_0x4/state","qos":"2","datatype":"auto","broker":"40f8c1d9414e9ee8","nl":false,"rap":true,"rh":0,"x":190,"y":4040,"wires":[["cc87326c367b4017"]]},{"id":"fb97e2c00b29c422","type":"debug","z":"a130db41.078cf8","name":"1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":650,"y":3960,"wires":[]},{"id":"cc87326c367b4017","type":"json","z":"a130db41.078cf8","name":"","property":"payload","action":"","pretty":false,"x":450,"y":4040,"wires":[["fb97e2c00b29c422","d22f522462ebdea2"]]},{"id":"d22f522462ebdea2","type":"ui_gauge","z":"a130db41.078cf8","name":"Fühler Kessel","group":"5817cb8be1e74b76","order":1,"width":4,"height":3,"gtype":"gage","title":"Fühler Kessel","label":"°C","format":"{{msg.payload.value}}","min":"-20","max":"+50","colors":["#2f86bc","#00b500","#ca3838"],"seg1":"","seg2":"","className":"","x":760,"y":4040,"wires":[]},{"id":"40f8c1d9414e9ee8","type":"mqtt-broker","name":"","broker":"somewhere","port":"1883","clientid":"","usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""},{"id":"5817cb8be1e74b76","type":"ui_group","name":"Kessel","tab":"fa285b75.203de8","order":9,"disp":true,"width":4,"collapse":false,"className":""},{"id":"fa285b75.203de8","type":"ui_tab","name":"Heizung","icon":"fa-thermometer-half","disabled":false,"hidden":false}]

cool .. yea @E1cid 's recommendation was simpler
also if you set your MQTT's Output to
image
you wont need the Json node either and you can wire the Mqtt directly to the Gauge :wink:

I will try, thanks :+1:

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