UI Gauge - Splitting data before sending to Gauge

Hi,
I have the following data entering node red.

image

I want to display CV01_Rate on a Gauge UI (Dashboard 2.0). When I get the following:

image

I believe need to extract the CV01_Rate data from the initial message. If I use a debug node and use payload.CV01_Rate I get only the data I need.

What function do I need to place between my source and gauge end point?

Many thanks for any help in advance.

You do not have to split it, you can use the value format field and enter
{{msg.payload.CV01_Rate | number : 2}} the number : 2 will format it to 2 decimal places.

If you really need to split the object then a split node and switch node to route is the easiest route.
e.g.

[{"id":"54e60a80d26d8c2b","type":"inject","z":"d1395164b4eec73e","name":"if order can be different","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"CV01_Rate1\":15.12345678,\"CV01_Rate2\":16.12345678}","payloadType":"json","x":540,"y":7360,"wires":[["e8f3faaab5afb0df"]]},{"id":"e8f3faaab5afb0df","type":"split","z":"d1395164b4eec73e","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":710,"y":7360,"wires":[["ad03663e3fc51aa7"]]},{"id":"ad03663e3fc51aa7","type":"switch","z":"d1395164b4eec73e","name":"route on parts.key","property":"parts.key","propertyType":"msg","rules":[{"t":"eq","v":"CV01_Rate1","vt":"str"},{"t":"eq","v":"CV01_Rate2","vt":"str"}],"checkall":"false","repair":false,"outputs":2,"x":710,"y":7420,"wires":[["fcbf5eb9b794a3fb"],["dc6a916b731cde9d"]]},{"id":"fcbf5eb9b794a3fb","type":"debug","z":"d1395164b4eec73e","name":"msg.payload.val","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":980,"y":7360,"wires":[]},{"id":"dc6a916b731cde9d","type":"debug","z":"d1395164b4eec73e","name":"msg.payload.val","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"error_count","statusType":"auto","x":980,"y":7420,"wires":[]}]

For the next time, if you need to do something similar that is what the Change node is for.

I recommend watching this playlist: Node-RED Essentials. The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.

Also

There’s a great page in the docs (Working with messages : Node-RED) that will explain how to use the debug panel to find the right path to any data item.

Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.

BX00Cy7yHi

Thanks E1cid, but i was using the new 2.0 Dashboard where the Gauge parameter for valve is not accessible like in v1.0, I was already doing as you suggested in v1.0:

image

image

In V2.0 I couldn't see where I can assign a single parameter.

My mistake .

Then use the spllt flow example i provided or use a change node and set mag.payload to msg.payload.CV01_Rate, prior to the gauge. You will also need to round the value prior to sending to gauge
e.g.

[{"id":"0713967da54e4bd4","type":"inject","z":"e1ef5728e9206b4a","name":"if order can be different","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"CV01_Rate1\":15.12345678,\"CV01_Rate2\":16.12345678}","payloadType":"json","x":140,"y":600,"wires":[["bd97cabbea4f2f3c"]]},{"id":"bd97cabbea4f2f3c","type":"split","z":"e1ef5728e9206b4a","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":310,"y":600,"wires":[["a09b20f6bd11103c"]]},{"id":"a09b20f6bd11103c","type":"change","z":"e1ef5728e9206b4a","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$round($$.payload,1)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":120,"y":660,"wires":[["aacbcbe5483832d0"]]},{"id":"aacbcbe5483832d0","type":"switch","z":"e1ef5728e9206b4a","name":"route on parts.key","property":"parts.key","propertyType":"msg","rules":[{"t":"eq","v":"CV01_Rate1","vt":"str"},{"t":"eq","v":"CV01_Rate2","vt":"str"}],"checkall":"false","repair":false,"outputs":2,"x":310,"y":660,"wires":[["32dbde3b7f509a6e"],["3da1c9db86ff4fcb"]]},{"id":"3da1c9db86ff4fcb","type":"debug","z":"e1ef5728e9206b4a","name":"msg.payload.val","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"error_count","statusType":"auto","x":580,"y":660,"wires":[]},{"id":"32dbde3b7f509a6e","type":"debug","z":"e1ef5728e9206b4a","name":"msg.payload.val","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":580,"y":600,"wires":[]}]

I will edit the category to dashboard D2 also.

You can use a "Change" node in Node-RED and set msg.payload to msg.payload.CV01_Rate

E1cid, cheers for the examples I now understand how you got what I needed and it's working great.

joepavitt,

Thanks for your response, I had tried that a number of times but I must have got the syntax wrong as I tried your method again and it too works.

I think I was going around in circles trying to get it to work!

1 Like

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