Bulk Remove Item/Things

Sorry to place this in off-topic…
And… sorry to have to ask this question (I DID search)
Is there a way to remove multiple Bluetooth and Network Items and things?
When I first setup OpenHAB2, I thought it would be cool to include my home network items (60 or so) and all the Bluetooth discoveries…
But now, when I’m adding a device, etc… I see all this “Junk” that I would prefer to NOT see.
I removed the Network and Bluetooth bindings… But I have to go in and MANUALLY remove all this stuff.
Can I access the OpenhabDB directly, etc to just remove all this junk?

You can do this using the console, see https://www.openhab.org/docs/administration/console.html. You can use the command “smarthome:items clear” to remove all items and “smarthome:things clear” to remove the things. This really removes EVERYTHING though, so be careful. There are also remove commands to only remove single things/items, see “help smarthome:items” or “help smarthome:things” for reference…

Awesome, Daniel!!
I’ll give it a shot.

This rule uses the REST API to do something similar. It wouldn’t take much to modify it to remove Things from another binding.

I’ll have to take a look at this. I see, or have not found a way, to use wildcards with openhab-cli.
For the record, these are not Zwave items, but residual when I decided to add a binding for Network and Bluetooth. (I would NOT do that IF I knew) :slight_smile:
I have a whole bunch of this and just want to get it outta there! :

network_pingdevice_10_10_10_250_online (Type=SwitchItem, State=NULL, Label=Online, Category=null)
network_pingdevice_10_10_10_21_online (Type=SwitchItem, State=NULL, Label=Online, Category=null)
network_pingdevice_10_10_10_250_latency (Type=NumberItem, State=NULL, Label=Latency (ms), Category=null)
network_servicedevice_10_10_10_31_80_lastseen (Type=DateTimeItem, State=NULL, Label=Last seen, Category=null)
network_servicedevice_10_10_10_90_80_online (Type=SwitchItem, State=NULL, Label=Online, Category=null)
network_servicedevice_10_10_10_90_80_latency (Type=NumberItem, State=NULL, Label=Latency (ms), Category=null)
network_servicedevice_10_10_10_90_80_lastseen (Type=DateTimeItem, State=NULL, Label=Last seen, Category=null)
I’ll let you know what I find that works the best for this
Thanks guys

Well, that’s a problem. It’s either clear all or remove one single. A possibility to send a wildcard string to remove would actually be quite handy.

Then I guess the alternatives left are either doing it manually or using a modified version of @5iver’s rule above.

Someday soon I was going to convert the rule to a shell script. When I do this, I’ll add a binding argument.

That would be nice! Maybe get it committed and added as one of the commands being called by openhab-cli?

Adding it as a Karaf command (and then including in the REST API) would be handy. Something like…

smarthome:things clear org.openhab.binding.network

Yep, that would be nice as well! Although in my opinion a possibility to do “smarthome:things remove zwave:device:*” would be even better, that way you could for example remove all things belonging to a specific controller and not another…

1 Like

I took a look on how this could be done. I found the code which does this, doesn’t feel like it would be rocket science to add another argument. Sadly I don’t have a clue on how I should try it out (recompile the bundle and get it into the system). Guess I’ll need to read into how this OSGi stuff (that I’ve mostly ignored up to now) really works…

I can do a list with the wildcard *…

How do you mean? “smarthome:things list” doesn’t take any arguments at all…

If I run this, it will return ONLY a result that begins with network
smarthome:items list network*

This will return only bluetooth devices:
smarthome:items list blue*

Silly that this wildcard doesn’t allow for removing…
Sorry, not enough coffee yet this morning… moving a little slow

Ah, you’re right! smarthome:items list takes a pattern argument although smarthome:things list doesn’t. I thought the two were consistent :slight_smile:

Sorry Daniel… I didn’t want you to be the one responsible for this…haha
But, did you look at this any more after this last thread?
I’ve been holding off bulk deleting my “stuff” (Plus haven’t had the time)

Not really, no… I thought this should be a nice little project for myself to learn how to contribute code, but then I kinda started doing a lot of other stuff instead. I still may give it a shot, but don’t hold your breath :wink:

Haha… understood!

Has anyone done this to remove things with a certain status in PaperUI? Ie remove all things UNINITALISED

i somehow lost all my things added with the GUI. therefore i want to add my things now via text-config in .things. i also want to get rid of all the items.

just to be sure.
if i delete all items like mentioned above, i will still have my text-config items afterwards, correct ?