How to graph the delta (difference) between indoor and outdoor temperature

  • What Grafana version and what operating system are you using?
    v9.3.6

  • What are you trying to achieve?
    To display the delta between indoor and outdoor temperature

  • How are you trying to achieve it?
    BY filtering on indoor and outdoor temperature and using Transform

  • What happened?
    Don’t know how to do it.

  • What did you expect to happen?

  • Can you copy/paste the configuration(s) that you are having problems with?

from(bucket: “my_bucket”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“entity_id”] == “outside_temperature” or r[“entity_id”] == “indoor_temperature”)
|> filter(fn: (r) => r[“_field”] == “value”)
|> aggregateWindow(every: v.windowPeriod, fn: last, createEmpty: false)
|> yield(name: “last”)

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
    No errors

  • Did you follow any online instructions? If so, what is the URL?
    I was not able to find instructions.

When you send the data to InfluxDB, is the timestamp the same for the indoor temp and outdoor temp?

Yes, the timestamp is the same.

@snowmangh

Maybe something like this?

from(bucket: "my_bucket")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["entity_id"] == "outside_temperature" or r["entity_id"] == "indoor_temperature")
  |> filter(fn: (r) => r["_field"] == "value")
  |> aggregateWindow(every: v.windowPeriod, fn: last, createEmpty: false)
  |> pivot(rowKey:["_time"], columnKey: ["entity_id"], valueColumn: "_value")
  |> map(fn: (r) => ({ r with delta: (r.setpoint - r.actual)}))
  |> yield(name: "delta")

I cannot check the above syntax, but it should be close to correct.

Thanks for the suggestion. After a re-verification, the timestamp is not quite the same. My bad.

I ended up using the experimental.fill function to draw the delta. Works great, but experimental.

import "experimental"
from(bucket: "my_bucket")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r[“outside_temperature” or r[“entity_id”] == “indoor_temperature”)
  |> filter(fn: (r) => r["_field"] == "value")
  |> aggregateWindow(every: v.windowPeriod, fn: last, createEmpty: false)
  |> experimental.fill (usePrevious:true)