Scripts entity_id bug

Hello,

I have a bug with scripts.

When i create a script with the entity ID “test_script_1” and change it in HA interface to “test_script_2”, it become “test_script_2” in the entity ID but it stay “test_script_1” in the yaml and is not found when i use action to “test_script_2”.
If i edit yaml and restart HA to become “test_script_2”, it go to “test_script_3” in entity ID but it is reachable in action to “test_script_2”…

It’s complicated to be very clear with this bug but there is something wrong with the script’s renaming actually.

Thanks.

What yaml?

Where?

I agree.
You need to be more specific what you are doing

script.yaml in /config
restart HA

So you create the script in UI then rename it in scripts.yaml?

I create a script in UI and rename it in UI (title and entity_id).
When i do that, action can’t find the new entity_id, renaming is not really working.
Then i look in yaml and find the old entity_id, the rename in IU didn’t change it.

You mean in the scripts editor?
That only changes the friendly name as I understand it.

To change the entity ID you need to open developer tools and find the script, open. Open info and change it there.

When you create something in the UI then you shouldn’t change it in yaml.

I’m sorry i have more than 6000 automations and 1000 scripts, i normally know what i’m doing but maybe i don’t explain clearly myself as i’m not english.

Did you tried to reproduce what i said ?

Create a script then rename it like an automation in this windows and then try to call the script with the new ID to see if the renaming is working.

I renamed a lot of automations a few days ago and they work fine and I can use the action automation.trigger and see them with the new name.

I am talking about SCRIPT !!!

Yes… and everything is probably completely different just because its a script.
The rename of a script probably is a different code than the one renaming a light or automation…
Yeah…

And no, I don’t want to even try.
Your first post and every following post has not been very great so I’ll just leave it here.

Yes it is exactly very different because it is a script.
I absolutely have no problem with automations.
Only with SCRIPT and i tried on 3 differents HA, same problem !
There is bug with entity_id renaming for script !!!

I agree that naming in scripts is a bit of a dog’s breakfast, but I’m not sure you can call it a bug. Just a mess. :grin:

Can’t see how to do this. Which bit of developer tools?

Can’t agree with you there. A user should never be able to break a system by issuing legitimate commands. “You shouldn’t do that” is not good enough.

As you can see from what you quoted, where you “find the script” and where you can “open more info”, i.e. states.

Well there is a reason why HA has moved from “everyone has to do everything in yaml files” to “(most) everything can be done without the yaml files”.
I can see there could be issues when you create a script in UI, rename it in yaml and then expect it to work.
I wouldn’t have seen that coming as a developer. I would expect either UI or yaml, not both.
Kind of like, “let’s see if I can break it some how”.
Moving from yaml files to UI was several years ago. So if something has fallen between then that isn’t surprising.
If it has taken this many years to find this issue then… I mean is it an issue?
And if it is. Is the forum the correct place to post it on?

Hm. How do I use Developer Tools | States to change an entity ID?

I notice that after changing the entity ID of a script in the file editor, the old name still appears in Developer Tools | States, which shows it as “unavailable”. This remains after a restart and even after a reboot. Even if you delete the script with the changed entity ID, the original is still there.

Maybe part of the problem is that we’re thinking of changing the entity ID of a script as “renaming” it, whereas it’s more like cloning.

I’m not aware that this happens when you change the IDs of other types of entity. You’re probably right that it’s an artefact of the move to UI editing.

Again… next few words of you quote. More info. The button that is an (i), then you press the cog wheel as usual.

I thinknunderstand what op is saying. It’s not a bug. They’re renaming the script in the rename script block (or in the alias in yaml) expecting it to update the entity_id.

Op it does not. You must edit the entity ID in the more info dialog (the gear icon) to get this.

All of the other places op mentions only edits the alias. And the alias doesn’t impact the entity ID. So it can appear that you have a bunch of busted entities after a bunch of alias renames ask me how I know… :sunglasses:.

I ran into the idiosyncracy whole renaming a bunch of Fridays script aliases and had to go back to update thier entity_ids separately.

The question is if you update the alias in the script in UI should we expect an entity ID rename to match. Op apparently does.

This will update the entity_id but not the service. I.e. if you use script.turn_on with your new entity_id, it will work.

This is a known limitation. Likely will get rejected if you file it as a bug.

I.e. if you name something script.test_1, the service/action will be script.test_1 and the entity_id will be script.test_1. If you rename the script entity_id to script.test_2 via the UI, the service will be script.test_1 and the entity_id will be script.test_2.

Meaning, this will be same regardless how many times you change the entity_id:

action: script.test_1

but this will need to be updated after you rename the entity_id

action: script.turn_on
target:
  entity_id: script.test_2
1 Like

Ah! Never tried that… Thank you. :grin: