I’m running 2023.11.0 and using modern template sensor style. As it has been described in details in this post, if entity_id and name are defined at the same time, the entity_id value will be set with the same value as the name value not the entity_id. I noticed that not setting the name at first place, sets the entiy_id to the desired value, and setting the name afterwards, well entity_id keeps it’s initial value.
But as @petro suggested is to use customize. Further along, @petro informed that this does not work anymore.
While as some other fellows I think it is weird not be be able to define the entity_id and name with different values (on my side for algorithmic reasons), I’m wondering whether something has changed since then.
I know that I can use the old programming style but I prefer to keep things going forward. In the meantime what I do is the following
First set the template sensor with no name and unique_id only
template:
- sensor:
- unique_id: irrigation_volume_id2
state: '{{state_attr("binary_sensor.irrigation_unlimited_c1_z1","volume")}}'
state_class: measurement
unit_of_measurement: "m3"
Then set the name
template:
- sensor:
- unique_id: irrigation_volume_id2
name: Irrigation Consommation Kfé François
state: '{{state_attr("binary_sensor.irrigation_unlimited_c1_z1","volume")}}'
state_class: measurement
unit_of_measurement: "m3"
Doing so, the template sensor will still be set with the value I need.
Setting the entity_id with GUI is not an option.