Display last and average values in gauge

I’m new to all the software I’m using: grafana, prometheus and home assistant in docker-compose on a linux system.

I updated all the docker images today to the most recent images

I’m trying to show last values and then averages of the last values in a gauge.

It fails to show anything if I try to sum different values, see the attached image.

If I use the same value twice it works - the “fake average”.

But if I use two different values nothing happens - the “broken average”.

There’s nothing output in the log files, and no errors on the web page.

The screen looks like this, notice that there are four queries but only three gauges:

Welcome @patman to the Grafana forum.

Does something like this work?

Thanks for having a look.

I don’t know how to get that screen / view in grafana - I see no “Mode”.

Is that because I’m using Prometheus as the data source? Or different version of grafana?

I’m on v9.1.6

I also don’t have the “bug” thing.

I was able to get it working by using this code (includes converting celsius to fahrenheit):

(avg(homeassistant_sensor_temperature_celsius{friendly_name=~"Sonoff TH A Temperature|Sonoff TH B Temperature"}) * 1.8) + 32

Screenshot:

I can see the Transform tab in your screenshot. What does it show if you click on it?

Ah ok, I get it now.

That sort of works, except I have 5 total sensors. On one panel, I want the averages of 2 from outside and 2 from inside, and none from the basement one - not an average of all values.

Then in another panel, I have the results of each sensor.

And then below that, I have graphs showing the values of temperature and relative humidity over time.

I see how I could use the transform and arrange things a bit differently, but the main values I want to see are the average outside and average inside temperatures of areas I actually use - I could really just use one sensor from outside and inside rather than averages, but they vary some (especially inside).

Right now, I have this dashboard (truncated at the bottom):

Maybe you already know this, but you can create as many transformations as you wish.

For each transformation, you can select ONLY those queries that you wish to average. For example, you could select only Outside Front and Outside Rear and check Replace All Fields to clean up the panel.

OK, and then I see I can add 2 transforms - so I could just have 5 queries, and get the averages of 2 pairs.

If I could arrange the 7 results in one panel properly, that would work nicely (put the averages on top, and others below), but I don’t see a way to do that.

I could also just show the averages in the one panel. But do you know how show multiple fields? I can’t control click and don’t see how to do that - the “Fields” for the gauge options is only letting me select one value, even though it uses the plural “fields”, as: “select the fields that should be included in the panel”.

This is just a quick n’ dirty mockup, but using 3 separate panels seems to be the way to do this:

As for showing the averages in just one panel, I would agree there is no way to arrange the 7 results.

1 Like