Entity IDs for autoconfigured sensors

I am using scripts to create some MQTT sensors via autoconfiguration. For example (one of several sensors for the garage thermometer device):

alias: Set up garage thermometer
sequence:
  - service: mqtt.publish
    data:
      topic: homeassistant/sensor/garage_thermometer/temperature/config
      retain: true
      payload: |
        {
          "name": "Garage Thermometer Temperature",
          "state_topic": "rtl_433/freyr/devices/Ecowitt-WH53/3/219/temperature_C",
          "unique_id": "garage_thermometer_temperature",
          "device_class": "temperature",
          "state_class": "measurement",
          "unit_of_measurement": "°C",
          "value_template": {% raw %}"{{ value | float | round(1) }}"{% endraw %},
          "device": {
             "name": "Garage Thermometer",
             "model": "WH53",
             "manufacturer": "Ecowitt",
             "identifiers": ["Ecowitt-WH53-219"],
             "via_device": "rtl_433"
          }
        }

This works fine, except for one thing: the resulting entity ID is “garage_thermometer_garage_thermometer_temperature”, while I was expecting it to be the same as the unique_id.

What do I need to change to get the outcome I was expecting? Can someone explain (or point to an explanation) of how the entity_id is determined.

The unique_ID is only used by the backend in HA. You may be able to see it, but never talk to it. It’s needed as a stable ID that the operator is not supposed to change in order to allow certain UI functions. (Like name changing)

You are best off to use unique_id’s and give them machine names like 01cf2959-f88c-4d21-bd7c-ad0b7a364482 (a uuid) so you aren’t tempted to try to use it somewhere. Less confusing.

Thanks. I can use UUIDs as unique_id.
How do I control/set the entity ID?

It’s giving you ‘device name’_‘entity name’ like the docs say. Change those to your liking.

OK, I see where I went wrong. I shouldn’t have included the device name in my sensor names.

Thanks for pointing me in the right direction.