Sensor History - temperature

Not sure which update got rid of the temperature history data, but no matter what timeframe i set, only see 9 days back in the history of my temperature sensor.

Is there some secret setting now to get back all history data?
Couple of month ago i could see all history data (at least 6 month) of my temperature sensor.

Thanks for any hint.

Cheers

Screenshot

There are issues with 2023.3.2 and 3 … i returned to 3.1

1 Like

The default recorder purge keep days option is 10 days. Always has been. So unless you deliberately changed it you should only see 10 days of state history.

Perhaps you are thinking of a statistics graph card. That graphs long term statistics which is kept forever (but at a lower resolution).

Maybe a screen recording can bring in some light. I checked the history data a couple of times / month in the past. “Always”, the same way like you see in the screen capture. With the latest update applied, i can no longer see the history data, that was “always” showing up there and is now gone.

So, how can i bring back the history data (more than 10 days) for the temp. sensors?

Screen Capture:
Screen Recording 2023-03-12 at 06.07.37

You never had more than 10 days of history unless you changed the default recorder settings. Did you do that?

https://www.home-assistant.io/integrations/recorder/#purge_keep_days

Never heard of that. Thank you for the hint. Will try to figure it out.

I really only want to record / keep the temperature data as long as possible.

Added those lines to the configuration.yaml

# RECORDER FILTER
recorder:
  purge_keep_days: 365
  include:
    domains:
      - light
      - sensor
    entities:
      - sensor.sen_studio_temperature
      - sensor.sen_kitchen_temperature
      - sensor.sen_bath_temperature

You have just excluded keeping any history for all other entities.

Also for good performance you should not increase the history retention beyond 30 days or so.

1 Like

Just updated the code above.
Is there a way to get more than 30 days?

This may be an older topic, but I have the same behavior. It seems that when I just started with HA in May, there was nothing purged… After while, I noticed that it would keep only a month or so… And recently it has changed to only 10 days.

I’m not saying that the 10 days were changed… I think the purge is executed more frequently. What triggers a purge? Is it related to db size?

Also, I would like to keep the data for as long as I can. Should I move to MariaDB instead of SQLite?

It was always 10 days unless you changed it.

Purge happens nightly at 4am-ish.

Neither of those options are good for long term data. You need a time series database like influxDB.

I didn’t change it and there was definitely more historic data in HA than just 10 days… At some point there was about 3 months of temperature sensor data.

I was planning on using InfluxDB, but my previous solution (Domoticz) could easily retain temperature data for years… I was hoping HA did the same. It seems HA only keeps energy data though…

You may be confusing state data with long term statistics that are never purged.

I mean this… A temperatur sensor with historic data… And a dialog that looks like you can actually browse historic data… but all it contains is 10 days. This definetly showed about 3 months of data after I had used HA for about three months… So I’m not sure if it really purged every day at 4:12 all the time.

So, you mean that this history browser is actually designed only to browse 10 days of history? I wonder why there is even an option to select a date in the past if that’s the case…

The recorder database purges state and event history data after the purge_keep_days setting. This is 10 days by default.

Long Term Statistics data (not visible in the history panel) is kept forever.

Ok. Where could I find the long term statistics?

In the statistics card, the energy dashboard or the statistics table of the recorder database.

hello,
any hint on how to debug the sensors that are not appearing in the statistics card?
I saw this:
https://developers.home-assistant.io/docs/core/entity/sensor/#long-term-statistics

but i see a lot of sensors not appearing so probably i’m missing something… for example, should i create template sensors to have statistics of temperature coming from climate entities?
Thanks!

To record LTS your sensors need valid unit_of_measurement and state_class attributes.

thanks, this makes sense. Local tuya integration is not working, sadly.
Does this mean that - for example - i can’t have statistics of the pFactor? of a percentage sensor?
Thanks

Why not?

% is a valid unit. And you can add the a measurement state_class.

You can use customize to add any attributes you like: