"Entity id already exists" error, but the entity does not exist in any configuration file

From Home Assistant log (ver. 0.105.4):

(...)
2020-02-16 22:15:03 INFO (SyncWorker_8) [homeassistant.loader] Loaded system_log from homeassistant.components.system_log
2020-02-16 22:15:03 INFO (MainThread) [homeassistant.bootstrap] Setting up {'logger', 'system_log'}
2020-02-16 22:15:03 INFO (MainThread) [homeassistant.setup] Setting up logger
2020-02-16 22:15:07 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 415, in _async_add_entity
    raise HomeAssistantError(msg)
homeassistant.exceptions.HomeAssistantError: Entity id already exists: switch.switch_2. Platform mqtt does not generate unique IDs
2020-02-16 22:15:07 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 415, in _async_add_entity
    raise HomeAssistantError(msg)
homeassistant.exceptions.HomeAssistantError: Entity id already exists: switch.switch_9. Platform mqtt does not generate unique IDs
2020-02-16 22:15:07 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 415, in _async_add_entity
    raise HomeAssistantError(msg)
homeassistant.exceptions.HomeAssistantError: Entity id already exists: switch.switch_2. Platform mqtt does not generate unique IDs

I tried to locate these switch_2 and switch_9 duplicate entries:

# find . -type f -exec grep -Hn "switch_2" {} \;                                                                                
./home-assistant.log:5:homeassistant.exceptions.HomeAssistantError: Entity id already exists: switch.switch_2. Platform mqtt does not generate unique IDs
./home-assistant.log:15:homeassistant.exceptions.HomeAssistantError: Entity id already exists: switch.switch_2. Platform mqtt does not generate unique IDs
./.storage/core.entity_registry:504:                "entity_id": "switch.switch_2",
./.storage/core.restore_state:861:                    "friendly_name": "switch_2",
./.storage/core.restore_state:869:                "entity_id": "switch.switch_2",
Binary file ./home-assistant_v2.db matches

It looks like it is registered only once in ./.storage/core.entity_registry. I have stopped HA, deleted core.* files and restarted HA → the output above is after that operation. (switch_9 is the same).

These names used to exist a long time ago (more than just these two) but are long gone and not present in any configuration.

Is this a bug?

more like the way HA registry works.

I think it is, same phenomenon here.

Kr,

André

I found the reason.

I was getting these entries though MQTT (mosquitto), as discovery retained states. I stopped mosquitto, removed its database, restarted it as well as HA and the entries are gone

2 Likes

That woked me.

Thanks WoJWoJ

Do you use of the Add-On mosquitto? If so where is the database located?
Because I have same issue… :slight_smile:

No, I use a standalone installation of mosquitto (in a docker container)

Ok clear, I found the location of the dB. Removed it and solved

Where did you find it?

1 Like