Logo Wael's Digital Garden

Home Assistant remove all rtl_433 devices

Home Assistant remove all rtl_433 devices#

Home assistant does not have a way to mass delete devices; I want to delete all rtl_433 devices (there are many of them).

Code#

async function deleteDevices(manufacturer_to_delete) {
    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["manufacturer"] === manufacturer_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("rtl_433");

Resources#