2023.4: Custom template macros, and many more new entity dialogs!

According to 2023.4: Custom template macros, and many more new entity dialogs! - Home Assistant

  • Home Assistant now keeps history when renaming entities :metal:

Before:

  1. sensor.entity with statistics
  2. Renamed sensor.entity to sensor.entity_old
  3. Created a new sensor.entity using the same name
  4. The new sensor.entity will have the full history (states and statistics) of the old sensor.entity

Now: doing the same results in a complete new history (states and statistics).

How to rename entities to actually preserve the old states + statistics?

It seems to be not possible anymore for an entity to inherit the history of another entity just based on the entity_id. I really need to solve this, otherwise this would be an actual step backā€¦ the entity_id swap workaround worked just perfectly before 2023.4!

When reading this first I thought thatā€™s exactly what this new feature does - instead after trying with a few entities, I lost all the history dataā€¦ :cry:


Edit: I think the core issue is when the old entity has itā€™s own unique_id set. One simply can not transfer unique_idā€™s to another entity, right?

EDIT 2: Outsourced to

1 Like

Interesting developmentā€¦ Iā€™ll need to keep an eye on this.

Are you in control of the new entity, i.e. did you create it or was it created by an integration? If you did, have you tried setting the unique ID for it (if supported)? Otherwise, you could try creating a wrapper template entity for which you can set a unique ID. I know these are workarounds, but itā€™s something to try.

The new entity was created by an integration. In detail the supervisor integration. I tried applying the former unique_id using customize.yaml, which had absolutely no effect.

Going the template wrapper entity path (if working at all) is way to ugly as it creates redundant entities for nothing :frowning:

Running into the exact same problem, how can i just replace one defect powerswitch and keep/migrate the energy history to that new switch.

1 Like

Letā€™s continue to find a solution for this @