MQTT Switch Plattform - Unique-ID is not the referenced ID in switches group

Hi Guys,

Home-Assistant is a way too buggy in how you configure things. I love it to give every mqtt-switch an unique id / name. But why is this unique id not used for internal naming?

- unique_id: mqtt_ds_eg_gang_wohnzimmer_left
  platform: mqtt
  name: "EG Gang Wohnzimmmer Relais 1 - Ganglicht"

Ends in switch.eg_gang_lichtschalter_wohnzimmmer_relais_1_ganglicht but why? This is so a big lack in configuration that i ever have to lookup that switch in correct naming before i can use them in automatisation or in Loveplace UI.

In this case, i also have a typo in “Wohnzimmmer” with 3m instead of 2m if i correct this misspelling, i have to adopt all other settings that rely on “name” instead of “id”. That is very confusing and totally seamless.

Other configurations, such as “groups.yaml” is complete different language setup.

  name: Alle Lichter
    - switch.kg_abstellraum_licht
    - switch.kg_heizung_licht
    - switch.kg_technik_licht
    - switch.kg_gang_technik_relais_1_keller_gang_licht
    - switch.eg_gang_lichtschalter_wohnzimmmer_relais_2

ID [all_lights] is also used for the naming, so “group.all_lights” is referenced to that piece of yaml-code.

Why is this not also working for switches.yaml?

AFAIK, unique_id is something invented later for lovelace interface. Before it the name (its normalized form) was defined as enough identifier and it remains.
The point is that unique_id is not mandatory.

On question why it is how it is? I would say bad design decisions (there are discussion around about why did they need second unique identifier), backward compatibility - it’s hard/expensive to change such things. not the first and not the last questionable ‘feature’ you can find overe here

Good news is, the inconsistence you found is not so important nor annoying. I feel mqtt integration is most reliable and flexible.

That is not completely true.

MQTT-Setting “name” is also not mandatory:

name string (optional, default: MQTT Switch)
The name to use when displaying this switch.

So if you define more than one MQTT-Switch you will have a duplicate warning, or the system is automatically increment an number for that device _1, _2, _3 and so on.

In the programm-code the mqtt-module only have to check for existing uniquie_id setting and rely on that value instead of “name”-Attribute.