How to set an MQTT sensor's ID manually? [SOLVED: you can't]

Tags: #<Tag:0x00007f3281bd84d0> #<Tag:0x00007f3281bdfe60>


I’m setting up some MQTT sensors using ESPEasy.

I would like to set the sensor ID manually, but it is always inferred from the friendly name:

  - platform: mqtt
    state_topic: "ESP_LoLin_A/bme280/Pressure"
    name: "Pression Bureau"    
    unique_id: lolinA_pressure
    device_class: pressure
    unit_of_measurement: 'hPa'

This would give a sensor named sensor.pression_bureau, although I’d like to have it named sensor.lolinA_pressure, in case I want to change its location some day.

Obviously, I’m using unique_id wrong.

How could I set the name manually?

Well for a start you can’t use uppercase letters in the object_id.

Secondly, unique_id is only used by the UI to keep track of entities, not to create the object_id.

Good point for the uppercase A, thanks.

However, as you might guess, this is not the heart of the problem.

Are you saying this cannot be done?

Yes. The object_id is taken from the sensor name and there is no way to alter it.

Correct. That’s how it is designed to work.

The only way to achieve it is like this (and capitalized letters aren’t allowed):

    name: lolina_pressure

You can also use

name: Lolina Pressure

Thank you all for your answers.

I want the friendly name to be “Pression Bureau” (Workroom pressure) and it is more important than the object_id identifying my LoLin A.

It is very surprising that the two are so intricate.