Entity id already exists - ignoring: automation.my_camera_motion. Platform automation does not generate unique IDs

I am getting these errors about automation IDs (not sensors or anything else, only automations). I do not indeed have same IDs for different automations, yet this error appears randomly. Is this a bug or there is some invisible automation stuck somewhere? My understanding that these IDs are generated from what is in the “name” field of automation, I keep these unique but may be HA uses only first N characters?

The ID is randomly generated when using the Automation editor (UI)
You might want to take a look at automations.yaml and see if there are any duplicates

1 Like

grep id .homeassistant/automations.yaml | sort | uniq -c | sort | egrep "[0-9]+ - id" says no “id” duplicates. Should I assign IDs manually? There seems to be a way to rename an entity in the UI but HA seems to ignore changes.

If you use yaml to create your automations, id isn’t required. Then the id is based on your automation alias or friendly name. So, based on the tittle of your post, you have more than 1 automation named My Camera Motion.

This is not the case here, all names in the automations page are unique. In the UI, it is “Motion Camera 2” actually, although its entity id is “automation.my_camera_motion” (renamed at some point). All automations are created in the UI btw.

Well, you’ve identified the problem. So update the entity_id.

1 Like

No I have not, what is the problem exactly? “Motion Camera 2” and “automation.my_camera_motion” are unique to other definitions.

And when I update the entity id to lets say “automation.motion_camera_2”, that entity settings window starts saying:
“This entity does not have a unique ID, therefore its settings cannot be managed from the UI”

The “automation.my_camera_motion” is now marked “read-only” in the entities list and there is no “automation.motion_camera_2” entity anywhere.

Ah, also noticed that when HA is busy, it is slow and occasionally can duplicate automations, i.e. in the list there are two exactly same automations. I stop the service, remove one from automations.yaml, start HA service - and the deleted automation is still in the list but this time it is read-only. Where does HA store automations in addition to automations.yaml?

Hey man, did you manage to sort it out? I’m experiencing the same thing and it’s the notification popup is driving me nuts.

Look friend, I had such a problem and I solved it, so …
It is necessary to change not only the name in the section
alias:
as well as in the section

  • id:
    if you have such a section

What?

If anyone stumbles upon this the proper way to fix it depends on how you integrated it:

Integrated through the UI

Nothing you can do. The developer needs to update the integration to give unique_ids. I doubt any UI integration has this issue because integrations don’t make it through the vetting process without having a unique_id.

Integrated through yaml

Check the documentation for the integration. Inside the configuration variables there should be a mention of unique_id.

If the integration has unique_id as an option for yaml:

Add unique_id to every entity that you have. Make sure it is unique to that integration. Now you can properly change any entity_id in the UI.

If the integration makes no mention of unique_id:

Unfortunately, you need to wait until the integration adds this functionality. Make a feature request or write up an issue.

The only way to change the entity_id without a unique_id in the integration is to update the name field. This is the ‘old’ way of doing things and is slowly being phased out. There are many old integrations that have this issue. They won’t be updated until someone says “Hey I can’t do this”. The best way to do that is to make a feature request or write up an issue on github.


EDIT: Well I just realized that this thread was about automations. If you create automations through the UI you should have no problem. If you create them through yaml but want to change the entity_id, then add id to your yaml and give it a random name that is unique to all other id’s in automations.

I ran into this, also been creating automation’s through the UI, not sure how it happened though.
Quick fix for me, was I simply duplicated the problematic automation, which I believe generates a new unique_id for the newly duplicated automation, then I deleted the original.

1 Like

I had the same problem. I’m new to Home Assistant and only create automations via the UI. Creating a new duplicate automation and deleting the old one seems to have fixed the problem.

2 Likes

open your automations.yaml search for the ID with the error. above the ID there will be a weird ID like this

  • *id001

delete top and in bottom of the automation there is another one, delete both. and restar HA.

This worked for me

3 Likes

I suddenly had this issue with two automations which were created in the UI months ago.

Looking in automations.yaml i could see they were actually duplicated (but not showing duplicates in the UI). I just deleted the duplicated lines and reloaded the automations which fixed the issue.

That just fixed the issue for me as well, duplicated entries right at the bottom of the file. What I don’t understanbd is, why is it added twice automatically to that file by HA? I think it is #2 below:

  1. If different threads try to update the file at nearly the same time, somewhere in their logic they have a flaw where they have arrived at the conclusion that the entry is missing from that file when it may have just been added (the view one of them has a stale view of the file) - unlikely

  2. The person who was updating the automation had two browsers open at the same time and made changes to one that saved the file - at that point the view of the file in the second browser instance as stale - then changes in the other second instance save the file again - but also triggered somehow adding the missing entry because the UI thought the entry was missing from the stale version of the file it saw -

No. Its really simple: Yaml is your configuration. When you reload, it reads the configuration. The system only knows what currently exists. Reloading will simply attempt to add the entity, if the id exists, it creates a new one. Each integration handles reloading yaml differently, typically it should not add duplicates. Core integrations like automations and templates won’t create a duplicate when you reload, but old yaml only integrations may.

If you add a unique_id to an automation when it previously didn’t have a unique_id, you’re essentially creating a new automation. The old one exists still (from yaml) and the new one has a unique_id, so the unique_id automation will get an _2.

So, if you don’t want duplicating things, always use a unique_id. If you don’t want duplicates when reloading and you don’t have unique_id’s, restart, don’t reload. Restarting is the only way to ensure you don’t get duplicates, or using unique_ids.

1 Like

Mine was an id section at the bottom of the automations.yaml file that was there twice. It was a script. What would cause that?

Well, what you’re saying is not possible. Scripts do not go in automations.yaml. They don’t even have the same yaml configuration. So you must be mistaken. When I say mistaken, I mean about what you think went into automations.yaml. Not that it duplicated the ID through some possible bug.

I am sorry it was an automation that calls the script. When I ran the script on it’s own it would work with no issue, it was an automation that was duplicated. This is what was at the bottom of the automations.yaml file:

- id: '1697593906718'
  alias: Reload Yolink Automation when button is pressed
  description: ''
  trigger:
  - platform: state
    entity_id:
    - input_button.reload_yolink_integration
    to:
  condition: []
  action:
  - service: script.reload_yolink_integration
    data: {}
  mode: single
- id: '1697593906718'
  alias: Reload Yolink Automation when button is pressed
  description: ''
  trigger:
  - platform: state
    entity_id:
    - input_button.reload_yolink_integration
    to:
  condition: []
  action:
  - service: script.reload_yolink_integration
    data: {}
  mode: single

So, how do you think that was caused?

If you’re just using the UI, it could be a bug. If you’re using the UI and looking at things via a text editor at the same time, then it’s most likely related to you saving the file while the automation editor was doing things.