I’m on the same boat and struggling with deficient diverse object_id / entity_id / unique_id and name / friendly_name relation implementation.
I find the arguments exposed against the Op’s requirement very scarce. Four wheels doesn’t make enough for a Ferrari. The same way, having the ability of getting an entity name in the interface (any name) does not make for a complete solution but the scarce.
I’m trying to build a package for advanced PV management, and I want to share it with my channel and group friends. I think that’s packages are for. I’m not building an integration or component.
So if I want that this package doesn’t interfere with anything that the installers already has on their systems, I must plan an entity_id (I name it like this bc that’s what gui shows).
The package has lots, lots of mqtt entities. And those end as:
- platform: mqtt
#name: 'Battery SoC'
name: energy_battery_soc
unique_id: energy_battery_soc
state_topic: "storage/battery"
value_template: "{{ value_json['soc'] }}"
unit_of_measurement: "%"
device_class: battery
state_class: measurement
So, the entity id I decided is <package>_<device / section>_<measurement>
.
- Name has to be like this or weird things happen. I’ve tried all combinations.
- Unique_id is useless (for me) but I must reiterate or the entity can’t have a human name.
- And then I must rely in the user to know what I’m talking about and write the “friendly name” for himself.
I’m also developer, and with the experience I know this is a fault.
If I put “Battery soc” as a name and don’t look back, the user could be squinting the eyes to get this one over a possibly large list of battery entities. I still don’t know how the included automations would function if the user has a phone battery entity.
Manual customizations are out of the equation if you want to share something or store something for rapid deployment.
Plus platform: mqtt is Pita compared to other entities. Someone talked about doing template entities instead, but I still haven’t found how to write an mqtt template entity. Just to replace the above one, for example. Or even better, to build a battery device that has all it’s measurements in child entities.
The package also has automations and helpers. Input selects, numbers… those are really ok.
The question is: Why all other entities, specially mqtt or modbus, are not defined like helpers? What are the wrong / obsolete one’s?
Please don’t take it badly. I have no intention to offend. Only give feedback and a defined field application where this is a problem.
Edit:
If unique_id is automatically calculated from the name, why isn’t automatically populated for the gui not complaining about not having an unique_id? Why it does exist (in yaml) in the first place?
Wouldn’t be better to have something like this for all yaml entities? (id + name)
platform_mqtt:
energy_battery_soc:
name: 'Battery SoC'
icon: mdi:battery-charging
state_topic: "storage/battery"
value_template: "{{ value_json['soc'] }}"
unit_of_measurement: "%"
device_class: battery
state_class: measurement
Or like gui elements:
platform: mqtt
energy_battery_soc:
...