Refactoring for entity id (in comparison to renaming)

Currently if you rename the entity id, it seems hass will only change its value in the database. This causes a problem that, e.g. previously you have referred to this entity via the old id in an automation script, the script will not anymore, or if you have referred to it in Node-RED.

To solve this, is it possible to add a “refactor” function (many IDEs have this) to change all occurrences of this entity, even inside an add-on?

+1 this would be a very helpful feature especially if devices are being injected through other services that could update frequently and change the names. I have a few of these through my HomeSeer integration and the manual cleanup work is laborious.