Average value from InfuxDB v2

Hi guys,

I have 2 outdoor temperature sources that I can save in InfuxDB v2. Now I’m trying to write Flux query in Grafana to display the average temperature graph. Both temperatures have the same “measurement”, “field” and “where” tag, and difference is only “source” tag.

from(bucket: "netatmo")
  |> range(start: v.timeRangeStart, stop:v.timeRangeStop)
  |> filter(fn: (r) =>
    r._measurement == "meteodata" and
    r._field == "temperature" and
    r.where == "outdoor" and
    r.source == "netatmo"

If I do not specify r.source, I have 2 lines in my graph. But I need only one line, calculated average from 2 values. How I can get it?

Maybe problem is that temperature values are NOT stored at the same timestamp because it is from 2 devices and this sendings data randomly, when temperature change. Sometimes the temperature is sent twice per minute, sometimes one per 3 minutes. I need an average value with 1-minute timeframe.

Thanks for your help.

Please move my question to InfuxDB category. Thanks