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

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