Unique_id: with MQTT sensor not working

Hi!
Im trying to sett unique_id: with a custom MQTT sensor, but it dosent work. It takes the name as ID

    - unique_id: "heatingSystem_heatcarrier_out_temperature"
      name: "Värmebärare Ut (GT8)"
      state_topic: "heatpump/0004"
      unit_of_measurement: "°C"
      icon: mdi:thermometer

I expected to get an entity with the name

sensor.heatingsystem_heatcarrier_out_temperature

but get

sensor.varmebarare_ut_gt8

Any advise?

Unique ID is not the same as entity ID. The entity ID comes from the name. This is the same throughout the system.

I use UUIDs for my unique_ids using this tool: https://www.uuidgenerator.net/ — for example:

- name: "Immersion switch switch input"
  unique_id: 4d973a01-6229-4e16-b276-17e191f0c522
  state_topic: "shellies/shelly1pm-XXXXXX/input/0"

You can rename the entity ID via the UI if you really want to:

1 Like

Thank you for pointing me in the right direction. This entity does not have a unique ID? - Home Assistant

so in my case this would be more correct…

- name: "heatingsystem heatcarrier out temperature"
  unique_id: d9cc470f-bd5e-4142-a278-69001b0c8e30
  state_topic: "heatpump/0004"
  unit_of_measurement: "°C"
  icon: mdi:thermometer

And then change the name through the UI to “Värmebärare Ut (GT8)”

An entity ID can only be lowercase letters without accents plus underscores.

You can keep the name as you want it displayed by default, and alter the entity ID if you don’t like the default conversion.

What are you trying to achieve here? Where are you trying to read the name?

Okey, Im new to HA, used OpenHAB before. I’m want to end up with a sensor that has one name that is for the UI, and one entity ID for automations etc… I don’t want these to be the same, they follow different patterns (naming conventions) that I have.

In most cases, you can customise what is shown in the UI, no matter what the entity name is.

This is what I’m looking for. But as I understand it cant be achieved completely from YAML with MQTT.

It can.

- name: Some Name
  unique_id: d9cc470f-bd5e-4142-a278-69001b0c8e30
  object_id: heatingsystem_heatcarrier_out_temperature
  state_topic: "heatpump/0004"
  unit_of_measurement: "°C"
  icon: mdi:thermometer
2 Likes

THANKS! This was exactly what I was looking for.