Rename service (script)?

I had an issue recently where I was trying to add a widget to my Android phone which called a script I have in Home Assistant. ALL my scripts were showing apart from this one, and I couldn’t figure out why it was missing.

After a while investigating I realised that the “service” name did NOT match the entity name / script name, so it was called something random, not what I was expecting based on its name / entity name.

Pretty sure it was a script I renamed ages ago but it’s kept the “service” name as it was on creation.

Can the “service” be renamed after initial creation?

So to reproduce:

  1. Create a script with name “my_script_number_1”.
  2. Rename the entity / name of the script to “my_script_number_2”.
  3. Open up Developer Tools > Services and try to find “script.my_script_number_2”. It doesn’t appear in the list, but “script.my_script_number_1” does (despite being renamed and no longer existing under that name).

Is this just how things work? Should a script always be created fresh rather than renaming? Or is this a bug I should raise with service names not getting renamed under the hood?

Thanks!

1 Like

There are 2 things:

  • the friendly name
  • the entity_id

You renamed the friendly name, but not the entity_id

I had changed the entity ID as well. It still shows the “service” as the original name.

You’ll be able to reproduce it fairly simply with my steps, I’ve just done it again with a new script and reproduced it perfectly straight away with my steps.

I’m on the latest version of Home Assistant, too.

Screenshot showing that the entity ID is correct.

Ah, looks like someone has raised it as an issue in Github: Renaming script entity id fails · Issue #115334 · home-assistant/core · GitHub

1 Like

I added a temporary solution here: Renaming script entity id fails · Issue #115334 · home-assistant/core · GitHub

This caused issues actually so I changed it back. It had a warning message in some screens saying a script couldn’t be found.

And there is the service name. I found no way to change that.

I have the same issue since 2023 version.
I have script
tv05ir_on_and_play
and decided to rename it to
tv02ir_on_and_play
It would seem that both friendly name and entity was renamed successfully.
BUT IT WAS NOT. Despite I see entity
script.tv02ir_on_and_play
in settings of script and it the global entities list,
the script with new name cause error in automation, and OLD
name script.tv02ir_on_and_play is still working, but does not exist in entities list.
This very annoying problem and the only workaround is to delete problematic script and create it again

This thread is kinda hard to follow. You say you are talking about names, but seem to for some bizarre reason set the “friendly name” to be slugified or even the exact same as the entity ID. Just, why?!

Anyway. Many (most? all?) things in HASS has two names. You have the “friendly name”, which is the one you can set in the “Show settings” window where you can also change the entity ID. But then there is some other name that still exists on a different level. For a script/automation, you can change this “other” name by selecting “Rename” from the … menu.

Why is it this way? I have no idea, and I think it just makes things confusing. In most places within HASS, the “friendly name” if one exists (i.e. is not blank) will override and be displayed instead of the “other name”. But in some places, such as Developer Tools > Actions, it will not.

At least you can change both names for scripts/automations. For helpers, it is impossible to change the “other”/“original” name! At least not from the UI. If you manually edit the hidden config files/database (which is discouraged), it probably can be done somehow.