Long-term, statistics sensor to summarize all recorded data

Hi,

I have a sensor which has longterm statistics configured and so far, there’s about months worth of data captured by it. I would like to configure a sensor that would capture a satistical characteristic (namely min/max but I’m potentially looking for a solution that would also capture the average and median) of the entire sequence. What I have tried so far:

  • input_number with an automation to update it

    works great for min/max but it is a bit of a clunky solution and I don’t think you can do median with it (average is possible by having another input_number that captures the number of datapoints in the longterm statistic)

  • trigger-based template sensor with self refrencing

    would be a winner but reloading the yaml causes the sensor to go to unknown state even tho, there was a value in it before. I’m not ruling out a configuration mistake from my end

  • statistics platform

    Sounds lilke exactly like I want but it requires setting a max_age or sampling_size which means that it is not going to be of all data forever, unless you keep updating the max_age parameter (I tried setting it to max_age: {years: 10} but years is not a valid key for max_age)

  • statistics card

    Only includes data over at most the past year and if you don’t have a full year of data, it simply returns “?”. Plus I would prefer to have it displayed as an entities row

Note: I don’t need to capture data in the recorder, I only need a way to display it in a concise way (preferably as an entities row).

Any suggestions?