Node-red / grafana sum/average


following situation:
I have some solar panels and using some esp32 stuff, I got a value every 30 minutes which represents the average of the generated power during the last 30 minutes time period.
Hopefully you understand what I mean. :slight_smile:
So for example in a time range from 8-10 o'clock, I get 4 values, e.g.:
8:30: 150W
9:00: 230W
9:30: 170W
10:00: 50W

These are the values, which are permanently written into my InfluxDB and with which I have to deal with.
So that means, if I sum up these values (600W) and divide them through the time, I should get 300Wh.

My goal sounds pretty easy. I want to display just the value of all Wh which my solar panels have collected. So I have to do some calculation in a grafana query, I think. Or not?

The result do not have to show a specific time period (it could, but it do not need to). I am interested in the sum of every generated Wh during the whole year.

Can anyone help me or do I have to go to a grafana forum?


Just starting work so time is limited but ...

I think that you need to select the whole year as a fixed time selection (rather than Grafana's normal sliding time window) and then group by year. Using the sum and avg functions should then give you the answers.

Because this is rather different to a normal Grafana query, it might actually be easier to try things out in the InfluxDB command line. There are some examples on the InfluxDB docs site.

Do you want to do this in Grafana or in a direct query on the database?

If you want a direct query to give you the total Wh over a period then it will be something like
SELECT SUM("value")/2 FROM "the_measurement" WHERE ...
with a WHERE clause selecting the time range.
The divide by 2 is because, for example, the value 150W at 08:30 is 75Wh, the 230W at 09:00 is 115Wh and so on, so you just have to add them up over the total time range and divide by 2.

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