Calculate average daily energy cost

Hi Guys

I have the energy integration running quite well but I am missing a display of the average daily energy cost over the last 30 days or so.

I have the entity that tracks daily cost but if I run a average calculation on this, it takes into account all the tiny increments over the day. One idea was to take this entity and everyday at 1s before midnight, write the current value into a number entity but the automations GUI won’t let me take another entity as value to write into the number entity.

I guess I am going a completely wrong approach and there is a very simple solution I have not thought of to accomplish this?
Any help is appreciated thanks.