Energy Dashboard History

Hi All,

I have my Energy Dashboard configured properly (as far as I can tell), however the sensor statistics are only available for a bit over a week or so. Looks like I cannot get a proper history view of my consumption, even though the sensors providing the inputs have been running for months (some almost a year at this point).

Is this something I will need to change at the sensor level, or is there a setting in the Energy Dashboard that would allow me to look back? Where should I look?

This is my current configuration:

  • electricity input is provided by a P1 Power meter (via Homewizard integration)
  • Solar is provided by the SolarEdge integration
  • Gas consumption is provided by a Zigbee door sensor I configured a few months back
  • device readings are coming from various Shelly devices and a Panasonic Comfort Cloud integration for the A/C

And this is what it gives me:

Did you on;y set up the energy dashboard “a week or so” ago?

It does not calculate energy usage before you set it up.

No, it’s been set up for a while. I think it comes down to storing the history of the sensors for a limited time - if I check the individual entities, I see the same there (ie. history is only available from last week of November)

No, state history has nothing to do with it. Long term statistics are kept forever, and that is what the energy dashboard uses.

It is strange, because it correlates exactly with the sensor history:

How is your recorder database set up?

I have not touched it up until yesterday when I started looking into DB management on this forum, so up until then I had the default set up that comes “out of the box” after installing Home Assistant OS.

Yesterday I looked into this thread How to keep your recorder database size under control - Community Guides - Home Assistant Community (home-assistant.io) and created the recorder line in my configuration.yaml file excluding some of the non-important entities/device classes.

This is what I have there for now:

recorder:
  exclude:
    domains:
      - device_tracker
      - media_player
    entities:
      - camera.doorbell_sub
      - camera.front_door_main
      - camera.front_door_sub
      - camera.garage_sub
      - sensor.home_assistant_v2_db_size
      - sensor.memory_free
      - sensor.memory_use_percent
      - sensor.processor_use
      - sensor.ble_mac_50765cb7d9ea4e2199a4fa879613a492

My current DB size is over 700MB, so I do reckon that a substantial amount of data resides there:
image

I have this same issue, but for my solar edge intergration. I had to remove it and readd it and I lost all the data. I wanted some backfill with it because it is all available.

Did you make sure that the sensors are named exactly the same after you re-added the integration? I was browsing the forum to find an answer to my problem, this came up in various other topics.

As far as my initial problem is concerned, I have tried to read up on this, but unfortunately the situation does not make sense. Entities added to the Energy dashboard should be treated as part of LTS. State_class is configured properly for all. (total_increasing)

It is as if something drastic occurred around the 25th of November and the system cannot access any data before that. Where can I see/validate what happened?

Just to conclude the topic, let me share the closure: after doing tons of reading and doing some very beginner-level poking in SQLite, it turned out that all the statistics were gone from the DB. Dong some additional read-up on this topic, I realized that the DB got corrupted and HA automatically created a fresh one during the bootup coming after the incident.

I did not get any flashing warning concerning the issue, but digging around in the logs showed me that this is what happened.

The solution? Frankly, I did not bother to restore the DB (there are apparently ways to do that if you are really determined and attached to your old DB, but I ended up migrating to MariaDB.