How to guarantee consistency of entity names?

How entity names are derived from ESPhome devices is still a mystery to me. I think at the early beginning it was just complete chaos and if two devices had “watts”, entities would just be named sensor.watts, sensor.watts2 etc. At some point, sensor.devicename_sensorname seemed to become current.

I thought the first part of entities’ names would be “name” from the esphome section of the device … but it seems to be more friendly_name? Which one is it?

Now more importantly, what happens if I change these? I tried it out and it seems my entities remain the same. Good.

But this brings me to the next question: How can I ensure I get the same consistent entities in case I ever need to re-add my device?

Example:

My current entity is: sensor.vue2sub1_total_power. It was generated when I had:

esphome:
  name: vue2sub1
  friendly_name: vue2sub1

Meanwhile I updated my config to:

esphome:
  name: vue3basement
  friendly_name: "Vue Basement"

Fortunately my entities remained sensor.vue2sub1_total_power. But what if I were to remove and re-add this device? I am afraid it would create new entities sensor.vue_basement_total_power or sensor.vue3basement_total_power and hence break all my automations, history/statistics and InfluxDB archive.