Group data hourly, daily, monthly etc. how?

Hi,
I want to have an overview how much electricity i use each therefore i want following :

  1. Be able to see hourly for 24h graph how much has been used
  2. Be able to dig into the hour and see by minnute.
  3. Be able to see daily totals by day, month, year.

I get my data from Home assistant and i run influxdb 2.0 but i don’t know exactly how to aggregate data and what is the best practice to do what i want.

I can’t add attachments but here is a snippet of the data that i have uploaded to WeTransfer https://we.tl/t-8eABOk8tNT in CSV format.

Following querry shows a upgoing curve of the data :

from(bucket: “Home Assistant”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: ® => r[“entity_id”] == “filtered_kamstrup_counter”)
|> filter(fn: ® => r["_field"] == “value”)
|> filter(fn: ® => r["_measurement"] == “kWh”)
|> aggregateWindow(every: 1s, fn: last, createEmpty: false)
|> yield(name: “last”)

Do note that i just have a counter of the total kWh used and that just increases so i need to calculate how much was used during the window somehow.

/donnib

Hi,
You can use difference() function to get the consumtion between two point, somthing like this:

from(bucket: "Home Assistant")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "kWh")
  |> filter(fn: (r) => r["entity_id"] == "filtered_kamstrup_counter")
  |> filter(fn: (r) => r["_field"] == "value")
  |> aggregateWindow(every: 10m, fn: last, createEmpty: false)
  |> difference()

Regards

1 Like