UI_GAUGE node, dynamic range?

Hello,
concerning the UI_GAUGE node image , would it be possible to make both min and max values dynamic with an annexed parameterization page where I could define these default values.
Example, a 12V battery or a 24V battery, the scale would be from 0 to 12 for the first one, and from 0 to 24 for the second one. This would make my code dynamic and configurable for various installations without having to touch the NR editor.
Thanks for inputs.

That can be done by using msg.ui_control . See the docs here https://github.com/node-red/node-red-dashboard/blob/master/config-fields.md#ui-widget-configuration-via-msgui_control

Too strong :v: Thank you very much.
I didn't know about this. It is very much appreciated. Thank you for the quick help

RTFM is still needed :face_with_monocle:

1 Like

Here is the example (below) with the node "function" for the next person who asks himself the same question as me.

Now I have to ask the user to fill in the 2 min and max fields, pass them in the function node, that should be fine.
But how to save the data for a future NR reboot and reload them at startup. (and override the defauts values)
In short, of course i whant don't lose these user defined values.

What would be the best solution ?

  • Create one or more .ini file(s) , but if one file, how to parse this ?
  • Store the values in my DB (influxdb)
  • Another idea to do this ? If there's any example, it would obviously be great.
[{"id":"e44864d7.49bd78","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"7ba4d99f.5e0c78","type":"function","z":"e44864d7.49bd78","name":"","func":"msg.ui_control = { \"min\":00, \"max\":50 }\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":220,"y":80,"wires":[["7b9509ca.516d48"]]},{"id":"7b9509ca.516d48","type":"ui_gauge","z":"e44864d7.49bd78","name":"","group":"67452c21.0b93e4","order":1,"width":0,"height":0,"gtype":"gage","title":"gauge","label":"units","format":"{{value}}","min":0,"max":10,"colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":370,"y":100,"wires":[]},{"id":"3b8b62f1.8f2f0e","type":"inject","z":"e44864d7.49bd78","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"30","payloadType":"num","x":70,"y":80,"wires":[["7ba4d99f.5e0c78"]]},{"id":"cb38066e.ce7108","type":"function","z":"e44864d7.49bd78","name":"","func":"msg.ui_control = { \"min\":100, \"max\":2000 }\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":220,"y":140,"wires":[["7b9509ca.516d48"]]},{"id":"5ab6702.b70109","type":"inject","z":"e44864d7.49bd78","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1500","payloadType":"num","x":70,"y":140,"wires":[["cb38066e.ce7108"]]},{"id":"67452c21.0b93e4","type":"ui_group","name":"Essais","tab":"159c03ce.b0101c","order":1,"disp":false,"width":"6","collapse":false},{"id":"159c03ce.b0101c","type":"ui_tab","name":"Essais","icon":"dashboard","order":3,"disabled":false,"hidden":false}]

You can store them in persistent context - eg read up here - A guide to understanding 'Persistent Context' and the docs https://nodered.org/docs/user-guide/context

You can store them in persistent context

Yes, that's exactly it. I just remembered it just now. I had already done this once before.
Great idea. Thanks dceejay for getting me back on track!

You can explore this example also.

Interesting indeed.
I might use it for the display on the phone. It's good to know.
Otherwise thank you all for your help, here is what I was able to achieve with Node Red.

The follow-up of my Photovoltaic installation which has only one serial port and no operating software to have a synthetic view of what happens except a small screen on the inverter.
This is now a thing of the past! It runs on a Pi3 with NR + influxdb and grafana.

One of the future big step is to use SVG to make an animation of the electrical flows, like in the industry with SCADA's

This forum is all I appreciate, sharing information without restraint.

View of my dashboard:

1 Like

Finally,
here's what I made with your info.
The gauge is customizable and the max and min values survive a restart of Node Red by returning to the previously defined values.
This is exactly what I wanted.

I provide the flow as an example.

[{"id":"e44864d7.49bd78","type":"tab","label":"essais","disabled":false,"info":""},{"id":"7ba4d99f.5e0c78","type":"function","z":"e44864d7.49bd78","name":"Défini les caractéristiques \\n de la jauge","func":"var minimum = flow.get(\"Gauge-min\");\nvar maximum = flow.get(\"Gauge-max\");\n\nmsg.ui_control = {min:minimum, max:maximum}\nmsg.payload = 0\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":630,"y":220,"wires":[["7b9509ca.516d48"]]},{"id":"7b9509ca.516d48","type":"ui_gauge","z":"e44864d7.49bd78","name":"","group":"67452c21.0b93e4","order":1,"width":0,"height":0,"gtype":"gage","title":"gauge","label":"[V]","format":"{{value}}","min":0,"max":10,"colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":810,"y":160,"wires":[]},{"id":"ab8cdeac.f540b","type":"ui_text_input","z":"e44864d7.49bd78","name":"","label":"Min Gauge value :","tooltip":"","group":"67452c21.0b93e4","order":2,"width":"3","height":"1","passthru":true,"mode":"text","delay":"0","topic":"","x":190,"y":200,"wires":[["a6be09b7.6e78a8"]]},{"id":"9b6353df.af102","type":"ui_text_input","z":"e44864d7.49bd78","name":"","label":"Max Gauge value :","tooltip":"","group":"67452c21.0b93e4","order":2,"width":"3","height":"1","passthru":true,"mode":"text","delay":"0","topic":"","x":190,"y":240,"wires":[["36c7d1e0.03b50e"]]},{"id":"a6be09b7.6e78a8","type":"function","z":"e44864d7.49bd78","name":"Gauge-min","func":"flow.set(\"Gauge-min\",msg.payload);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":390,"y":200,"wires":[["7ba4d99f.5e0c78"]]},{"id":"36c7d1e0.03b50e","type":"function","z":"e44864d7.49bd78","name":"Gauge-max","func":"flow.set(\"Gauge-max\",msg.payload);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":390,"y":240,"wires":[["7ba4d99f.5e0c78"]]},{"id":"df11a9eb.a3d278","type":"ui_slider","z":"e44864d7.49bd78","name":"","label":"slider","tooltip":"","group":"67452c21.0b93e4","order":5,"width":0,"height":0,"passthru":true,"outs":"end","topic":"","min":0,"max":"4000","step":1,"x":610,"y":140,"wires":[["7b9509ca.516d48"]]},{"id":"311101bb.37d82e","type":"function","z":"e44864d7.49bd78","name":"Get back value Gauge-min","func":"var flag1 = flow.get(\"Gauge-min\");\nmsg.payload = flag1;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":400,"y":340,"wires":[["8a0ea8f1.064438","ab8cdeac.f540b"]]},{"id":"8a0ea8f1.064438","type":"debug","z":"e44864d7.49bd78","name":"min","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":630,"y":340,"wires":[]},{"id":"426b45f3.a6f6dc","type":"inject","z":"e44864d7.49bd78","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":170,"y":340,"wires":[["311101bb.37d82e","3a70ba4f.248e76"]]},{"id":"352c5347.f12cfc","type":"debug","z":"e44864d7.49bd78","name":"max","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":630,"y":380,"wires":[]},{"id":"3a70ba4f.248e76","type":"function","z":"e44864d7.49bd78","name":"Get back value Gauge-max","func":"var flag2 = flow.get(\"Gauge-max\");\nmsg.payload = flag2;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":400,"y":380,"wires":[["352c5347.f12cfc","9b6353df.af102"]]},{"id":"a8566559.df6168","type":"inject","z":"e44864d7.49bd78","name":"Set to 0","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":460,"y":140,"wires":[["df11a9eb.a3d278"]]},{"id":"67452c21.0b93e4","type":"ui_group","name":"Essais","tab":"159c03ce.b0101c","order":1,"disp":false,"width":"6","collapse":false},{"id":"159c03ce.b0101c","type":"ui_tab","name":"Essais","icon":"dashboard","order":3,"disabled":false,"hidden":false}]

Values are stored here (flow context):

2 Likes

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