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.