Don’t get me wrong. I like what you guys build. It just baffled me when I noticed the deviation.
And pulling a 2 year graph for a single sensor with a logging rate of 10 seconds on a quad core is not that fast either. I can see the rpi sweating.
Maybe it is a good idea to “lock” the history in days and weeks for the total numbers. Just leave the live graph you have in the UI, because you want to see the trends, but for the history numbers underneath.
Make a day start from 00.00 to end at 24.00. Calculate total for that day and write that total to sd at 24.00.
This way, the display for a day also shows the graph for that particular day, and not half the night from the day before.
To display the total for a month, you only have to add up the 28 to 31 totals from the days to get the correct month value. If you save a single number for the month, you only have to add up the 12 months to show the exact value for that particular year.
To save space on the SD card, you could also add a button to only save totals for previous years starting from year “x” backwards and delete the individual loggings.
Just an idea to make this workable on an rpi