Calculate yearly/monthly/daily consumption of powermeter with block

Hi There!

Is there any chance to calculate the daily/monthly/yearly consumtion with blocky?
The only way i found was setting a fixed offset for exampel now-30d. But this is not really correct.

I need from 01.06.22 till now or from 01.01.22 till now for the yearly calculation.

Any best practises?



There is a DateTime library in the marketplace which has a “ZDT with” block that lets you set an absolute date. Date and Time

Work is going on to merge this with core but I don’t think that has been merged yet.

Once you have a ZDT, you should be able to get things like the current month, so you can derive last month, get the first and last days of last month, etc. Then you can retrieve “meter readings” and do simple difference.

It does all rely on persisting a usable “meter reading” to begin with.

@rlkoshak @rossko57

Thanks for your answers!

Tested a sample query to calculate my yearly engergy consumption for the last 5 years. My influx DB is running on a rpi4 and this query seems to be very stressy for the database. → Very slow, CPU 100%.

Now i am thinkin about an influxDB datawarehouse. So calculate the values just one time with a script or something else and write them to shadow items.

Is this the better approach? If yes, any hints in which scripting language or tool i have to look at?

Any value older than the current year is not going to change so it makes a lot of sense to calculate it just the once and then reuse the result from that point forward. You probably have hundreds of thousands of data points in a five year old InfluxDB database, assuming you have not set up some sort of compression retention policy (e.g. do like rrd4j does and throw out a block of entries and replace them with their average). So it’s not surprising that it would bring an RPi to its knees.