EuleMitKeule / device-tools

Device Tools: Create, modify and merge your Home Assistant devices.
73 stars 6 forks source link

Associate and then dissociate an entity to a virtual device causes it to disappear permanently #22

Open profucius opened 6 days ago

profucius commented 6 days ago

Hey there, first of all great integration! Very useful for my specific needs.

I was doing some testing with some non-critical data, and I discovered one of the ways that this integration can be destructive (you did generally warn us).

Specifically, I created a new virtual device, and then I associated an entity to it which belonged to a different device. It worked. However when I removed the entity from the virtual device, the entity seems to have disappeared. It did not reassign to the previous device, nor can I seem to find it anywhere in the Entities page/list. I do still see a reference to it in the core.entity_registry file, but (as expected) much of its metadata has been stripped out.

This poses a problem, that I cannot even reassign the removed entity to the virtual device even. I think this integration needs some method (or instructions) to recover removed entities. At the very least, to reinclude whatever metadata is necessary so that they show in the list again, but ideally to reassign them back to their original device.


Side related important note: You mentioned in the Caution callout on the Readme.md that it could potentially break stuff. Can I suggest that you add a note to this, specifically calling out a warning the above; If an entity is associated to a virtual device and then removed from it, that you may be unable to associate it again to anything. At least until this is resolved or worked-around.

Thanks for your time.

EuleMitKeule commented 6 days ago

I think this is a bug, as generally it should be possible to revert any changes made by this integration.

Specifically this is the code where reverting changes happens: https://github.com/EuleMitKeule/device-tools/blob/4ea9f63de232eb2ae84619f127d4c19a9945fa9a/custom_components/device_tools/device_tools.py#L317

EuleMitKeule commented 6 days ago

I added a section about known issues to the readme and included this bug.