Best way to populate many ui-gauges-Classic

I have a sql server with 10 columns of weather related information (Temperature, BarrPress, Humidity, outside_temp, outside_humid,...etc) and
I want to use UI-gauge-classic. I'll windup with many gauges but at least it would take up less space.

  1. I can use multiple function nodes for each column such as:
   msg.payload = msg.payload[0].Temperature
   msg.topic = "temperature";
   return msg;

or
I can use change nodes to do the same thing.
Which one is cleaner and easier to maintain?
Thanks

A change node is generally preferable to a function node as it is more efficient and less likely to have bugs.

You could also consider a single function node with multiple outputs.

msg.payload = msg.payload[0].Temperature
msg.topic = "temperature"
const msg1 = {"payload": msg.payload[0].BarrPress, "topic": "Pressure"}
const msg2 = {"payload": msg.payload[0].Humidity, "topic": "Humidity"}
etc

return [msg, msg1, msg2, ...]

Thank you. jbuud's solution yields less total node. I'll try that one.

Building on @jbudd's solution you could do something like

const keys = ["Temperature", "BarrPress", "Humidity"]
let messages = keys.map((key) => {
    return {payload: msg.payload[0][key]}
})
return messages;

Do you need msg.topic? If you need it because you are using multiple needles then it becomes a little more complex.

const keys = [
    {payload: "Temperature", topic: "temperature"},
    {payload: "BarrPress", topic: "pressure"},
    {payload: "Humidity", topic: "humidity"}
]
let messages = keys.map((key) => {
    return {payload: msg.payload[0][key.payload], topic: key.topic}
})
return messages;

The advantage of using a structure like that is that you are separating the data from the logic. So if you want to add a new key, or change it, you just change the structure at the start, the code itself remains the same.

Guys,
I will try both. Experimentation is important to throughly understanding.
Whenever I read this site I keep saying "I didn't know I could do that.
Thank you.
Yes, multiple payloads with multiple topics.

I will also experiment with this idea. With multiple pointers, why not complex labels such as Temp:yellow,76 BarrPress:Green,1008

I don't understand what you mean by that.

text for the guage (from payload) to show multiple values for each pointer.
ui-gauge-classsic

Just wondering how to do this.

I think you are confused.

That picture with the coloured arc (green, blue, yellow) is not from the data.

It is set for the range.

I think you can cheat and have dynamic ranges, but that doesn't make sense with what I understand you are doing.
So I won't elaborate on that.

I assume you know that you can display whatever text you want in the text fields. The font size should be controllable by using CSS, but I don't know how to allow multiple lines in the field.

It is the text below the hub that @chuckf201 wants to configure.

You could certainly put the first line in the field above the hub (msg.measurement), and the second in the field below the hub (msg.formattedValue)

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