does mqtt AD use device name for sensor

For devices supporting the Auto Discovery feature. Like ZWaveJS2MQTT, Zigbee2MQTT.

Moderator: leecollings

Post Reply
Gravityz
Posts: 652
Joined: Wednesday 16 December 2015 19:13
Target OS: NAS (Synology & others)
Domoticz version: 2025.1
Location: Netherlands
Contact:

does mqtt AD use device name for sensor

Post by Gravityz »

i recently installed a couple of esp sensors and they work great.

however i migrated one from a device called ESP8266-co2 to a device called ESP32-co2 and noticed the co2 sensor was instantly working without being discovered as a new device.
It looks like MQTT AD does not use the name as part of the unique sensor id.
I also noticed that when i have a device with a plain name(without - in it) it is recognized differently

Question 1:does MQTT AD use devicename as part for creating unique id's (eg, when you rename de device it is discovered as a new device)
Question 2: could it be that the - in the device name/friendly name is causing this

Code: Select all

2025-12-30 15:41:49.416 Status: MQTT Auto Discovery Client Gateway: Discovered: douchelamp/douchelamp (unique_id: ESPlightdouchelamp) supported_color_modes: { color_temp, rgb }


2025-12-30 15:23:59.432 Status: MQTT Auto Discovery Client Gateway: Discovered: ESP32-Watermeter (Meterkast Temperatuur)/ESP32-Watermeter (Meterkast Temperatuur) (unique_id: ESPsensormeterkast_temperatuur)
User avatar
waltervl
Posts: 6677
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: does mqtt AD use device name for sensor

Post by waltervl »

I am not using MQTT AD but in latest beta the device/sensor naming has been changed: https://github.com/domoticz/domoticz/pull/6431
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Gravityz
Posts: 652
Joined: Wednesday 16 December 2015 19:13
Target OS: NAS (Synology & others)
Domoticz version: 2025.1
Location: Netherlands
Contact:

Re: does mqtt AD use device name for sensor

Post by Gravityz »

ok thanks. maybe it will fix this.

i checked the mqtt message and that one includes the complete path including devicename so the problem is in the discovery part.

eg a MH-z19 sensor inside a esp called ESP-8266 sents out this message after it is discovered and created by mqtt ad

homeassistant/sensor/esp8266-co2/mh-z19_co2_value
esp8266-co2/sensor/mh-z19_co2_value

now when i move that sensor into a complete new unit called esp32-co2 i expected the devices to be recreated but they are not

this is send out
homeassistant/sensor/esp32-co2/mh-z19_co2_value
esp32-co2/sensor/mh-z19_co2_value

but the same previous created ESPsensormh-z19_co2_value is being used.

so this means if you use the same naming convention in all of your esp's( which is preferred) you get into trouble if you have more devices with the same sensor name/light
User avatar
waltervl
Posts: 6677
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: does mqtt AD use device name for sensor

Post by waltervl »

I think it uses the info in the config topic to create the Domoticz device.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Gravityz
Posts: 652
Joined: Wednesday 16 December 2015 19:13
Target OS: NAS (Synology & others)
Domoticz version: 2025.1
Location: Netherlands
Contact:

Re: does mqtt AD use device name for sensor

Post by Gravityz »

i checked the config string.
that string is complete
domoticz receives the complete path (see first post) but aparently is only using the unique id which begins with ESP, the the name of the device(light,sensor) and after that the name of the sensor

i looked if i can append anything from esphome but do not think i can since everything send out of esphome is unique but since domoticz is only using the last part of it(the unique id) you might run into problems if you have multiple esp's with a sensor called temperature.
lucky for me i named most sensors specifically(eg flair_temperature_in) instead of just temperature.
i do have a couple of standard sensors buttons which i use in all my esp's(restart, esp_temperature, esp_wifi_signal but i do not send out these to be recognized

Code: Select all

{"dev_cla":"carbon_dioxide","unit_of_meas":"ppm","stat_cla":"measurement","name":"MH-Z19 CO2 Value","ic":"mdi:molecule-co2","stat_t":"esp32-co2/sensor/mh-z19_co2_value/state","avty_t":"esp32-co2/status","uniq_id":"ESPsensormh-z19_co2_value","dev":{"ids":"8cd0b2a8b5e7","name":"ESP32-CO2","sw":"2025.12.2 (Dec 31 2025, 09:05:53)","mdl":"esp32-c3-devkitm-1","mf":"Espressif","cns":[["mac","8cd0b2a8b5e7"]]}}
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest