home-assistant / frontend

:lollipop: Frontend for Home Assistant
https://demo.home-assistant.io
Other
3.9k stars 2.64k forks source link

Script Entity ID not Updating when Changed #14140

Open Daniel-dev22 opened 1 year ago

Daniel-dev22 commented 1 year ago

Checklist

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 commented 1 year ago

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

Daniel-dev22 commented 1 year ago

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

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

github-actions[bot] commented 1 year ago

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.

Daniel-dev22 commented 1 year ago

Still ann issue.

hawkseye76 commented 1 year ago

Yep, still an issue.

larserikalexander commented 1 year ago

Still an issue.

mvanlijden commented 1 year ago

still an issue

domibarton commented 1 year ago

I've the same issue on 2023.1.7!

kasperschnack commented 1 year ago

Still an issue.

karwosts commented 1 year ago

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., 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 commented 1 year ago

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., 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.

https://github.com/home-assistant/frontend/assets/47092714/1869f163-1152-4cb1-a065-d1200d409c74

karwosts commented 1 year ago

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 commented 1 year ago

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.

https://github.com/home-assistant/frontend/assets/47092714/e3817c4f-7861-4b95-be2c-51718b56088b

'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 commented 1 year ago

@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 commented 12 months ago

@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 commented 10 months ago

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., 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.

github-actions[bot] commented 7 months ago

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.

Daniel-dev22 commented 7 months ago

Not stale.

rhmunich commented 6 months ago

Still an issue.

PineappleEmperor commented 6 months ago

+1

goodlucknow commented 6 months ago

+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 commented 5 months ago

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

justinmyersm commented 4 months ago

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 commented 3 months ago

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 commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

No includes here.

lukasmalkmus commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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.