Obtaining the average power consumed in the hour of greatest consumption

Hello. I get the power consumed in my house from a sensor. Every 10 seconds I feed this data into influxdb2. I need to obtain the average of the power consumed in the hour of greatest consumption of my home, measured in watts. Some help?

Let’s assume you want the mean of the greatest (maximum value for the hour) over the last 24 hours.

Maybe this?

Can you try a query like the above, but with your data?

I understand that first it would be necessary to locate the time in which the highest power consumption occurs (highest power peak). In that hour, it would be necessary to do the average of the power consumed.

Perhaps this

Blockquote
z = from(bucket: “DSMR”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] == “DSMR”)
|> filter(fn: (r) => r[“_field”] == “P_total”)
|> filter(fn: (r) => r[“tag”] == “DSMR”)
|> aggregateWindow(every: 1h, fn: mean, createEmpty: false)
|> pivot(rowKey:[“_time”], columnKey: [“_field”], valueColumn: “_value”)
|> rename(columns: {P_total: “mean”})
//debug result z
//|> yield(name: “mean”)

y = from(bucket: “DSMR”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] == “DSMR”)
|> filter(fn: (r) => r[“_field”] == “P_total”)
|> filter(fn: (r) => r[“tag”] == “DSMR”)
|> aggregateWindow(every: 1h, fn: max, createEmpty: false)
|> pivot(rowKey:[“_time”], columnKey: [“_field”], valueColumn: “_value”)
|> rename(columns: {P_total: “max”})
//debug result y
//|> yield(name: “max”)

//join the tables
result = join(tables: {t1: z, t2: y}, on: [“_time”])
//filter out the tables we need
|> keep(columns: [“_time”, “max”,“mean”])
//debug the tables
|> highestMax(n:1,column:“max”, groupColumns: [“max”,“mean”,“_time”])

|> yield(name: “max_mean”)

Blockquote

Firstly, it would be necessary to locate the time slot (one hour long) in which the highest consumption peak occurs (the highest value of power consumed). In that time slot, the average energy consumed would have to be calculated.

Firstly, it would be necessary to locate the time slot (one hour long) in which the highest consumption peak occurs (the highest value of power consumed). In that time slot, the average energy consumed would have to be calculated.

why?

The first query gets the mean of the power

The second query gets the max of power

After joining the query are sync on time on a hourly base.

Subsequently the combined tables are sorted on the highest max. including the mean

1 Like

Now I understand. I was not aware of the highestMax() function. Thank you.

1 Like