Average sensor reset at midnight

Hello,

I would like to create sensor that calculate the average for example the temperature of a room on the day (in resetting at midnight with the last temperature measured by the sensor) while keeping the history of the daily averages.

I already try with the platform statistics sensor with max_age: 24:00:00, but this is not quite what I want since it keeps the measurements over the last 24 hours while I want it to be reset at midnight with the last value read by the temperature sensor.

How can create this average sensor with long-term history to get the daily average of this sensor ?

Did you ever get this to work? I would like to do the same thing so I can feed that average to my Netro lawn watering system (throughout the day)