"Only scripts inside scripts.yaml are editable."

I am not so sure how I came to this situation, maybe by editing a script from the UI and from scripts.yaml at the same time, but here I am:

I have a script listed in the scripts list in the UI that I cannot edit: clicking on the “Edit script” button opens the following error message:

Only scripts inside scripts.yaml are editable.

But this script doesn’t exist in my scripts.yaml file.

Thus I’m stuck and cannot delete it. How can I get rid of it?

2 Likes

either with “file-editor” ( install the add-on if you aint got it )
or through Samba, ( if you have it ) or through SSH ( If you have it ) :wink:

As I said, this script doesn’t exist in my scripts.yaml file. :slightly_frowning_face:

Yes, but you also mentioned you “messed around” with manual/UI editing, so did you save it as a separate “something.script” ?
Also make sure you deleted ALL cache in browser, etc., And i.e restart Core, if you haven’t already

BTW: What do you use to “Edit” your script.yaml ? , do you see any “additional” script-files in /config or /config/scripts ?

PS: You also didn’t mentioned whether you had “additional” folder for scripts ( stated in your configuration.yaml )

so did you save it as a separate “something.script” ?

No, saved it in scripts.yaml

Also make sure you deleted ALL cache in browser, etc.,

Yes, already did.

And i.e restart Core

Yes, already did, and several upgrades since I have this issue, so Core and OS have been restarted multiple times.

What do you use to “Edit” your script.yaml ?

VS Code, with “Home Assistant Config Helper” extension.

do you see any “additional” script-files in /config or /config/scripts ?

No

You also didn’t mentioned whether you had “additional” folder for scripts ( stated in your configuration.yaml )

I don’t, only:

script: !include scripts.yaml

It is the same as with automations. If you have several locations, only the main (default) location is editable.

I don’t understand, what are you saying exactly? I do have only one file where scripts are defined (the default scripts.yaml), but the ghost script does not exist in that file.

Found a way to remove this ghost script, was far easier than all I’ve tried!

In the UI, click on “Info” on the script row, then click “Remove entity”:

7 Likes

Folks, this looks like a bug. I did not edit anything directly in yaml, neither in the ui editor, nor using the file editor. I changed the entity name, automations immediately found out the old script does not exist, they let me found the new one with new entity name, however, the list of scripts contain the old one that goes directly to this error. Scripts.yaml contain the old entity name. So I renamed the entity directly again in the script.yaml and it opens. This is apparently a bug.

4 Likes

This explains the issue perfectly for me - well done. Figure you may need to log an issue on GitHub.

Problem with saving scripts · Issue #76208 · home-assistant/core (github.com)

1 Like

Frank Nijhof:

When changing entity name for a script, the script keeps saved with old name in scripts.yaml but has new name for HA UI, which causes mess.

This is not a bug, but by design. Changing properties of an entity in the UI overrides what is set in the backend (in this case, the YAML file).

1 Like

Came here because of the same problem. And I didn’t understand the explanation. I can change the entity_id everywhere via UI entity list. And now scripts are the only ones, where I get into trouble if I do this? Really don’t get it.

1 Like

If I got it correctly, the point is that you have the option to change entity id in general, ervywhere but if you want to change id of the script, do it there. I understand it from the developers perspective, keep option everywhere. I think they should consider a warning popup windows when you are changing entity id for a script

Yes and no. Yes there are differences between yaml from automations and scripts. But in the end of the day, they are technically more or less the same. But e.g. for automations I can change entity_id. And for every other entity as well. So if we are talking about “year of harmonization”, I don’t get, why this problem is “not a bug, but design” for scripts. For me it is not typical for HA entity handling and not fitting to automation and other areas. Perhaps not a bug, but at least a historical gap.

2 Likes

Then go to the github topic I created and tell Frank directly. I understand your arguments.

Thank you @ otiel!
genius

Not sure someone mentioned this already, this is how i get rid of the duplicate script.

Short version
If you change the script name, a duplicate script appears and you can delete the old one on the “entities” tab.

Long version
Settings / Automations & Scenes / Scripts / 3 dots at the back of a script / Show info about script / Tab: Entity setting / Entity id: change this value

If you restart Home Assistant (Settings/System/Restart) a 2nd script with the same name appears in the scripts list. The new named entity id you can edit / use now.

How to delete the old one.
Settings / Devices & Services / Entities / Search Entities: "old entity name whom gives the error “Only scripts inside scripts.yaml are editable.” / has a red “restored” icon at the back / select and delete.

2 Likes

ok and again. I duplicated a script and edited it as I wanted. Then I renamed the old script as “deprecated” and renamed the new one I just created by the duplication to have the same name as the one I currently call deprecated. I used GUI only and I am once again in that mess that clicking on a new script opens the old one. If this is by design, it’s wrong design.

1 Like

The short version is to delete the entity. The “design” is that by renaming the script, you do not rename the entity. Each script is also an entity and renaming scirpts do not rename entities. By renaming script, you detach it from the entity, which leads to this mess. I think that proper design would be to not allow users do this mess through the GUI. That’s actually the reason why complex systems such as HA move from yaml to gui, to avoid mistakes.

@frenck would you open this case within your developer team? I think that @arganto made a good point that the handling of entities related to scripts is not consistent with other parts in HA such as automations. Thank you