Meanwhile, @thomasdelaet did do a pull request for extending the utility_meter integration with a quarter-hourly option : Add quarter-hour period feature for utility_meter component by thomasdelaet · Pull Request #41999 · home-assistant/core · GitHub
In the utility_meter component, add support for 15 minute intervals (quarter-hours).
one (and my use case for this is that in Belgium, a significant part of your electricity bill is going to be based on your peak usage per 15 minute interval. Measuring and managing this peak usage can help to reduce cost.
Documentation at home-assistant/home-assistant.io#15290
I hope to see his pull request accepted and done for the version 0.117.0 of HA.
I switched also to the influxdb v2 integration to store de raw data, because my HA database is limited to store only 5 days of data, otherwise it is explosing in size.
On the influxdb side I added two graphs on the dashboard, one based on the value calculated by the utility_meter integration based quarterhourly and on based on the raw value of my realtime smappee sensor giving the power consumption of the grid in W each second.
Calculated value utility_meter quarterhourly
maxAverageQuarterHourData = from(bucket: "homeassistant")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["friendly_name"] == "Gemiddeld piekvermogen per kwartier")
|> filter(fn: (r) => r["_field"] == "value")
|> filter(fn: (r) => r["_measurement"] == "kW")
|> aggregateWindow(every: 15m, fn: max, createEmpty: false)
|> yield(name: "maxAverageQuarterHour")
maxMonthData = maxAverageQuarterHourData
|> aggregateWindow(every: 1mo, fn: max, createEmpty: false)
|> yield(name: "maxMonth")
maxMonthData
|> aggregateWindow(every: 1y, fn: mean, createEmpty: false)
|> yield(name: "averageYear")
Raw value of smappee sensor grid consumption
averageQuarterHourData = from(bucket: "homeassistant")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["friendly_name"] == "Net afname")
|> filter(fn: (r) => r["_field"] == "value")
|> filter(fn: (r) => r["_measurement"] == "W")
|> aggregateWindow(every: 15m, fn: mean, createEmpty: false)
|> yield(name: "averageQuarterHour")
maxMonthData = averageQuarterHourData
|> aggregateWindow(every: 1mo, fn: max, createEmpty: false)
|> yield(name: "maxMonth")
maxMonthData
|> aggregateWindow(every: 1y, fn: mean, createEmpty: false)
|> yield(name: "averageYear")
Of course to get and see the 12 month values, we must have the data of 12 months…
You can experiment by setting for example 1 day instead of 1 month and 12 days instead of 1 year.
At that moment you can already test the graph layout.
Why two graphs?
You see that the two graphs are grosso modo identical, meaning that the assumption to use the calculated utility_meter quarterhourly is correct (see my previous post)
Hereunder an example of my output. The line you see between the two blocks is when the influxdb v2 integration did have a bug when going from HA 0.0115.6 to 0.116.0.
During several days no data was inserted into the influxdb till I discovered the problem and corrected it by adding the optional precision option. It was optional for influxdb v1.x, but required for influxdb v2.
A bug correction was done in HA for the next version 0.117.0? to make it also optional for influxdb v2.