OK further to this and I wanted to share one of the nuanced issues with HA…
Justification:
The reason for doing this is that HA IS TERRIBLE when it comes to replacing devices seamlessly when they become faulty OR a new technology comes along and you replace that device with different tech. If you replace that device with something different, you have to edit, lovelace, custom cards, scripts and automations and relace the old entity with the new one. Additionally it becomes problematic if you have “other” temlplates that reference that “real device” entity and do math on that entity to form a new one, because now you have to hunt down that math template and change it.
Im sure that anyone with a LARGE system with lots of templates has seen this and then wanted to just kill themselves:
"Do you also want to rename the entity IDs of your entities?
This will not change any configuration (like automations, scripts, scenes, dashboards) that is currently using these entities! You will have to update them yourself to use the new entity IDs!"
Therefore, for the last 5 years Ive taken a leaf out of @frenck book from many years ago (I dont rememeber which ‘choo choo’ video he mentioned it) and replaced all my physical entities with template entities that mimic the real devices.
So therefore it is easier to make a device template that represents a real device
EG:
sensor.shelly1_9899229989898_temperature = sensor.outside_temp_template
In Automations, scripts, lovelace, other entity templates(non-negotiable), climate controllers, blueprints, custom componenents, custom, cards (custom-button card templates also non-negotiable), node-red (I can keep going) etc you ONLY NEED to reference, sensor.outside_temp and youre golden. in EVERY PART of your HA instance.
.
If you HAVE to change the physical device from a shelly to a xiaomi/modbus/someobscurething in the future, all you need to do is change 1 line in your template and EVERYTHING WORKS!!! Automations, Templates, Custom Cards, custom templating within custom cards, scripts, blueprints etc etc etc because everything in your instance references:
sensor.outside_temp_template
We have always had templates - and templates create an easy way around this for larger installs that need reliability, rather than hours of hobbyist tinkering. Templates are not foolproof, but for the lack of basic global variables as entities within HA (perhaps in V2026.12.5) , in the meantime they are a good way of creating global entities.
NOTE: when I say"larger installs" - as a reference - the biggest of my lovelace dashboards is 38k lines long (I have 6 of them) and my automations.yaml is close to 30k and I use template cards to reduce the size of my lovelace code. there is also a real reason why my dashboards are so big, but that is a discussion for another post to do with lack of user admin, caching and preloading.