Name: Yours to do with as you please, does not have to be unique. Used for display in the frontend. You can either define it in YAML or change it in the UI depending on the integration.
Entity Id: Yours to do with as you please, does have to be unique. Used for entity selection in the backend. Most people use a naming scheme along the lines of <domain>.<location>_<function> e.g. switch.upstairs_bedroom_bedside_lamp You can either define it in YAML or change it in the UI depending on the integration.
Unique Id:Does have to be unique, and you can define it for YAML integrations (but not discovered ones?). Used by home assistant to keep track of things like customised entity ids.
@WallyR i know that there is a way via the UI. But im searching for a way without using the UI. I want to be able to configure everything via YAML.
@tom_l can you please give me an exampe for a YAML configuration where i can set all three (name, entity_id und unqiue_id) for a template sensor for example?
Even though the chances are very high, you cannot be 100% sure that the entity_id will become sensor.lounge_dehumidifier_time_remaining because HA has the last word and could append e.g. _2 to the entity_id.
If the unique_id configured in YAML is used for a second sensor an error at startup will be thrown and you will instantly know there is something wrong.
Besides that. I’m wondering why the friendly_name variable was removed from the new format and one has to go detour over customize.yaml?
Finally it is an architectural question wether or not the unique_id should be useable by the user or if it should be hidden from the user.
The problem here is that you cannot write yaml that defines and uses a sensor, say in a package, and be sure that it will work, because the sensor it defines might not end up with the entity_id that the yaml uses to refer to it. For example;
If you just load this yaml snippet, there is no guarantee that sensor.battery_output_power will actually be based on sensor.battery_power, because there might already be a sensor.battery_power so the one defined in this yaml file might actually be sensor.battery_power_2.
And you will probably not notice this because it will silently apparently work. AFAIK there is no way you can say “use the sensor I defined just up there”.
I agree that using too generic names is part of the problem, but it’s also nasty that it’s a “silent error”. It would be nice if you got a “Error: entity already exists” failure trying to load the yaml.
I think you will get an error if the unique_id is not unique, but that’s not the identifier you use to reference the entity, so it doesn’t really help because even if unique_id is unique, the entity_id could still be automatically changed.