Rolling 30 day energy usage

Hi
I can currently get my energy usage from MQTT and show daily, weekly and monthly sensors for gas and electricity but they reset each new day/week/month. I’d like to be able to create a sensor that shows the last 30 days of usage. Does anyone have any ideas on how I could do this?

Thanks!

My current thinking is to have 31 entities, one for each day and just before the day resets update the relevant entity for the day. Then I can have one sensor that adds up all 31 entities. Does anyone else have any ideas?

Is this what you are looking for?

I have looked at that but it looks like that just adds up the sensor values and resets them back to zero at the end of each period

I see I didn’t understand you first post. Your looking to drop day 32, not a reset.

Unfortunately I don’t know of a solution.