Gauge - Dynamic min and max

The values are transferred from a controller every 500 ms and updated. The summarizing in my drawing with the JOIN should only show as an example what I intend to do.

So if a new value for Min or Max is passed from the controller, this should also affect the gauge. I can not open every time a value changes there Node Red and adjust the values so that the display is correct.

The dashboard runs permanently on a display and has only one indicating task. Interactions are not possible, it should only inform.

So the min and max may also change twice in second? This kind of gauge does not have any meaning then. It just have no readability.

Hopefully min and max do not change that rapidly - or at least you can use RBE node to remove non-changed values - otherwise the gauge will flash like a bad one. (and indeed as @hotNipi says will be almost meaningless to a user, who needs to be able to glance at it to derive information.

The values do not change 2 times per second. It is displayed for a long time Recipe 1 and then after a product change Recipe 2 for a long time.

I still do not know how to dynamically adjust the 2 values for min and max.

In your very first post you had a variable called min. Replace the slider in my example with that.. Same for max.

1 Like

Hallo dceejay,

that's exactly what I was looking for. Many, many thanks for your help and sorry if I have hired something stupid. is there also a possibility for sector to implement this? a copy of your function and change from min to seg1 did not work.

I think as seg1 is our variable you set it one layer higher (outside of options) Also I nite the dotted lines. Dashboard widgets are NOT supported in subflows.

Do I understand it correctly that it is not possible for seg1 and seg2?

msg = {ui_control:{seg1:msg.payload}};
return msg;

you can set both if you want to

msg = {ui_control:{seg1:msg.payload, seg2:msg.somethingelse}};
return msg;

it does not work. in the information of the gauge the value for seg1 and seg2 is always empty.

you need to set some defaults, but it is working fine.

[{"id":"f03f3202.91e12","type":"ui_gauge","z":"adc578f5.614308","name":"","group":"cc1b923d.14259","order":3,"width":0,"height":0,"gtype":"gage","title":"gauge","label":"units","format":"{{value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"20","seg2":"80","x":530,"y":1280,"wires":[]},{"id":"f541a866.024408","type":"function","z":"adc578f5.614308","name":"","func":"\nmsg = {ui_control:{min:msg.payload}};\nreturn msg;\n","outputs":1,"noerr":0,"x":350,"y":1340,"wires":[["f03f3202.91e12"]]},{"id":"4f5ad74c.0c4a18","type":"ui_slider","z":"adc578f5.614308","name":"","label":"data slider","tooltip":"","group":"cc1b923d.14259","order":4,"width":0,"height":0,"passthru":true,"outs":"all","topic":"","min":0,"max":"100","step":1,"x":170,"y":1280,"wires":[["f03f3202.91e12","89e6c9e5.a17318"]]},{"id":"d9ae1c43.b5801","type":"ui_slider","z":"adc578f5.614308","name":"","label":"Min slider","tooltip":"","group":"cc1b923d.14259","order":5,"width":0,"height":0,"passthru":true,"outs":"end","topic":"min","min":0,"max":"40","step":1,"x":160,"y":1340,"wires":[["f541a866.024408"]]},{"id":"6b9aabc0.ddb044","type":"ui_slider","z":"adc578f5.614308","name":"","label":"Max slider","tooltip":"","group":"cc1b923d.14259","order":6,"width":0,"height":0,"passthru":true,"outs":"end","topic":"max","min":"60","max":"100","step":1,"x":170,"y":1400,"wires":[["2a4eb1e2.a022ae"]]},{"id":"2a4eb1e2.a022ae","type":"function","z":"adc578f5.614308","name":"","func":"\nmsg = {ui_control:{max:msg.payload}};\nreturn msg;\n","outputs":1,"noerr":0,"x":350,"y":1400,"wires":[["f03f3202.91e12"]]},{"id":"5a6e3554.a86fcc","type":"function","z":"adc578f5.614308","name":"","func":"\nmsg = {ui_control:{seg1:msg.payload, seg2:(100-msg.payload)}};\nreturn msg;\n","outputs":1,"noerr":0,"x":350,"y":1460,"wires":[["f03f3202.91e12"]]},{"id":"ce01db4.aa12528","type":"ui_slider","z":"adc578f5.614308","name":"","label":"Seg slider","tooltip":"","group":"cc1b923d.14259","order":7,"width":0,"height":0,"passthru":true,"outs":"end","topic":"min","min":0,"max":"40","step":1,"x":180,"y":1460,"wires":[["5a6e3554.a86fcc"]]},{"id":"cc1b923d.14259","type":"ui_group","z":"","name":"Default","tab":"28f4e723.1c8a68","disp":true,"width":"6","collapse":false},{"id":"28f4e723.1c8a68","type":"ui_tab","z":"","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]
2 Likes

Thank you Mr. Dceejay I learned a useful lesson, I was looking for a Variable Range Gauge and I can readily adapt yours. Thank you.

I read the docs on github.
What is missing for me is a conditional approach:

if(msg.payload>ui_gauge.max) ui_gauge.max=msg.payload;

If would appreciate if anyone could let me know how this could be done.

You could save the last max value in context & compare to that....

var max = context.get("max") || 1; //get max value from memory context
if(msg.payload > max ) {
  max = msg.payload; //update max 
  context.set("max", max); //store max value
  node.send( {ui_control:{max: max}} ); //send update
}
return msg; 
2 Likes

Hi

Any idea how I could feed a gauge two diferent sets of values?
And only Display set_A IF Value <= X kWH and set_B if Value >= X MWh ?
And maybe.. possibly.. toggle between them? I have already found the Switch function but I'm frankly at a loss... Just started with NodeRed :smile:



I also played around with an idea to have two Gauges and make either of them to go appear/hide IF payload = .... but the GUI doesn't offer that kind of functionality as far as I can tell and I have a feeling that might be out of my league.
I tried to look around the flows.json file but couldn't see how I could make that last idea to work either.

Ideas, tips and or tricks are much appreciated.

First of all thank you very much for providing this help:

In which library's reference manual can I find all the properties of this gauge object? What about the other objects on the dasboard?

I only found this Seg1 and Seg2 here in this thread ... and that was after a lot of research.

There is a list of all the config fields in the docs here node-red-dashboard/config-fields.md at master · node-red/node-red-dashboard · GitHub

2 Likes

This is perfect Dave.

I was thinking about the dynamic range for ui_slider the other day :grin:

Now yes, all the properties of the dashboard object.

Note 10. Thank you very much.