Table of Contents

Heizungsmonitor

Ideensammlung

Q: grafana: i get 1min binary values in influx and want to have summary minutes per day
With Flux (sum of 1‑minute boolean samples per day), use a daily aggregate window and (optionally) convert minutes to hours.

Flux query: minutes per day

from(bucket: "your_bucket")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) =>
  r._measurement == "sensor" and
  r._field == "value"        // 0/1 samples each minute
)
|> aggregateWindow(
  every: 1d,
  fn: sum,
  createEmpty: true
)
|> yield(name: "minutes_on")

Each output point is the total minutes the signal was ON that day, assuming one sample per minute with values 0 or 1.

In Grafana, select Flux as the query language, paste this query, and use a time range aligned to days (now()-30d/d to now()/d) so each bar shows one day.

Flux query: hours per day

from(bucket: "your_bucket")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) =>
  r._measurement == "sensor" and
  r._field == "value"
)
|> aggregateWindow(
  every: 1d,
  fn: sum,
  createEmpty: true
)
|> map(fn: (r) => ({ r with _value: float(v: r._value) / 60.0 }))
|> yield(name: "hours_on")

The map step converts summed minutes to hours by dividing by 60.

You can rename value to a friendlier field (for example dailyhours) with another map or rename step if desired.

If your 1‑minute values are not exactly 0/1 but represent a duty (for example 0 or 60), adjust the division factor in the map accordingly.