Power consumption (kWh) from electric meter counter for daily/month view - InfluxDB 2.0 / Flux Query

I’am logging the ongoing meter readings in a influxdb 2.0.
for example:

I tried a lot of querys, but the results are not correct.

My problem is that, I found a lot of good stuff for the old influx DB query but not for the new influxdb 2.x flux query.
I think that’s common use case and somebody have already a working. Thanks a lot.


I am facing the exact same problem. I had a dashboard running with Influx 1.x and that was fine. For some reasons I had to switch to Influx 2 and I am not able to make something similar that is working. Should be so easy but it’s not. :frowning:

1 Like

after failing, I try past & copy :rofl:
I found a Dashboard wich use flux query an a power consumption view:

But I couldn’t adapt it to my environment.
maybe you will have more success with it…

unbelievable that nobody has a solution for this, and yet so many have an energy measurement layout.
I’ve been sitting on this problem for days, reading endless forums, and no solution in sight. only ridiculous instructions for professional programmers which cannot be implemented as home users.
simply let the value of the measurement start at zero every day or every month. that’s all i’m looking for.

I hear you. Monitoring energy consumption is one of the most common use cases, yet many solutions are either referencing old versions of software, or are half baked.

What query have you created so far? And are you using Flux or InfluxQL?

1 Like

I have same concern to build water pump station dashboard.
Say, Today, Yesterday, This Month Accumulate, This Year Accumulate,…
I had pulse count every 10 sec.
I use latest Influxdb 2.1.1 and Grafana 8.3.3.

Thank you.

I get the data from InfluxDB 2 visualized in Grafana.
However, not as desired. The day starts at 12:00 a.m. and not at 3:00 a.m. The timezone command doesn’t work. With InfluxDB 1, none of this is a problem.

Relative Time: 0d/d

import "timezone"
option location = timezone.location(name: "Europe/Berlin")

from(bucket: "stromzaehler")
  |> range(start: today())
  |> filter(fn: (r) => r["_measurement"] == "stromzaehler")
  |> aggregateWindow(every: 1h, fn: spread, createEmpty: false)
  |> drop(columns: ["measurement", "month", "week", "year"])