Hello, I need to record the price of car fuel and archive it 10 years back. The standard sensor is deleted after about 10 days and gets a value every 360 seconds. So I created a sensor statistic, but it doesn’t behave correctly. Can someone help me?
The statistics sensor uses state data from the recorder database, that only goes back 10 days (by default).
So no, that max age wont work (also your sample size is too small, ten years @ update every 360s = 876,600 samples).
The easiest way to retain long term data is using Long Term Statistics. This is 5 minute max/min/avergage for 10 days, then after that it is down sampled to hourly max/min/average and kept forever.
To ensure LTS are kept for sensor.tank_ono_price_diesel it needs the following attribute:
state_class: measurement
If the integration supplying that sensor does not support state_class you should open an issue to get it added. Until then you can use customize to add the attribute.
You can’t (easily) use LTS in calculations in templates though. This method is only good for display in statistics graphs. What do you want to do with the 10 years of data?
Yes, I want to display it mainly in graphs…
But if it is set that there will be one value per day, which is enough for me, after all, in 10 years there will not be so many of those values. In the worst case, I will put it for 5 years or I will make another aggregation, for example, from monthly statistics. But the question is how to do it?
thanks, this works fine, but I’d like to see more beautiful charts and these are: “type: custom:apexcharts-card”
is it possible to screw it in somehow?