WTH Delete devices from GUI

Maybe there needs to be better documentation around this? It isn’t obvious to a user that this is the case. But where does it go? This page titled devices is about adding integrations. Then the last example is about entities, but still calls them devices. I can submit a PR to clear this page up. But it is unclear to me where the documentation on actual devices lives.

https://www.home-assistant.io/docs/configuration/devices/

I myself spent a long time wondering why my mobile app integration had two devices for my phone and why I could not simply delete the old device that was orphaned with no entities.

1 Like

Bug report raised.

There were additional bug reports but specifically related to not being able to delete group devices (which are just light devices in Deconz)

and in this closed bug report it is confirmed that you have to delete entire integration with some note about being fixed in next release. Obviously this did not happen since we still complain about it

2 Likes

Others should raise bug reports for additional integrations. Make sure to raise it against the integrations and not the addons.

I use the MQTT integration but with auto discovery disabled so I cannot confirm if this is still buggy. Can some of you with that problem confirm and raise bug reports against it?

I remember Philips Hue integration having same issue. But I have thrown out my Hue hub and gone all in on Deconz. So I cannot confirm that one either. Can you delete a device in the Hue integration? Does it get auto deleted if you remove it from the Hue hub?

My reasoning towards this…

If I update a device name (ex - because I moved a light switch to different room) through the device manufacturer app/web service/etc, HA does not update the entity_id/friendly names/etc to reflect the new name.

If I could delete the HA device, restart, the integration should recreate the device and entities to reflect the new name.

At least in this use case, you can rename the device in Phoscon.

And after that renames the device in Home Assistant. Both device and entities. There is a user interface for it. And actually for Deconz adding a device causes it to be pulled into Home Assistant when it is discovered with its default name. You can rename it all you want in Phoscon. You still need to go to HA and rename it there.
Exception is event names. They update as they are actually not stored as entities. They exist when the event happens and that is it. But the battery sensor name will be some default you have to rename after adding it

So this use case is actually not an argument why we need to be able to delete devices.

You could argue that renaming a device in Phoscon should rename it in Home Assistant. That could become a major breaking change for many of us that have renamed entities to an overall naming scheme. I am not sure I would like that.

UniFi integration should clean up after it self when the user remove a client from the controller.

funny thing at my system when using deconz integration and unifi integration is that when clicking on the deconz integration and the filter is filtered on ‘deconz’ it is also showing the unify controller in te list :stuck_out_tongue:

I think there’s been confusion about this. For example, I raised this issue about the Tuya integration not cleaning up devices but was told that, when the PR to enable config flow was made, they were asked to remove the cleanup code since the devices would be cleaned up automatically as a result of another PR which had been merged.

@Robban I just had to manually delete 6 devices from core.device_registry

They were all called unknown device and a record typically looked like this

            {
                "area_id": null,
                "config_entries": [
                    "4154b4ac75fc4ce49ab03078ff1dae7c"
                ],
                "connections": [
                    [
                        "mac",
                        "9c:8e:cd:08:cc:81"
                    ]
                ],
                "entry_type": null,
                "id": "f57a7c42954b4bea92f892a13b0d42ea",
                "identifiers": [],
                "manufacturer": null,
                "model": null,
                "name": null,
                "name_by_user": null,
                "sw_version": null,
                "via_device_id": null
            },

They were just cruft waiting to be deleted. Some had disabled entities and I could see from their names that they were actual old devices. Most were Apple related.

It is just another example of having to hack core.device_registry to get rid of devices that no longer exist. There should be a DELETE button natively in Home Assistant so you can get rid of the cruft.

As of today there has been no activity on the Deconz integration bug I raised. You still need to hack a JSON file to replace a light bulb in Home Assistant and I had to do it again the other day when I retired a device because I got a new and better for same lamp.

1 Like

Real life gets in the way now and again

2 Likes

The activity I hoped for was a simple acknowledgement of the bug being a real bug that will eventually be addressed.

Q: How many Home Assistant users does it take to change a light bulb?
A: None. We just tell the users to buy a new lamp and throw the old one in the corner of the living room?

Q: How many hours does it take to replace a light bulb?
A: 30 hours and 1 minute. 1 minute to replace the physical light bulb and 30 hours to read the entire official deConz thread on the forum.

Q: How do you give an old broken Philips Hue light bulb a proper funeral?
A: You just throw it in the garbage bin. The memory of its former glory will last forever in Home Assistant

Q: How do you recognise the current light bulbs from the old zombie light bulbs in Home Assistant
A: The old ones have swear words as names.

Q: Why do you have an area called Saint Paulus Cemetery?
A: That is where I move my devices that are dead and cannot be deleted

Q: Why are your light bulb jokes so pathetic?
A: Because I am an engineer
A2: Oh, I am sorry. I did not know

17 Likes

Hi all,

I noticed that also Chromecast integration has the same bug. Old devices no longer available are shown in gui.

So I opened an issue:

This is one of the most what the heckiest thing in hass. Almost every integration is affected.

I assume, that not always an integration can understand that a device is old or replaced and should be deleted. That is why we should have a way to do it manually for any integration and any device without editing JSON configuration db.

Let’s free home assistant from legacy devices!

2 Likes

Great! :slight_smile:
In 0.116 I deleted a device in deconz and ran the new service “deconz.remove_orphaned_entries”. And now the device is gone in HA!
No need to edit the core.device_registry anymore! Thank you, thank you, thank you! :slight_smile:

2 Likes

Thanks for verifying :slight_smile:

@robban I also want to give feedback. First thanks for addressing this really annoying problem

I have tried this a few times. It sort of works but not as I think people expect

First - I tried the feature of disabling new devices automatically. When I disaable this then I can add new devices and rename them before pulling them into HA. That is great. But once I have renamed it it is hard to pull it in. The deconz.device_refresh does not load the new device. I tried several times. I had to restart HA to get the device loaded.

Then I added the new device (a light bulb) and removed it again in the Phoscon app.

And then tried the deconz.remove_orpharned_entries and a device was removed. But not the new one. I never found out what is missing. Maybe another orphaned device I had forgotten about. Another restart of HA and then again deconz.remove_orpharned_entries and then it removed the device.

So much better. But that need to restarting HA is a bit strange. And from a UI point of view, the Deconz integration (and integrations in general) really should have the buttons visible to do these actions. Having to go to a geeky developer tool is not very intuitive. You have to know. But that is a generic HA problem.

In any case - it is MUCH BETTER than before. At least I do not need to hack JSON files when I remove Deconz device and that I am very thankful for. The rest is constructive feedback

1 Like

The disabling works by just ignoring signalling from the library, the data already exist in the current structures. That device_refresh then doesn’t catch the new ones is a bug missed behavior, its probably because the service logic compares what the library knows before polling deconz manually rather than looking at what is registered in hass and not. Create an issue for this please.

Yes the removal of entities currently requires you to at the least reload the integration first, because there is no mechanism right now that updates the library based on things removed from deconz so if the library has seen the device it will be there until a reload.

The generic clean up button from the GUI is complex because there needs to be integration specific logic to handle special cases unique to each (or not) integration. Earlier the registries properly automatically removed orphaned devices when entities was removed (also on restart). But since the system needs to consider there are devices not belonging to entities (the service itself) you can’t take this general approach if you want to cover all cases.

I haven’t gotten much traction yet on exposing this per integration, I will return to this topic since I need to make sure this works properly with UniFi as well, I might talk more directly to Bram or Paulus about it, I know dmulcahey saw the relevance in implementing support for ZHA at least.

Thanks for the feedback <3 !

1 Like

Why don’t we still have no integrated method of deleting devices from an integration. I am using the mikrotik integration and it added numerous (undesired) devices and entities when using auto discovery (now turned off to avoid further mayhem).

I have now deleted 6 times a number of entries (devices and entities) from both core.device_registry and core.entities_registry manually and even deleted all but one (in use) from known_devices.yaml. On HA restart these device are added back in again. This is a PEST if even manual deletion doesn’t work anymore.

Can somebody explain why even after manual deleting entries from device and entities registry they magically reappear and when are we going to have a comprehensive way of deleting unwanted devices.

1 Like

So the moral is post an issue on github, or better still, a PR :slight_smile: