# UI\_GAUGE node, dynamic range?

**URL:** <https://discourse.nodered.org/t/ui-gauge-node-dynamic-range/36756>\
**Category:** Dashboard\
**Created:** [30 November 2020 12:31 UTC](https://discourse.nodered.org/t/ui-gauge-node-dynamic-range/36756 "2020-11-30T12:31:49Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jean-Luc](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jean-luc/32/89996_2.png) [@Jean-Luc](https://discourse.nodered.org/u/Jean-Luc)\
**Post date:** [30 November 2020 12:31 UTC](https://discourse.nodered.org/t/ui-gauge-node-dynamic-range/36756/1 "2020-11-30T12:31:49Z")

</div>

Hello,  
concerning the **UI\_GAUGE** node ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/7/d7ad02b586fab0a530f482f4b8692510f0c4cc3f.png) , 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.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/9/e9e1f9f2922db337b77319a47246fe8f3fd2ba18.png)

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [30 November 2020 12:38 UTC](https://discourse.nodered.org/t/ui-gauge-node-dynamic-range/36756/2 "2020-11-30T12:38:18Z")

</div>

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](https://github.com/node-red/node-red-dashboard/blob/master/config-fields.md#ui-widget-configuration-via-msgui_control)

---

<div class="post-metadata">

**Author:** ![Jean-Luc](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jean-luc/32/89996_2.png) [@Jean-Luc](https://discourse.nodered.org/u/Jean-Luc)\
**Post date:** [30 November 2020 12:51 UTC](https://discourse.nodered.org/t/ui-gauge-node-dynamic-range/36756/3 "2020-11-30T12:51:27Z")

</div>

Too strong ✌ 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 🧐

---

<div class="post-metadata">

**Author:** ![Jean-Luc](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jean-luc/32/89996_2.png) [@Jean-Luc](https://discourse.nodered.org/u/Jean-Luc)\
**Post date:** [1 December 2020 09:16 UTC](https://discourse.nodered.org/t/ui-gauge-node-dynamic-range/36756/4 "2020-12-01T09:16:59Z")

</div>

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.

```auto
[{"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}]

```

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [1 December 2020 09:24 UTC](https://discourse.nodered.org/t/ui-gauge-node-dynamic-range/36756/5 "2020-12-01T09:24:08Z")

</div>

You can store them in persistent context - eg read up here - [A guide to understanding 'Persistent Context'](https://discourse.nodered.org/t/a-guide-to-understanding-persistent-context/4115) and the docs [https://nodered.org/docs/user-guide/context](https://nodered.org/docs/user-guide/context)

---

<div class="post-metadata">

**Author:** ![Jean-Luc](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jean-luc/32/89996_2.png) [@Jean-Luc](https://discourse.nodered.org/u/Jean-Luc)\
**Post date:** [1 December 2020 09:29 UTC](https://discourse.nodered.org/t/ui-gauge-node-dynamic-range/36756/6 "2020-12-01T09:29:54Z")

</div>

> 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!

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [1 December 2020 09:49 UTC](https://discourse.nodered.org/t/ui-gauge-node-dynamic-range/36756/7 "2020-12-01T09:49:13Z")

</div>

You can explore this example also.

> **[Dashboard tips - Gauge with selective input (flow) - Node-RED](https://flows.nodered.org/flow/cd90709d95fcba9970bd88205871c3c7)**

---

<div class="post-metadata">

**Author:** ![Jean-Luc](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jean-luc/32/89996_2.png) [@Jean-Luc](https://discourse.nodered.org/u/Jean-Luc)\
**Post date:** [1 December 2020 12:59 UTC](https://discourse.nodered.org/t/ui-gauge-node-dynamic-range/36756/8 "2020-12-01T12:59:02Z")

</div>

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:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/8/08d123cf428143b1b067b8e7ed35c8a40ad6c8fe.png)

---

<div class="post-metadata">

**Author:** ![Jean-Luc](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jean-luc/32/89996_2.png) [@Jean-Luc](https://discourse.nodered.org/u/Jean-Luc)\
**Post date:** [1 December 2020 17:35 UTC](https://discourse.nodered.org/t/ui-gauge-node-dynamic-range/36756/9 "2020-12-01T17:35:56Z")

</div>

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.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/c/ec2ad8531b4f9a3b2a3e7a26d7e8ce8c1dbf1fb8.png)

```auto
[{"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):

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/4/44dfcb3c957c2774c02bb862840e1c9756d8f83a.png)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [15 December 2020 17:36 UTC](https://discourse.nodered.org/t/ui-gauge-node-dynamic-range/36756/10 "2020-12-15T17:36:20Z")

</div>

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