What is the right or best way?

I've done this several ways (different every time) and basically poke till it works but think not 'the right way'. How should it be done?

In this case we have a sensor spitting out the string {"speed":0,"direction":301}

Run it thru a json node and we get
object
speed: 8.1
direction: 180

From there I can split or sort to get a gauge but it feels like that's not the correct solution...

Did the homework, came up with this. Many thanks to previous posts!

Simple (once you figure it out) set the mqtt node output to a parsed JSON object then {{msg.payload.speed}} for the value format in gauge.

[{"id":"bc56177d.74aa18","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"130a5646.78895a","type":"mqtt in","z":"bc56177d.74aa18","name":"","topic":"anemometer/five_second_avg","qos":"2","datatype":"json","broker":"59511bc6.baa294","nl":false,"rap":true,"rh":0,"x":410,"y":540,"wires":[["56bc69f9.f74c58","99ee3a89.6ea428","536d3358.6f2a7c"]]},{"id":"56bc69f9.f74c58","type":"debug","z":"bc56177d.74aa18","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":710,"y":500,"wires":[]},{"id":"99ee3a89.6ea428","type":"ui_gauge","z":"bc56177d.74aa18","name":"Speed","group":"27899de0.e78e22","order":2,"width":0,"height":0,"gtype":"gage","title":"Windspeed","label":"MPH","format":"{{msg.payload.speed}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":690,"y":540,"wires":[]},{"id":"536d3358.6f2a7c","type":"ui_gauge","z":"bc56177d.74aa18","name":"Speed","group":"27899de0.e78e22","order":2,"width":0,"height":0,"gtype":"compass","title":"Windspeed","label":"Degrees","format":"{{msg.payload.direction}}","min":0,"max":"360","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":690,"y":580,"wires":[]},{"id":"59511bc6.baa294","type":"mqtt-broker","name":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"protocolVersion":"3","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""},{"id":"27899de0.e78e22","type":"ui_group","name":"Weather","tab":"7d7bbe46.42567","order":3,"disp":true,"width":"6","collapse":false},{"id":"7d7bbe46.42567","type":"ui_tab","name":"Data","icon":"dashboard","disabled":false,"hidden":false}]
3 Likes

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