Work around device tracker component deleting devices #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The device tracker component level code deletes any registered devices that are associated only with device_tracker entities. Not only that, but it will also (indirectly) delete those entities from the entity registry. This code was meant to fix behavior of older HA versions and was supposed to have been removed after 2022.6, but never was. Here is the culprit:
https://github.com/home-assistant/core/blob/78c1efa7d4b3faaf6a2bf63d71a64095453e0c97/homeassistant/components/device_tracker/config_entry.py#L54-L74
The result is that any user modifications stored in the entity registry are lost.
This change works around that code & problem by disassociating the device_tracker entities from their devices at shutdown so that at startup, the device tracker component level code won't try to delete the devices. When this integration is loaded (i.e., setup), it will reassociate the entities with their corresponding devices.