home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.61k stars 29.92k forks source link

Renaming Script Entities does not rename script ID #124550

Open sam-ward opened 3 weeks ago

sam-ward commented 3 weeks ago

The problem

This may be expected behavior, but it caught me out today so I thought i'd log it. I went through the exercise today of migrating my scripts (and automations) from yaml files to the editor using the migrate button. The process was:

  1. Migrate the script, naming it the same as the old script (so it ends up with a _2 suffix).
  2. Delete the script from the manually maintained yaml file (not scripts.yaml).
  3. Using the Developer Tools -> YAML -> Reload Scripts.
  4. Using Settings -> Devices -> Entities screen to delete the orphaned script entity and change the entity ID of the new script entity to remove the _2 suffix

But what I found was that despite renaming the script, the script could only be referenced in an automation with its "original" old name (with the _2 suffix), and there didn't appear to be any mechanism to effect the rename as desired.

In the end to achieve the desired result I manually edited scripts.yaml file and changed (what I am assuming is) the script ID and used the developer tools to reload the scripts (in hind sight I could have also copied the script again to the desired name and deleted the _2 instance).

As I said i'm not sure if this is expected behavior, but it is certainly confusing behavior that you can not rename a script in-spite of the UI appearing to allow you to do so. Its also confusing because the same process does work on the automations.

What version of Home Assistant Core has the issue?

core-2024.8.2

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

script

Link to integration documentation on our website

https://www.home-assistant.io/integrations/script/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 3 weeks ago

Hey there @home-assistant/core, mind taking a look at this issue as it has been labeled with an integration (script) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `script` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign script` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


script documentation script source (message by IssueLinks)

Plawasan commented 3 weeks ago

Similar thing happens even if you stick entirely to GUI, i.e. if you rename a script, the service action that the script provides keeps the old name. The only workaround I could find is recreating the script from scratch with the new name which then also creates the action under the new name.

rrooggiieerr commented 5 days ago

Duplicate of https://github.com/home-assistant/core/issues/115334

masi commented 5 days ago

The option "rename" changes what is called "alias" in YAML of the service.

Mind that there is also an entity for the service which can be (re-)named independently.

sam-ward commented 5 days ago

The problem I am seeing is that despite renaming the alias, and renaming the entity, at the UI layer atleast (I’m not sure if it’s deeper), it appears to only recognises the ID (if that’s the correct term, the 0 indent line of the scripts.yaml) of the script in the automation editor, developer tools, and auto complete.

On Sun, Sep 15, 2024, at 12:39 AM, Martin Kutschker wrote:

The option "rename" changes what is called "alias" in YAML of the service.

Mind that there is also an entity for the service which can be (re-)named independently.

— Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/124550#issuecomment-2351054712, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAF2YVEAFSRN7CGOTMASYIDZWRRE7AVCNFSM6AAAAABNCDHFLKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNJRGA2TINZRGI. You are receiving this because you authored the thread.Message ID: @.***>