What to do when getting the "Platform esphome does not generate unique IDs."?

I have several Sonoff Basic switches which are all called switchXX where XX are two digits. I used to have them flashed with ESPurna (and communicate with HA though MQTT) but I decided to move them to ESPHome.

To do this, I used the same steps for ~20 switches:

  • reflash the switch
  • remove it from HA (via the web interface)
  • add it to HA though the ESPHome component.

The reason for this approach is to make sure I have clean switch.switchXX entries, and not something like switch.switchXX_2 because of an existing switchXX entry. As you can imagine, this is a learned experience :slight_smile:

So now all my switches are moved and they have the right names. Except one, namely switch02 (there is nothing special with this switch).

When starting HA, I see in the logs:

2020-08-19 16:05:40 ERROR (MainThread) [homeassistant.components.sensor] Platform esphome does not generate unique IDs. ID 68c63aa3ad46-wifisignal already exists - ignoring sensor.switch02
2020-08-19 16:05:40 ERROR (MainThread) [homeassistant.components.binary_sensor] Platform esphome does not generate unique IDs. ID switch02binary_sensorswitch02 already exists - ignoring binary_sensor.switch02
2020-08-19 16:05:40 ERROR (MainThread) [homeassistant.components.switch] Platform esphome does not generate unique IDs. ID switch02switchswitch02 already exists - ignoring switch.switch02

Apparently, there are some artefacts left from the “old” switch02 (why, I do not know). Despite the log messages switch02 works perfectly and is seen correctly by HA: (the ESPHome integration also sees one switch02, 2nd screenshot below)

image

When searching for switch02 in the entities (though the web interface) I see only what is above. There are no traces of the other entries form the log.

While this is mostly an aesthetical/cleanup point (because switch02 works as expected) I would like to understand how to get rid of these entries.

I imagine I could fiddle with the contents of .storage because I do see them there, but I would prefer a softer approach first (domain redacted):

/etc/docker/data/hass/.storage(master*) # grep switch02 *                                                                                                              root@srv
core.config_entries:                    "host": "switch02.my.domain",
core.config_entries:                "title": "switch02",
core.config_entries:                    "host": "switch02.my.domain",
core.config_entries:                "title": "switch02",
core.device_registry:                "name": "switch02",
core.entity_registry:                "entity_id": "binary_sensor.switch02",
core.entity_registry:                "original_name": "switch02",
core.entity_registry:                "unique_id": "switch02binary_sensorswitch02",
core.entity_registry:                "entity_id": "switch.switch02",
core.entity_registry:                "original_name": "switch02",
core.entity_registry:                "unique_id": "switch02switchswitch02",
core.entity_registry:                "entity_id": "sensor.switch02",
core.entity_registry:                "original_name": "switch02",
core.entity_registry:                "entity_id": "device_tracker.switch02",
core.entity_registry:                "original_name": "switch02",
core.restore_state:                    "friendly_name": "switch02",
core.restore_state:                "entity_id": "switch.switch02_2",
esphome.0841eee4ac7f43c683fbe804bdf2352e:                "name": "switch02",
esphome.0841eee4ac7f43c683fbe804bdf2352e:                "object_id": "switch02",
esphome.0841eee4ac7f43c683fbe804bdf2352e:                "unique_id": "switch02binary_sensorswitch02"
esphome.0841eee4ac7f43c683fbe804bdf2352e:            "name": "switch02",
esphome.0841eee4ac7f43c683fbe804bdf2352e:                "name": "switch02",
esphome.0841eee4ac7f43c683fbe804bdf2352e:                "object_id": "switch02",
esphome.0841eee4ac7f43c683fbe804bdf2352e:                "name": "switch02",
esphome.0841eee4ac7f43c683fbe804bdf2352e:                "object_id": "switch02",
esphome.0841eee4ac7f43c683fbe804bdf2352e:                "unique_id": "switch02switchswitch02"
esphome.6f498b337d14425f8f2516a8687e62a3:                "name": "switch02",
esphome.6f498b337d14425f8f2516a8687e62a3:                "object_id": "switch02",
esphome.6f498b337d14425f8f2516a8687e62a3:                "unique_id": "switch02binary_sensorswitch02"
esphome.6f498b337d14425f8f2516a8687e62a3:            "name": "switch02",
esphome.6f498b337d14425f8f2516a8687e62a3:                "name": "switch02",
esphome.6f498b337d14425f8f2516a8687e62a3:                "object_id": "switch02",
esphome.6f498b337d14425f8f2516a8687e62a3:                "name": "switch02",
esphome.6f498b337d14425f8f2516a8687e62a3:                "object_id": "switch02",
esphome.6f498b337d14425f8f2516a8687e62a3:                "unique_id": "switch02switchswitch02"
esphome.fb94b3930d0c4d409982cecf05ad100e:                "name": "switch02",
esphome.fb94b3930d0c4d409982cecf05ad100e:                "object_id": "switch02",
esphome.fb94b3930d0c4d409982cecf05ad100e:                "unique_id": "switch02binary_sensorswitch02"
esphome.fb94b3930d0c4d409982cecf05ad100e:            "name": "switch02",
esphome.fb94b3930d0c4d409982cecf05ad100e:                "name": "switch02",
esphome.fb94b3930d0c4d409982cecf05ad100e:                "object_id": "switch02",
esphome.fb94b3930d0c4d409982cecf05ad100e:                "name": "switch02",
esphome.fb94b3930d0c4d409982cecf05ad100e:                "object_id": "switch02",
esphome.fb94b3930d0c4d409982cecf05ad100e:                "unique_id": "switch02switchswitch02"
1 Like

Did you find a solution?

Not exactly. I edited the entries in the UI to switch02 but did not found why the issue happened in the first place.

I think one must manually get rid of the outdated esphome. files.
I found 4 ones containing the identical dallas temp sensor ids, while only one of the files is the actual one which also gets listed from within the file core.entity_registration.
And the error remained until I clean that list of next to 60 esphome… files resulting from either having copied the code from one ESP8266 onto another (exchanged one with an internal antenna by another with external antenna, or even replaced it by an ESP32.

Looks as if HA suffers from Redmond’s Windows “let’s keep as much garbage as possible” feature :slight_smile: but granted it might not be a HA issue but caused by ESPhome.

Have to tidy my ESPfiles … we’ll see if this cures the issue.

Have a look at the core.config_entries file located inside the .storage folder.
Mine had around 10 duplicated or outdated entry_ids, being dead ones from the past which of course did contain the very same dallas ids the actual esp definition file got.
And since not only the core.config did contain the entries but also a waste of more but 50 outdated esphome.nnnnnnn files were still there, HA felt to take these into account somehow.

I wished there’s a ‘cleaning’ tool which, perhaps there’s one I missed so far?

1 Like

Did anyone find a cleaning method for old ESPHome ID’s?

1 Like