Go to entities list in Settings - there is no āsensor.xxx_yyy_zzzā sensor (as well as āsensor.some_friendly_nameā). The sensor is not created.
Goto Log - it contains no info about this sensor.
What I expected:
3. The sensor "sensor.xxx_yyy_zzz" is created, it has a friendly_name āSome friendly nameā.
or
3. The sensor "sensor.some_friendly_name" is created, now I can open itās settings and manually input a friendly name āSome friendly nameā.
or
3. The sensor "sensor.some_friendly_name" is created, now I can customize it (using YAML) with friendly name āSome friendly nameā.
Thatās the way it normally works ( sensor.some_friendly_name will be created and you can customize it via UI or customize.yaml / customize section). I canāt say why nothing is created in your case.
Can you please post your full sensor code?
Friendly name is just an attribute, so you add it as you would any other attribute:
template:
- sensor:
- unique_id: xxx_yyy_zzz
name: "Some name I want the entity_id based on"
state: >-
{{ ... }}
attributes:
friendly_name: "This is my friendly name"
Sorry, do not know how it happened - but I was wrong.
The sensor IS created.
And it has a entity_id āsensor.some_friendly_nameā, a name āSome friendly nameā.
Now I can change itās entity_id & name via UI.
But - I need this sensor to be "sensor.xxx_yyy_zzz" - and why I cannot get it via YAML?
OK, I may specify āxxx_yyy_zzzā as a name in YAML:
and the created sensor is āsensor.xxx_yyy_zzzā.
Now to set a friendly_name I need to either use UI or customize option. Why it is not possible to specify a friendly_name while declaring a sensor? (like it is possible for legacy syntax)
I do not like a trend to replace YAML by UI. I am trying to keep all code in YAML.
Currently I will have to use the ācustomizeā option to set a friendly_name. This is not a progress.
Seems that with the new syntax some code is stored in json files and CANNOT be changed by YAML.
That is why I do not call it a āprogressā.
I just started using the new syntax (probably after more than a year when it was invented), currently seems that it is not as predictable as the legacy syntax.
I tried this from version to version. Seems that friendly_name isnāt accepted. The attribute is only built if I use another alias (e.g. friendly: or details: ).
Did you see any records in the Log?)
I did not.
The sensor is just not created. Silently.
Moreover, the āfriendly_nameā is not supposed to be added as a simple attribute. So, that advice of another person āadd this attributeā was not based on knowledge (((
If you use unqiue_id, then your entity_id will be sensor.template_xxx_yyy_zzz. If you omit unique_id and jus t use name, your entity_id will be sensor.some_friendly_name. Your entity is created, but youāre searching for the wrong term.
FYI. Everything I just said is what happens when you FIRST create the sensor. If you make changes to the configuration but maintain the unique_id, everything I just said is thrown out because itās now inside your entity_registry and you have to manage the names in the UI.
If you want everything set via the YAML with a name and friendly nameā¦
- sensor:
- name: xxx_yyy_zzz
state: "{{ blah }}"
attributes:
friendly_name: Some Friendly Name
Second to Lastly, as @finity saidā¦ just donāt use the new style if you want a unique_id, entity_id, and name to be all different. The sole purpose of supplying a unique_id is to manage the entity from the UI. If you donāt have those intentions, donāt use it with the new style.
Lastly, the other option is to also customize your entity in the customize section.
It should be like any other entity and be an attribute on the entity itself. Again, keep in mind that you cannot have a unqiue_id and you have to be editing a new entity. As soon as you create a sensor with unique_id, any yaml edits to name may not appear depending on what you did in the UI.