Gauge - Dynamic min and max

Sorry if this is a duplicate entry.

I have a connection to a plc. From a data block I get a min and a max value for a variable. I would now like to pass this to a gauge. Unfortunately, I have not found anything suitable. the values are in the following format:

Min : msg.payload : number
85

Here's the one :wink:

Hallo,

that's the second step. At the beginning I would like to summarize the min, max and data value from 3 different variables so that I can pass it as in the example to the gauge. what is necessary for this?

What have you tried?

I have 3 individual variables which I would like to summarize and then, as in the linked example, to pass the gauge.

That’s restating the question, not explaining what you have tried. It’s easier to suggest things for you to try if you show what you have done. For example it makes it easier to see where the three variables are.

1 Like

I would like, as it can be seen in the picture, to summarize 3 values from variables in order to transfer them to the gauge. However, I lack the knowledge of how I could do that. What you see on the picture does not work that way. I just put it together for viewing.

So add some debug nodes so you can see the data and add one after the join node as well.
Give them all the debug nodes names so you can see which one is which. Post a screenshot of the debug window here...

Are you trying to show all three values in the same gauge at the same time?

Here's my test setup.
image

This is what I put in the first function node...

var max = 50;
var min = 20;
var data = 30;
msg = {payload:data,ui_control:{min:min,max:max},topic:"Soil"};
return msg;

The second function node is the same but with different values for max, min and data.

Hope this works for you.

2 Likes

Yes, min max and value in the same gauge.

The reason for this is that I do not need a static min and max but a dynamic because the article, which I indicate, changes from time to time.

That's exactly what I need 75%.

Just the min and max are not static but have to be loaded from a variable.

so look at those debug nodes you should have added by now, and change the variables in the example to be the path to the specific data item

maybe my written english is so bad ...

i have been trying for several posts to ask which control i need to use to summarize the 3 values. I can not debug anything to show you. but it is e.g. for min = 10 then, for max = 30 and for value = 22 in it.

As we still don't know how your values look like and when they arrive, are they coming in at same time, do they come in all together all the time, and stuff like this, then it is kind of complicated to give you strong advise.

For me it seems to be simple case where you just manage incoming data from known source to be stored into flow context and then for gauge just read all variables from flow context.

var max = flow.get('gaugeMin') || 0;
var min = flow.get('gaugeMax') || 100;
var data = // some numeric data from source 
msg = {payload:data,ui_control:{min:min,max:max},topic:"Soil"};
return msg;
1 Like

But this doesn’t match what you showed in your screenshot earlier.
Where you have three separate inputs that you are joining using a Join node.
which is why seeing your flow and the data makes it so much easier to suggest a solution

So where do the min and max come from ... - are they ever reset ? or does the min just keep getting lower and the max higher (based on the incoming data).

Here is a simple example using three sliders and no context.

[{"id":"f03f3202.91e12","type":"ui_gauge","z":"adc578f5.614308","name":"","group":"cc1b923d.14259","order":1,"width":0,"height":0,"gtype":"gage","title":"gauge","label":"units","format":"{{value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","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":2,"width":0,"height":0,"passthru":true,"outs":"all","topic":"","min":0,"max":"100","step":1,"x":170,"y":1280,"wires":[["f03f3202.91e12"]]},{"id":"d9ae1c43.b5801","type":"ui_slider","z":"adc578f5.614308","name":"","label":"Min slider","tooltip":"","group":"cc1b923d.14259","order":2,"width":0,"height":0,"passthru":true,"outs":"all","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":2,"width":0,"height":0,"passthru":true,"outs":"all","topic":"max","min":"60","max":"100","step":1,"x":170,"y":1380,"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":1380,"wires":[["f03f3202.91e12"]]},{"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}]
4 Likes

Si hablás español y crees que te podés expresar mejor en este idioma hay gente en este foro que también lo habla.

For what i've understanded from your question the answer from @hotNipi is the most accurate, you'll receive the three values and you need to store them in context data, the join module will be a headache. When you have all the data you'll generate the joined message and then send it to the gauge node.

Well the solution I just posted avoids the join and context entirely so is the minimal implementation and reduces flicker on the gauge during repeated updates...

i just run your code, in my opinion that's the best solution, i've learned a thing today. Thanks!