How to truly change entity ID of a script?

I create a script “Party lights Living room”. It gets entity ID script.party_lights_living_room.

Then I duplicate the script. I can’t rename it without saving first, so I save it. It gets enttiy ID script.party_lights_living_room_duplicate.

I rename the script to “Party lights Kitchen”. That doesn’t change the entity ID, so I do that manually.

However, the old entity ID never really goes away. If I click “Restore entity ID”, it will change the entity ID of the script back to script.party_lights_living_room_duplicate:

How do I sever the connection between the original script and the duplicate?


UPDATE

A solution (albeit a cumbersome one) is here:

After renaming it, click the Update button, not “Restore entity ID” (which renames/restores the original name).

As an alternative, I usually just switch to YAML view on the old script/automation and simply copy the entire body of the YAML.

Then I:

  • Paste the YAML into a new script/automation.
  • Delete the alias line.
  • Save it (giving it a new name).
  • Delete the old automation/script

That procedure does lose any history associated with previous runs, but it reliably assigns a new name and it’s easy for me to remember.