Quantcast
Viewing all articles
Browse latest Browse all 200

Get the highest 15 minute average per month of a power graph

Grafana v10.3.3 (252761264e)
Influx 2.x.y

In Influx I have the power consumption and power generation (+ for using from grid / - for PV generation) for my home.
I want to generate a bar graph for a given year which

  • Gets all power data and averages this per 15m (0-15-30-45-0)
  • Out of all these averages in a month, I want the bar to show the highest average of that month.

I keep having problems with the syntax or getting to know the Flux language.

In pseudo code this would be something like

Timeframe == current year
Get all power
average per 15 min
per month, select maximum of that month

The challenge i have is in the last part/item of the pseudo code, in the old days that would be with “group by” I think. But also when I try tinker in Influx Studio the result right now looks like it is counting the instances rather than averaging them out.

from(bucket: "EnergyFlow")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "energy")
  |> filter(fn: (r) => r["_field"] == "Total_W")
  |> filter(fn: (r) => r["meter"] == "main")
  |> filter(fn: (r) => r._value >= 0)
  |> aggregateWindow(every: 15m, fn: mean, createEmpty: false)
  |> yield(name: "mean")

5 posts - 3 participants

Read full topic


Viewing all articles
Browse latest Browse all 200

Trending Articles