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?

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: )