home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.16k stars 29.83k forks source link

Many "Jewish Calendar" integration entities were duplicated with an "_2" appended to their ID #119657

Closed VictorS42 closed 3 months ago

VictorS42 commented 3 months ago

The problem

Home Assistant listed repair: delete the lines for the "Jewish Calendar" integration from configuration .yaml, then restart HA.

After following those instructions, all of the original entities were marked "no longer provided" and a new set appeared with an "_2" appended to the entity ID. Deleting and reinstalling the integration did not resolve the problem. I can manually delete the old entities and delete the "_2" from the new entities.

HA JCal 2024-06-13 222739

What version of Home Assistant Core has the issue?

core-2024.6.1

What was the last working version of Home Assistant Core?

core-2024.6.1

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Jewish Calendar

Link to integration documentation on our website

https://www.home-assistant.io/integrations/jewish_calendar

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 3 months ago

Hey there @tsvi, mind taking a look at this issue as it has been labeled with an integration (jewish_calendar) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `jewish_calendar` 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 jewish_calendar` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


jewish_calendar documentation jewish_calendar source (message by IssueLinks)

puterboy commented 3 months ago

I had the same problem after the latest update. All 25 existing entities were duplicated with a _2 and the original ones were ignored. This also broke all my automations that referred to the initial entity versions.

I fixed this painfully but manually by:

  1. Create a Backup of HA
  2. Stop HA: ha core stop
  3. Back up homeassistant_v2.db and the .storage directories
  4. Edit /homeassistant/.storage/core.entity_registry to (a) remove the initial unsubscripted entries (b) remove the '_2' suffix from the new entries
  5. Use sqlite to delete the 25 _2 suffixed new metadata_id entries from the states_meta table. Since these were the last 25 new entries, it was relatively painless using something like:
    sqlite3 home-assistant_v2.db "DELETE FROM states_meta where metadata_id > NNN"
  6. Use sqlite to merge the new with the old state data. This was relatively simple since the metadata_id's were in the same order for both the original and the new 25 entities. If that is true and the new _2 entities are the last entries in states_meta, you can use a single sqlite statement like:
    
    sqlite3 /homeassistant/home-assistant_v2.db "UPDATE states SET metadata_id = metadata_id - <DIFF> WHERE metadata_id > NNN" where <DIFF> is the difference between the new an the old metadata_id's
  7. Restart HA: ha core start

It seems to have worked!

This is not for the faint of heart -- and backing up is critical

tsvi commented 3 months ago

@puterboy if you still have the backup of the entity registry file, could you post here the values of the unique_id for the old and new entities? Please also post longitude, latitude, and elevation currently in your home assistant config. I would like to try and fix this for others.