WTH Can’t I mass-delete (non-existent) devices?

For unknown reasons, I ended up with hundreds of RM174RF sensors added to Home Assistant (via RFXtrx integration) - we’re talking hundreds of Smoke Detector devices, consisting of more than 2000 entities.

Currently there is no way to mass-delete these non-exists devices. When I try to delete one, I get:

Device / service not found

The best I can do at the moment is to click each device in turn, and Hide it. This is neither practical nor correct.

It would be great if the UI would allow me to select multiple devices and Hide / Detete / Force Delete them.
See Some entities not visible in RFXCOM RFXtrx

THANK YOU!

I run an SDR with rtl_433 streaming over MQTT into Home Assistant. It allows me to read from all of my utility meters, as well as snoop around the neighborhood’s RF signals (I found out my neighbors have some great outdoor temperature sensors I can read from).
It’s a really good setup, but it does result in a lot of devices getting created by the MQTT integration. Unfortunately, even without the MQTT retain flag, Home Assistant still retains the device. So, I literally have hundreds of non-existent devices listed in my instance… and I can’t mass delete them. It’s really annoying.

+1 to this WTH.

5 Likes

This seems to be a recurring WTH: WTH Delete devices from GUI from 2020 for example

I would be very interested on your setup. I have multiple 433MHz devices, would be interesting to ingest it into HA.

1 Like

i agree manually hiding these sensors by hand is painful and there needs to be a better way of deleting unwanted/unneeded sensors

Yeah, running OpenMQTTGateway in an ESP32. I have thousands of ghost devices which cannot be deleted. Also losing the actual devices in the mess when they get re-added with an incrementing number tacked onto the entity ID and HA keeps using the old ID and doesn’t see the device any more. Pretty much useless.

Because this issue has not been fixed yet, I have created a Python script that can bulk remove devices based upon a given field. It helped me remove all of my useless devices and get my device registry cleaned up.

1 Like

While developing stuff in ESPHome I often end up with orphaned entities I can’t delete. Sometimes I have to reboot for them to be deletable, in other cases I have to remove the esp device and add it back.

Could you provide an example (for the clueless) of how to use this?

1 Like

EDIT: Apparently this script can’t remove fields with null as the value

EDIT 2: I want to remove all devices created by browser_mod, so I entered these as second and third parameter: identifiers browser_mod, the created file will contain all existing devices except those created by browser_mod

After looking at the source code and tried a couple times, this is what I did:

  • using FIle Editor Add-On I created a file in python_scripts folder, I named it bulk_remove_devices.py like the original file. I just copy and paste the code and save the file
  • then still from File Editor Add-On, from the gear pull down menu I clicked Execute Shell Command menu
  • on the popup window I entered this command:
/usr/bin/python3 /config/python_scripts/bulk_remove_devices.py
  • then I add these three parameters after the .py above, add space in between: /config/.storage/core.device_registry <field_name> <field_value>
  • replace the <field_name> and <field_value> with values that you want to remove. For me, I want to remove all devices which have manufacturer field equal to null
  • So the whole command line:
/usr/bin/python3 /config/python_scripts/bulk_remove_devices.py /config/.storage/core.device_registry manufacturer null
  • press Execute button to run the script and hope for the best :grin:

Cheers!

would you mind to explain how to read multiple devices with rtl_433?
TIA

Thanks for sharing this script but I think for me the script isn’t working because the values change too much every added device is added as a smoke_detector and then with a different number. It would be nice if there would be a more simple solution, so that’s why I upvoted this topic.

1 Like

Hi, thought I’d share this here too:

1 Like

@pdecat s code solved my issue in a minute or two, highly recommend it!

Also, thank you again!

1 Like

i´m in the same boat, with unwanted 433 devices flooding HA.
it would be good to implement multiple choice buttons in the list to allow mass selections / operations.
(and my be deletions should go to a “trashbin” first before final purge :wink: )

When I execute the code below in the console I got an error
" VM404:1 Uncaught SyntaxError: Unexpected identifier ‘Smoke’"

Can someone help me to solve this problem?

async function deleteDevices(RM174RF Smoke Detector) {
let hass = document.querySelector(“home-assistant”).hass;
let message = { type: “config/device_registry/list” };
let count = 0;

await hass.callWS(message).then(async(response) => {
    for (let i = 0; i < response.length; i++) {
        device = response[i];
        if (device["RM174RF Smoke Detector"] === model_to_delete) {
            await hass.callWS({
                "type":"config/device_registry/remove_config_entry",
                "device_id": device["id"],
                "config_entry_id": device["config_entries"][0],
            }).then((response) => {
                console.log(`Deleted device ${JSON.stringify(device)}`);
                count++;
            })
        }
    }
    console.log(`Deleted ${count} devices`);
})

}
await deleteDevices(“RM174RF Smoke Detector”);

VM404:1 Uncaught SyntaxError: Unexpected identifier ‘Smoke’

WTH…just realized that’s not possible as I had to delete 150+ devices :frowning: the first time I’m really disappointed with HA

I’ll add another WTH. I have 650 rtl_433 devices that I need to purge. I don’t see that this would be difficult to add to the UI as there is a list to select devices in bulk, but no way to delete the selected ones, but you can change their area and whatnot. Most people probably don’t need to delete this many entities at once, but those of us that need to, it’s a serious problem.

Echo the need to be able to select-multiple devices/entities and delete (or take any mass action).

I have worked around this by using a mouse-click macro recorder to record myself deleting a single device and then repeating the action 10, 50, 100 times – but it’s a clunky hacky solution and there should be something more elegant baked into the UI.

1 Like

Just another person chiming in with the need for a mass delete option. Moved continents and had to swap anything not battery operated for the local voltage/plug standard. Thankfully, only about 9 devices for me, but now I’m concerned if any device ever populates the hundreds of devices previous commenters are mentioning.