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

[BUG] Docker entities duplicating on HA restart #60

Open
Pacoboyd opened this issue Jan 15, 2025 · 13 comments
Open

[BUG] Docker entities duplicating on HA restart #60

Pacoboyd opened this issue Jan 15, 2025 · 13 comments
Labels
bug Something isn't working

Comments

@Pacoboyd
Copy link

Got a bug happening on my instance that basically every time I restart HA I get a brand new set of docker entities and the old ones all go unavailable. If I do multiple restarts, I get multiple sets of stale entities.

My cards still continue to work because I'm using auto-entities and filtering out unavailable, but it's getting a little tiresome to do cleanup every reboot.

Love the plugin and I have a workaround, just informing of the issue.

Also, would love it if it would remember renamed entities. At first I thought it was an issue with renaming the docker entities, but then even if I didn't rename them, they were still creating new entries on reboot.

@Pacoboyd Pacoboyd added the bug Something isn't working label Jan 15, 2025
@Pacoboyd Pacoboyd changed the title [BUG] Docker entries duplicating on HA restart [BUG] Docker entities duplicating on HA restart Jan 15, 2025
@domalab
Copy link
Owner

domalab commented Jan 15, 2025

@Pacoboyd That's a strange bug. If you enable debug logging on integration and reload it does any errors show up in logs?

Anything else in the logs that's showing this strange behaviour?

@Pacoboyd
Copy link
Author

Pacoboyd commented Jan 15, 2025

home-assistant_unraid_2025-01-15T21-24-46.374Z.log

Was able to duplicate by just restarted the integration as well.

Looks like it keeps trying to migrate existing sensors to a new unique_id sensor. Not sure why

@domalab
Copy link
Owner

domalab commented Jan 16, 2025

Have you tried to remove the integration completely, clear cache, clear Unraid entries from Developer Tools -> Statistics and re-installing it?

  1. Uninstall the Unraid integration from Home Assistant
  2. Remove the existing entities using one of these methods:
  • Use the GUI: Settings > Devices & Services > Entities and delete all Unraid-related entities
  • Or manually delete the relevant entries from the .storage/core.entity_registry file while HA is stopped
  1. Remove any old integration data:
  • Delete the Unraid integration configuration from .storage/core.config_entries
  • Delete any Unraid cache files in config/custom_components/unraid/
  1. Restart Home Assistant
  2. Reinstall the integration

This would give you a clean slate with proper entity IDs from the start, avoiding any migration issues completely.

From release 2024.12.28 code was refactored and proper entity names and unique IDs was introduced but to migrate old entities to new ones is a hit and miss.

@domalab
Copy link
Owner

domalab commented Jan 16, 2025

home-assistant_unraid_2025-01-15T21-24-46.374Z.log

Was able to duplicate by just restarted the integration as well.

Looks like it keeps trying to migrate existing sensors to a new unique_id sensor. Not sure why

From the logs, I see Entity ID Collisions and I see multiple instances where entities are being removed and recreated with similar patterns.

So its a bug in the migrations.py file

@Pacoboyd
Copy link
Author

Pacoboyd commented Jan 16, 2025

OK, took steps below, still having an issue unfortunately. After reinstalling, it has the proper entities, but restarting the integration still creates a bunch of unavailable entries.

  1. Uninstall the Unraid integration from Home Assistant - Done
  2. Remove the existing entities using one of these methods:
  • Use the GUI: Settings > Devices & Services > Entities and delete all Unraid-related entities - Done
  • Or manually delete the relevant entries from the .storage/core.entity_registry file while HA is stopped - Done, little tricky but got it done with ssh addon and notpad++, removed 233 lines
  1. Remove any old integration data:
  • Delete the Unraid integration configuration from .storage/core.config_entries - Done, this didn't have anything for unraid in it after removing the integration
  • Delete any Unraid cache files in config/custom_components/unraid/ - Done, this folder didn't exist after removing the integration
  1. Restart Home Assistant - Done
  2. Reinstall the integration - Done

@The-Croz
Copy link

I am actually having this issue as well

@The-Croz
Copy link

The-Croz commented Jan 24, 2025

@Pacoboyd did you rename your "device" brought in by the Unraid integration and change all entity IDs to match? I believe that is what's triggering the issue. It tries to recreate the entities from the original device name and then I end up with a bunch of duplicates and name conflicts.

FYI, the default name my Unraid integration loads with is "Unraid Server (Server)" so I get entity names like "Unraid Server (Server) Server Docker Service" and the ID as "binary_sensor.unraid_server_server_server_vm_service". I attempted to change these manually to clean up the redundancies in the names created but then is when I ran into this bug mentioned here.

EDIT: Actually, this does still occur on restart as well. I get new entities created with _2 at the end and all the original entities go offline.

@19jm81
Copy link

19jm81 commented Jan 26, 2025

Having the same issues here, with no renaming of any kind, just simply install and I see duplicates appearing

Image Image

@The-Croz
Copy link

The-Croz commented Feb 2, 2025

Anyone having any luck fixing this? Ended up just uninstalling the integration for now until it can get fixed since I kept getting duplicates.

@blair287
Copy link

blair287 commented Feb 3, 2025

Same issue here every restart duplicates everything.

@domalab
Copy link
Owner

domalab commented Feb 3, 2025

@Pacoboyd @The-Croz @blair287 @19jm81 I haven't looked into this yet due to other commitments.

@domalab
Copy link
Owner

domalab commented Feb 4, 2025

@Pacoboyd @The-Croz @blair287 @19jm81 I had some free time and made updates to the migration code. When you get time can you please test it and see if it fixes the duplicate entity issue you are experiencing?

You will need to download the source code as a zip file from the bug/migrations-fix branch

https://github.com/domalab/ha-unraid/tree/bug/migrations-fix

Or copy the code files from bug/migrations-fix branch and replace yours then restart home assistant.

  1. init.py
  2. migrations.py
  3. naming.py
  4. config_flow.py
  5. const.py

@blair287
Copy link

blair287 commented Feb 7, 2025

@Pacoboyd @The-Croz @blair287 @19jm81 I had some free time and made updates to the migration code. When you get time can you please test it and see if it fixes the duplicate entity issue you are experiencing?

You will need to download the source code as a zip file from the bug/migrations-fix branch

https://github.com/domalab/ha-unraid/tree/bug/migrations-fix

Or copy the code files from bug/migrations-fix branch and replace yours then restart home assistant.

  1. init.py
  2. migrations.py
  3. naming.py
  4. config_flow.py
  5. const.py

Tried it out i got a migration error on first start but deleted and readded integration now its all good not creating duplicates I've reloaded integration and restarted HA no more issues. Thanks great work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants