Ive a dashboard that is pulling data in via OPC UA. Mainly numbers from vibration readings.
I have a gauge that displays the current vibration reading. Every vibration reading has an alarm level, which is represented in the gauge by each segment. Can the value of each segment be changed from a number stored in a global variable?
ive read that this is possible, but i am not sure how its achieved.
As an example, here's the JS in the function node labelled 'Dynamically alter Current'
var current = msg.payload.ENERGY.Current;
flow.set("current",current);
current = current.toFixed(2);
var max = 3;
var min = 0;
if (current > 20) {
max = 40;
min = 20;
}
else if (current > 15) {
max = 20;
min = 15;
}
else if (current > 10) {
max = 15;
min = 10;
}
else if (current > 5) {
max = 10;
min = 5;
}
else if (current > 1) {
max = 5;
min = 1;
}
else if (current > 0) {
max = 1;
min = 0;
}
else {
max=500;
min=0;
}
msg = {payload:current,ui_control:{min:min,max:max},topic:"Current"};
return msg;
The gauge is supposed to be a visual representation of the data, but if the following data point falls into a higher criteria band, visually the gauge could fall, instead of increasing (because the scale would have changed).
I started-off with the 'wattage' scale that goes from zero to 20,000 watts. As it was difficult to 'see' the low-value readings, I made it dynamic. Then thought... "I'll apply that to current readings also"
Please see my flow below, the change in alarm has been detected and is shown as a global variable on the right, so I am pleased that bit seems to be working.
The flow is probably a mess compared to others but I can sort that at a later date.