await (async (garbage_id, actually_delete=false) => { const hass = document.querySelector("home-assistant").hass; const devices = await hass.callWS({type: "config/device_registry/list"}); for (const device of devices) { if (device.area_id !== garbage_id) continue; try { if (actually_delete) { await hass.callWS({ type:"config/device_registry/remove_config_entry", device_id: device.id, config_entry_id: device.primary_config_entry, }); } console.log( 'Delete device:', device.name_by_user || device.name, device.manufacturer, device.model, ); } catch (error) { console.error(`Failed to delete device ${device.id}:`, error); } } })( // Change this to the ID of your garbage area "eb89d996b3487d2c80204b9cc861e99a", // When this is `false` the code will just list the devices it would // have deleted, but not actually delete them. You should leave this // as `false` the first time, review the output, then run it again // with this changed to `true` when you want to actually delete the // devices. false, );