Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script Entity ID not Updating when Changed #14140

Open
3 tasks done
Daniel-dev22 opened this issue Oct 20, 2022 · 32 comments
Open
3 tasks done

Script Entity ID not Updating when Changed #14140

Daniel-dev22 opened this issue Oct 20, 2022 · 32 comments

Comments

@Daniel-dev22
Copy link

Checklist

  • I have updated to the latest available Home Assistant version.
  • I have cleared the cache of my browser.
  • I have tried a different browser to see if it is related to my browser.

Describe the issue you are experiencing

If I create a script, rename the script entity id from the entities menu, the entity id is not renamed in the scripts.yaml.

The auto generator when you type will suggest the renamed entity_id and script name but it's not actually the correct entity id because when the script is called it says the script is not found.

Describe the behavior you expected

If a user renames a script entity_id from the entities page that it will update the script in scripts.yaml

Steps to reproduce the issue

  1. Create Script
  2. Change entity_id from entities page
  3. Attempt to use script from an automation or service call in developer tools.
  4. Check scripts.yaml and see the script entity_id never changed.
    ...

What version of Home Assistant Core has the issue?

2022.10.4

What was the last working version of Home Assistant Core?

No response

In which browser are you experiencing the issue with?

No response

Which operating system are you using to run this browser?

No response

State of relevant entities

I think this is expected behavior because it used to give an error when doing this but now it doesn't do the user assumes it actually changed the entity_id when it didn't.

Problem-relevant frontend configuration

new_script:
  alias: Master Lights Script
  sequence:
  - service: light.turn_{{ set_light }}
    target:
      entity_id: '{{ target_lights }}'
    data: '{{ light_setting }}'
  mode: parallel


I renamed that entity_id only to find it was never renamed in scripts.yaml and only renamed in the frontend/entities page.

Javascript errors shown in your browser console/inspector

No response

Additional information

No response

@Jeepmb
Copy link

Jeepmb commented Nov 12, 2022

Wanted to add to this, also experiencing the issue with 2022.11.1

@Daniel-dev22
Copy link
Author

Wanted to add to this, also experiencing the issue with 2022.11.1

Unfortunately... doesn't seem like anyone actually checks these.

@github-actions
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale label Feb 10, 2023
@Daniel-dev22
Copy link
Author

Still ann issue.

@github-actions github-actions bot removed the stale label Feb 10, 2023
@hawkseye76
Copy link

Yep, still an issue.

@larserikalexander
Copy link

Still an issue.

@mvanlijden
Copy link

still an issue

@domibarton
Copy link

I've the same issue on 2023.1.7!

@kasperschnack
Copy link

Still an issue.

@karwosts
Copy link
Contributor

karwosts commented Jun 7, 2023

If a user renames a script entity_id from the entities page that it will update the script in scripts.yaml

I don't believe this is how its supposed to work. The scripts.yaml does not have an entity_id. The identifier for the script in scripts.yaml is the unique_id, and that does not change when you rename the entity id.

I agree that there is still some confusion as some places display the script unique_id, some display the entity_id, some display the friendly name. and some display the alias. But I can't find any thing that's actually broken.

Is there anywhere where something does not work because you renamed a script, or is the issue only that the name displayed in certain places is not as desired?

E.g. I create a script with the unique id: my_new_script_original_name, and an alias "My Script Alias"

my_new_script_original_name:
  alias: My Script Alias
  sequence: []
  mode: single

The entity_id is originally script.<unique_id>, but it can be renamed.
The friendly name is originally the script alias, but it can be renamed.

I can rename the entity_id to script.my_renamed_script. I can change the friendly name to My Script Friendly Name

devtools: showing entity id and friendly name
image

services picker: shows unique_id and friendly name
image

scripts tab: shows friendly name
image

script editor: shows alias
image

Have I missed anything? Or is the issue just that you want the services picker to show the renamed entity id instead of the unique_id?

@Daniel-dev22
Copy link
Author

Daniel-dev22 commented Jun 7, 2023

If a user renames a script entity_id from the entities page that it will update the script in scripts.yaml

I don't believe this is how its supposed to work. The scripts.yaml does not have an entity_id. The identifier for the script in scripts.yaml is the unique_id, and that does not change when you rename the entity id.

I agree that there is still some confusion as some places display the script unique_id, some display the entity_id, some display the friendly name. and some display the alias. But I can't find any thing that's actually broken.

Is there anywhere where something does not work because you renamed a script, or is the issue only that the name displayed in certain places is not as desired?

E.g. I create a script with the unique id: my_new_script_original_name, and an alias "My Script Alias"

my_new_script_original_name:
  alias: My Script Alias
  sequence: []
  mode: single

The entity_id is originally script.<unique_id>, but it can be renamed. The friendly name is originally the script alias, but it can be renamed.

I can rename the entity_id to script.my_renamed_script. I can change the friendly name to My Script Friendly Name

devtools: showing entity id and friendly name image

services picker: shows unique_id and friendly name image

scripts tab: shows friendly name image

script editor: shows alias image

Have I missed anything? Or is the issue just that you want the services picker to show the renamed entity id instead of the unique_id?

Thank you for the response and I appreciate the work you're putting into the frontend.

I attached a video. If I edit the alias in the UI it updates the entity_id it will generate for the script. If I edit the alias in the script yaml it will not generate an entity_id and instead it's script.new_script do that 2 times and you will find you lost a script because it overwrote the previous one.

Screen_Recording_20230606_212815_Home.Assistant.mp4

@karwosts
Copy link
Contributor

karwosts commented Jun 7, 2023

Hmm I cannot reproduce any case where a script is "lost". If I do what you did (new script -> edit in yaml -> change alias -> save), I see new scripts added with some kind of unique # as their unique_id and entity_id. But I don't see anything being overwritten.


'1686107788648':
  alias: foo
  sequence: []
'1686107816319':
  alias: bar
  sequence: []

Nevertheless, is this a different issue than what you originally posted, which I think involved renaming the entity ids of existing scripts, not modifying the alias of new scripts?

Originally you mentioned:

when the script is called it says the script is not found

Do you have any examples of this? Also the videos are very helpful in showing which particular UI elements and fields you are referring to.

@Daniel-dev22
Copy link
Author

Hmm I cannot reproduce any case where a script is "lost". If I do what you did (new script -> edit in yaml -> change alias -> save), I see new scripts added with some kind of unique # as their unique_id and entity_id. But I don't see anything being overwritten.


'1686107788648':
  alias: foo
  sequence: []
'1686107816319':
  alias: bar
  sequence: []

Nevertheless, is this a different issue than what you originally posted, which I think involved renaming the entity ids of existing scripts, not modifying the alias of new scripts?

Originally you mentioned:

when the script is called it says the script is not found

Do you have any examples of this? Also the videos are very helpful in showing which particular UI elements and fields you are referring to.

I guess the issue is fixed. I just checked and I saw that doesn't happen for me anymore. Previously this would result in test the first script being overwritten.

Screen_Recording_20230607_064231_Home.Assistant.mp4
'1686134532780':
  alias: Test
  sequence: []
'1686134545845':
  alias: Fooscript
  sequence: []

when the script is called it says the script is not found
This was happening because the friendly name was the alias but the entity_id was script.new_script

@silamon
Copy link
Contributor

silamon commented Aug 18, 2023

@Daniel-dev22 , in what sense is this related or a duplicate of #17571.
Is the issue fixed for you, as mentioned above, or is there a way to reproduce this given the steps in #17571?

@Daniel-dev22
Copy link
Author

@Daniel-dev22 , in what sense is this related or a duplicate of #17571.
Is the issue fixed for you, as mentioned above, or is there a way to reproduce this given the steps in #17571?

Related in that there's issues with the Scripts UI resulting in bad entity IDs.

If I update the alias in yaml it does not update the script entity id.
https://github.com/home-assistant/frontend/assets/47092714/6fd92996-0ffe-4286-b2b3-7798983f0bc3

If I update the alias in the UI it does update the script entity id.
https://github.com/home-assistant/frontend/assets/47092714/fcd0bb1d-1748-43ce-aa4a-569724a80ed5

@george9816
Copy link

george9816 commented Oct 10, 2023

If a user renames a script entity_id from the entities page that it will update the script in scripts.yaml

I don't believe this is how its supposed to work. The scripts.yaml does not have an entity_id. The identifier for the script in scripts.yaml is the unique_id, and that does not change when you rename the entity id.

I agree that there is still some confusion as some places display the script unique_id, some display the entity_id, some display the friendly name. and some display the alias. But I can't find any thing that's actually broken.

Is there anywhere where something does not work because you renamed a script, or is the issue only that the name displayed in certain places is not as desired?

E.g. I create a script with the unique id: my_new_script_original_name, and an alias "My Script Alias"

my_new_script_original_name:
  alias: My Script Alias
  sequence: []
  mode: single

The entity_id is originally script.<unique_id>, but it can be renamed. The friendly name is originally the script alias, but it can be renamed.

I can rename the entity_id to script.my_renamed_script. I can change the friendly name to My Script Friendly Name

devtools: showing entity id and friendly name image

services picker: shows unique_id and friendly name image

scripts tab: shows friendly name image

script editor: shows alias image

Have I missed anything? Or is the issue just that you want the services picker to show the renamed entity id instead of the unique_id?

Ok, so the problem comes from the fact that the unique_id and the entity_id are very easy to be confused. I think both should be one and the same thing. Or, the unique_id should be editable.
Or, if not, the entity_id should be displayed everywhere and I think this is the better solution.

I encountered this problem when selecting a widget on Android. There, the services picker shows just the unique_id, without any Aliases. I changed the entity_id and, not being aware of the difference between the unique and the entity id, I didn't know why the modified id wasn't appearing.

Copy link

github-actions bot commented Jan 8, 2024

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale label Jan 8, 2024
@Daniel-dev22
Copy link
Author

Not stale.

@github-actions github-actions bot removed the stale label Jan 8, 2024
@rhmunich
Copy link

Still an issue.

@PineappleEmperor
Copy link

+1

@goodlucknow
Copy link

+1

Happening for me with latest HA OS. Just recently moved from a docker container to dedicated machine, this is the cause of a lot of teething problems copying automations over from my old install.

@dylango
Copy link

dylango commented Mar 15, 2024

Still an issue. It makes me afraid to change entity_id at will.

@justinmyersm
Copy link

justinmyersm commented Apr 12, 2024

This is still an issue.

Renamed script:
entity_id_01

Broken automation because the automation is looking up the "unique_id" vs "entity_id":
entity_id_02

scripts.yaml:
entity_id_03

The "unique_id" needs to change when the "entity_id" does to eliminate the confusion.

To make things worse, it references the new entity_id when using yaml:
entity_id_04

Home Assistant OS installed on barebones machine.

Core: 2024.4.3
Supervisor: 2024.04.0
Operating System: 12.2
Frontend: 20240404.2

EDIT: I would like to add the issue persists after a reboot of the OS and the entire machine.

EDIT2:

Updating the "unique_id" in scripts.yaml "fixes" the automation, but breaks the script:
entity_id_08
entity_id_05
entity_id_06
entity_id_07

@karwosts
Copy link
Contributor

I know I previously said I didn't think it was possible, but I did find a sequence of steps that allowed me to overwrite an existing script by creating a new one. I have filed the specific steps as a new issue #20777.

@lukasmalkmus
Copy link

This still seems to be an issue. I don't know the circumstances but when I create a new script, save it and change its entity_id, I still see the old ID in the UI, when e.g. trying to use the script as an action. However, the Devices > Entity view shows the correct, new ID.

@masi
Copy link

masi commented Jun 28, 2024

This still seems to be an issue. I don't know the circumstances but when I create a new script, save it and change its entity_id, I still see the old ID in the UI, when e.g. trying to use the script as an action. However, the Devices > Entity view shows the correct, new ID.

Same here.

I see a discrepancy between the name of the service and the name of the entity. Looks like changing the id of the script changes only the name of the entity, but not of the service.

Which is odd in the UI, as you see the name and icon of the service and not the script entity.

@ulnic
Copy link

ulnic commented Jul 12, 2024

still an issue today for me as well. Just migrated some services from scripts (yaml) and I just noticed the same - exactly as above. Took me a while to realise as it's only in the service tab the real script entity id is shown apparently - all other UI shows the updated name.

Does anyone know how to force-update (or which file to update to make this change permanent)?

@ulnic
Copy link

ulnic commented Jul 12, 2024

for anyone else also having this issue - do you have a customize: !include customize.yaml or similar inside your configuration.yaml file? Could it be linked to this?

@vilhalmer
Copy link

No includes here.

@lukasmalkmus
Copy link

I got

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

But I'm 99% sure that's the baseline configuration.

@ulnic
Copy link

ulnic commented Jul 12, 2024

hmm wonder what it could be. Tried to rename again (via UI) to a v2 but then picked this up in the logs. Not sure why it would already be in use?

Could it be something that if the script is referenced in e.g. automations or so?

image

@ulnic
Copy link

ulnic commented Jul 13, 2024

only way I got this to be aligned is that I

  1. Renamed the existing old script to an entity id i was NOT going to use
  2. Duplicated an existing script and ensured the script NAME is the exact format I wanted to use it.
  3. Deleted the previous / old script

This means other entities, such as fan for me would still use the old script names after I had done the migrate from yaml to UI on quite a few of these.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests