Script Migration from YAML to UI - Incorrect script entity names

Hi folks, hope you’re all having a lovely festive period time with family and friends.

I used to have all my automation and scripts in YAML. I finally made the move and imported them to the UI. This mostly went fine, some disappeared in the process, but nothing I couldn’t save from my backup.

However, one thing I’m finding is that I have inconsistencies between the old and new script names - this means that anything calling a script (for example a Lovelace button service call) is calling the incorrect script name.

For example …

… this script is called “script.hot_water_boost” when I view it from the Developer Tools / States pane.

It’s also “script.hot_water_boost” when I view it from Settings / Devices & Services / Entities pane.

It’s even “script.hot_water_boost” when I pull it up in Settings / Automations & Scenes / Scripts / Select Script / Three Dots / Information / Settings.

However … if I try to use “script.hot_water_boost” in my Lovelace dashboard button, it gives me an error saying that it can’t find that service to call.

If I edit my dashboard button …

… and let it autocomplete the name for me, I see that it’s actually called …

Screenshot 2022-12-26 at 12.22.37 pm

… script.hot_water_boost_2!

This works fine and calls the service correctly. The problem I have is I’d like to fix these so the script entity is named correctly (script.hot_water_boost_2, not script.hot_water_boost_2), but I can’t find anywhere to do that as Home Assistant think’s it’s already called that.

Has anyone come across this before, and does anyone know how I could go about correctly these script entity names?

Thanks very much as always!

I have no idea what motivates people to switch perfectly running automations and scripts to the UI from yaml. I really see no benefit. But…

it’s likely that the migration creates the new entity before it removes the old entity so there is a conflict with the entity_ids. When that happens HA automatically adds a “_2” to the end of the second duplicate entity_id.

You just need to find the old migrated entity_id and make sure its gone from the system and then rename the new entity_id to the same as the old one (remove the “_2” from the end).

I would assume the “_2” entities are the new ones but I would verify that before deleting anything.

Thanks for your help.

The problem I have is that I can’t see these “new” entity_id’s to rename anywhere in Home Assistant other than Lovelace autocomplete. Wherever I look I only see the “old” entity_id … which doesn’t actually exist.

See screeshots above, they all show “script.hot_water_boost” which doesn’t exist.
I want to rename “script.hot_water_boost_2” which I can’t find to change.

have you restarted HA since the migration?

Yes, tried it in case there was something cached somewhere. No change sadly. :cry:

That might be something else to try…

Clear your browser cache (ctrl-f5 in chrome)

I’ve given it a shot, no change.
Thanks for your help and suggestions. :grinning:

I’ll post it as a bug and see what comes. :crossed_fingers:t2:

If you convert them from yaml to the UI without deleting the yaml one, you’ll have 2 automations in the end. Especially if your yaml one did not have a unique_id because the UI ones do have a unique_id. The system will think you have 2 unique automations and assign _2 to the second one.