A Home Assistant community member recently posted a guide on setting up the Energy Dashboard so history survives a device swap. The post is short on its own, but the replies are useful because they lay out two competing ways to handle the same problem. We have not tried either method, so treat this as a summary of the discussion, not a tested recipe.
What happened
The author replaced a whole-house energy monitor and lost two years of energy history. They say they got it back through database manipulation, and they put the blame on their own understanding of how the dashboard ties to entities, not on Home Assistant. The guide is their attempt to spare other people the same repair.
Approach one: a ledger sensor in the middle
The guide’s idea is to feed the Energy Dashboard from a template sensor, which the author calls a ledger, instead of from the device’s own sensor. The ledger acts like a bucket. When hardware changes, you point the bucket at the new source and the dashboard never notices. The author compares it to the way a relational database keeps a stable layer between data and its source.
The author also describes limiting the recorder to what they care about, using an include with an entity glob that matches names ending in _energy_ledger. They say their database sits around 300 MB. They also add attributes to each ledger for daily, weekly, monthly, yearly and total cost, so a dashboard can draw from a single entity.
Approach two: just rename the entity
Other replies argue the built-in route is simpler. As they describe it, you delete the old entity and rename the new one’s entity ID to match the old one. The author’s own comments agree that matching an existing ID is how a new entity inherits the old statistics, though they note it is easy to get wrong if entity IDs are unfamiliar to you.
The critics’ objections to the ledger method:
- You still change an entity ID at swap time, just inside a template instead of on the device.
- You build and maintain a template sensor for every energy sensor.
- You must manage what the recorder keeps, or risk duplicate data bloating the database.
The author’s reply is that nobody has to use it, and that it protects you from losing data by accident.
What this means for your install
We would not call either side the winner. Here is the practical takeaway for anyone with an energy monitor feeding the dashboard:
- Decide before the swap, not after. The author’s loss happened because the replacement was done without a plan for the history.
- Back up first. A full Home Assistant backup before touching a monitor costs little, and recovery by database surgery is clearly painful.
- Write down the old entity IDs. Both approaches hinge on knowing exactly which ID the dashboard was using.
- Weigh effort against scale. With one or two energy sensors, renaming is probably less work. With many sensors, or if you expect to swap hardware often, a stable layer in the middle may be worth its upkeep. That is our judgement, not something the thread settles.
The author also suggests Home Assistant could offer this kind of stable layer inside the Energy Dashboard itself, so the helpers list stays uncluttered. That is a suggestion, not a announced feature.
One caution: the thread is community opinion, and the author says they ran the guide past an AI for checking and would welcome corrections. Read the original, test on a copy of your data, and do not assume every step transfers to your setup.
