This is an automated archive made by the Lemmit Bot.
The original was posted on /r/homeassistant by /u/ktaragorn on 2026-02-16 23:26:54+00:00.
TL;DR - set discovery_unique_id_generator: mac as a safe default when configuring MQTT for your ESPHome device. This is needed if you have multiple esphome devices exposing sensors/entities with the same name.
This is a rant/followup to https://www.reddit.com/r/homeassistant/comments/18odja0/mqtt_not_assigning_unique_ids_i_thought_it_used/ which seems to have been archived for some reason.
I recently found out that home assistant prefixes entity names with device names for the entity id, and you can set a friendlyName. So it seemed the cleanest way to expose say multiple temperature sensors in multiple rooms, is to call them all name: temperature and set the friendlyName of each of the esp controllers according to the room of the house so the entity names end up like hall_temperature and bedroom_temperature. Previously I had esp32_bedroom_temperature and was dealing with it, or trying to use customize.yaml to fix it at hass.
However this leads to the dreaded "Platform mqtt does not generate unique IDs." error from hass. This commonly happens if you rename your ESP32 controller ( which I guess I had, so it seemed legit) and 99% of the posts above recommend different versions of clearing your data -> deleting the device on hass, deleting the retained messages, etc. I even went as far as nuking my mqtt container and trying to start again.. but it didnt help.
Turns out that while hass tries to be smart with entity id and keeping it unique with <device\_name>-<entity\_name>, it uses uniq_id provided by esphome to ensure it is a new entity, and this id is not using device name or any thing like that to keep it unique. In my case, both hall_temperature and bedroom_temperature were using ID ESPsensortemperature which was causing the clash.
I came across the reditt post above, but it didnt seem promising at the time, so didnt go deeper at first, and spent days trying other solutions. Setting that config solved my problem instantly. I dont know why this is not the default, instead of "legacy". I want to share this to spare others the pain.
Like the OP in the linked post.. this feels like I am still missing something, and cant be the intended experience.. let me know if I am missing something obvious, other than just naming your sensor verbosely with the device name at the source.