Automation Entity ID vs Alias — The Hidden Trap and Workaround

The Problem:
When you create an automation in HA the entity_id is locked to whatever name it had at creation. Renaming the alias later updates the friendly name but the entity_id never changes. This trips everyone up sooner or later when you start using entity_ids in templates and automations.
Example:
I make an automation, later find the name doesnt match its role very well so I rename it in the UI — then the problem arrives…

Alias: xyz name of my newly saved automation
entity_id: automation.xyz_name_of_my_newly_saved_automation

I rename the alias in UI to something better — entity_id stays exactly the same forever. Any templates or automations referencing it are now wrong or misleading.
The Workaround:
Instead of matching on entity_id use friendly_name in templates:

{{ states.automation
| selectattr(‘attributes.friendly_name’, ‘match’, ‘xyz.*’)
| map(attribute=‘entity_id’) | list }}

Clean Rename Process:

Open automation → Edit YAML → Copy
Delete automation
New automation → Edit YAML → Paste
Fix the alias name → Save
Fresh entity_id that actually matches

Feature Request:
Make entity_id automatically follow the alias when renamed — just like every other entity in HA. Or at minimum add a rename entity_id button. Automations shouldn’t be the exception.

No it isn’t. You can edit it at any time. Click on the entity (in your dashboard or dev tools / states) click on the cog icon in the card that pops up, edit the entity id.

1 Like

your missing the point Tom, unnecessarily complicated way to fix something that used to work and got removed,

Not sure what was removed. This has always been the way to change an entity id, for any entity type, automation, sensor, switch, etc…

1 Like

I don’t think this is true, is it? If you change any entity name, the id remains the same, surely? By design, I imagine. Automations are about the only entities where you can change the id with impunity, because they’re rarely referenced by entity id.

Choose a proper naming from the start and problem solved.

1 Like

If you create an automation via the UI (or in yaml with a unique id assigned) then the only thing that is immutable is the unique id.

both the friendly name and entity id are easily user configurable.

or if you want to rename everything including the unique id then just delete the existing automation and recreate it with a new alias that will then get a new unique id and a new entity id.

But I think that you may be incorrect in your logic (unless I’m missing something)…

any time the automation would be referenced anywhere it would be by the entity_id.

so if you just change the friendly name then all the places that the automation is referenced would still be using the (presumably unchanged) entity_id.

the only time things get confused is if you change the entity_id. then all of those references would be wrong and would then need to be updated where ever it’s used.

1 Like

I think this is where the confusion comes in. The entity ID is merely derived from the alias the first time the automation is created. The two aren’t synonymous. An automation has no explicit way of specifying the entity ID upon creation or otherwise, but as mentioned, you can edit any entity ID of any entity. Perhaps the recent default_entity_id should be added to automations too, like template entities have now.

And don’t forget about the entry_id.
That stays the same.