Average of the values of a single sensor

Hello everybody,
I would like to create a sensor that, having in input another sensor (which assumes different values), returns me the average of the history of those values. Now let me explain better :slight_smile:
I have a photovoltaic system, I would like to know the average daily PV production (based on the last week / month), so as to make estimates for the near future. I found the average helper, but it only allows the calculation between multiple sensors and not based on the history of a single sensor. Thereโ€™s a way?
A thousand thanks