macxq / foxess-ha

Home Assistant & FoxESS integration. Monitor you photovoltaic installation directly from HA ☀️ ⚡️
120 stars 37 forks source link

History data lost after 10 days #274

Open msutryk opened 3 weeks ago

msutryk commented 3 weeks ago

Hi all,

I have a problem with the data from the integration not being stored long-term. It seems like it's being removed after 10 days. It's like this for all entities.

I've been using this integration for months now.

All other HA integrations seem to store the data from the day they were installed.

Home Assistant Core 2024.10.2 Supervisor 2024.10.2 Operating System 13.1

foxess-ha version: v0.4

FozzieUK commented 3 weeks ago

It's not the integration at fault here - by default Home Assistant doesn't store sensor data any longer than 10 days, you can increase it if you want by adding this to your configuration.yaml at the top.

recorder:
  purge_keep_days: 182

That would keep sensor data for 182 days (6 months) but your database would obviously get bigger as a result.

If you add the load (sensor.foxess_load) and grid consumption (sensor.foxess_grid_consumption) and battery charge / discharge totals (sensor.foxess_bat_charge and sensor.foxess_bat_discharge) to your energy dashboard it will retain those statistics in your energy dashboard indefinitely.

msutryk commented 3 weeks ago

Hi @FozzieUK, thank you for taking the time to answer my problem. OK, it might be the case, what made me doubt it is that the other entities, like my Midea AC, Panasonic Heatpump, or simple zigbee temp sensors, are keeping the data for months but when I check my Battery SoC it's only 10 days.

You are right - when I look at the data in my energy dashboard I can look back for months.

I'll look into recorder.

Thank you!

FozzieUK commented 3 weeks ago

No problem, it is possible for sensors to be loaded as long term statistics, but with this integration as it creates so many sensors it can get a bit heavy on storage.

When you increase the recorder setting, do it carefully and keep an eye on your database size as it can become unmanageable if you have other applications that have rapidly changing sensors - this integration doesn't the sensors only update every 5 minutes at best.

If there are certain sensors that you really want to keep 'long term' you can create a template sensor using them as the source and then set it with a state_class ('measurement', 'total' or 'total_increasing') this tells HA to record them as statistics . That way you don't increase the overall size of your database and get to keep data much longer for the sensors you really want to watch.