Dashboard Gauge - programatically change the 'Units'

Hi Everyone,

I'm looking for a way to programatically change the 'Units' field in my flow. For example I wan't to be able to change the Units from 'BAR' to 'PSI' depending on my end device configuration.

I looked at modifying the parameter through the msg.ui.control properites
([node-red-dashboard/config-fields.md at master · node-red/node-red-dashboard · GitHub]), but the 'Units' field is not listed as a modifiable property through this implimentation.

Any help will be appreciated on how I might change the Units on the fly (maybe it can be done throught CSS?)

Many thanks

Michael

If you read the sidebar help text it says

The label can also be set by a message property by setting the field to the name of the property, for example {{msg.topic}} .

This also applies to value format and unit input fields. So you can feed in any msg property you wish, and dynamically populate the fields.
e,g

[{"id":"3a8b88d5c2d8e8c5","type":"inject","z":"d1395164b4eec73e","name":"","props":[{"p":"payload"},{"p":"units","v":"BARS","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"2","payloadType":"num","x":610,"y":4520,"wires":[["a1150a35d5b13b55"]]},{"id":"a1150a35d5b13b55","type":"ui_gauge","z":"d1395164b4eec73e","name":"","group":"4f791fdc1745d3d9","order":3,"width":0,"height":0,"gtype":"gage","title":"gauge","label":"{{msg.units}}","format":"{{value}}","min":0,"max":"50","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","diff":false,"className":"","x":790,"y":4520,"wires":[]},{"id":"6ea8cae4f7759baa","type":"inject","z":"d1395164b4eec73e","name":"","props":[{"p":"payload"},{"p":"units","v":"PSI","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"40","payloadType":"num","x":610,"y":4560,"wires":[["a1150a35d5b13b55"]]},{"id":"4f791fdc1745d3d9","type":"ui_group","name":"micro","tab":"c954274bbed7292e","order":1,"disp":false,"width":"18","collapse":false,"className":""},{"id":"c954274bbed7292e","type":"ui_tab","name":"Solar","icon":"dashboard","order":1,"disabled":false,"hidden":false}]
1 Like

Hi E1cid,

Many thanks for the solution - much appreciated, work a treat.

Thanks

Michael