core
core copied to clipboard
Scripts deleted still on core.entity_registry
The problem
I needed to create 3 scripts for each curtain I have here, one for open, close, and stop. I have 6 curtains, so, 18 scripts.
- First I created them using the UI and using the "duplicate" command to make it easy.
- After a while I needed to recreate all of them, so, I delete all
- Restarted my HA.
- Then I create them manually on my scripts.yaml and reloaded the scripts. The identity_id became messed. Someone became with "_2" at the end, others appear with wrong names, of other curtain + "_duplicar" (duplicate) at the end.
- Investigating I found at config/.storage/core.entity_registry some old and deleted entities and that appears to be the reason for all this mess.
- I deleted all again, commented all yaml from my scripts.yaml , stopped my Docker container, checked the core.entity_registry, and still exist some entities there, which should not exist anymore.
Just a note :
- I still have referencing for these scripts in two places:
- Dashboard buttons
- Script which calls all others, to open all curtains and others to close all curtains. Could this be the reason? If yes, then the HA, at the delete of an entity should ask if should remove all internal references, historical and saving... should be optional. There is no sense to force all this.
What version of Home Assistant Core has the issue?
core-2023.4.6
What was the last working version of Home Assistant Core?
core-2023.4.6
What type of installation are you running?
Home Assistant Container
Integration causing the issue
Scripts
Link to integration documentation on our website
No response
Diagnostics information
No response
Example YAML snippet
abrir_persiana_gas_quarto_inf:
alias: Abrir persiana gas quarto inf
sequence:
- service: remote.send_command
data:
num_repeats: 1
delay_secs: 0.4
hold_secs: 0
device: Persiana Quarto inf Casinha Gas
command: abrir
target:
entity_id: remote.controle_broadlink
mode: single
icon: mdi:blinds-open
Anything in the logs that might be useful for us?
there is nothing in the logs.
Additional information
This situation here is after:
- excluded all my scripts from the UI
- removed all code from my scripts.yaml
- restarted my HA .
- Restarted docker container
Just showing :
- print screen from my scripts, where have no script of my curtains (abre/fecha/para ... persianas)
- print of the entity search, which show the excluded items
- print of the entity_id of one , per example.
- the grep on the .storage showing the references of the excluded scripts, still there...
(here it's saying : if not in use, exclude them from the config)
Just a complement.
I executed the steps below and in the end, I'm able to solve the situation, however, I still considering this a bug/defect of the core.
- deleted all scripts
- stopped the container
- edited the core.entity_registry and removed manually all references to my curtains.
- started the container
- check the scripts, where they look non-existent, however, if I search for the entity I still find them... so, the problem continues.
Then I repeat the test, but at step 3 I also edited the core.restore_state excluing all references of the entity_id removed from the core.entity_registry . Then after restart the container, the entities gone for good and when I re-add my scripts at scripts.yaml all them became with the correct identity_id.
That said, this is a very negative behavior because when we test sensors, scripts, automation, means all garbage still on HA Core, which will only cause problems and slow down all processes. At least, should exists some kind of "garbage collector" at the Developer menu where we can run manually to clean all these orphan references.
Probably a similar thing: Noticed many old entities from a Scrape integration (added / deleted in UI). https://community.home-assistant.io/t/core-entity-registry-still-contains-old-entities/594872
Hey there @home-assistant/core, mind taking a look at this issue as it has been labeled with an integration (script
) you are listed as a code owner for? Thanks!
Code owner commands
Code owners of script
can trigger bot actions by commenting:
-
@home-assistant close
Closes the issue. -
@home-assistant rename Awesome new title
Renames the issue. -
@home-assistant reopen
Reopen the issue. -
@home-assistant unassign script
Removes the current integration label and assignees on the issue, add the integration domain after the command.
(message by CodeOwnersMention)
script documentation script source (message by IssueLinks)
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.