[SOLVED] How to remove a thing itel channel link manually from Paper UI json file?

I’m trying to remove an orphan thing item link from the org.eclipse.smarthome.core.thing.link.ItemChannelLink.json file in the /var/lib/openhab2/jsondb/ directory.

Item and thing were created via Paper UI and trhough config changes have changed and are named differently, however something went wrong in the paper UI removal phase of these and I now notice in the log files this link is created during startup process.

It doesn’t really bother but just want to clean it up as a orphan link doesn’t add any value, can only lead to errors and confusion.

I tried editing the org.eclipse.smarthome.core.thing.link.ItemChannelLink.json and removing all content so there is only the open close brackets left but for some reason when doing so it’s re-created during reboot. No clue how this is possible also tried clearing cahe and temp folder but it’s still re-created during reboot when I erase the org.eclipse.smarthome.core.thing.link.ItemChannelLink.json content

Anyone any idea how it’s what is re-creating the link item after manual editing the json file? and more importantly how I can manually remove the link.

The content of the file is

{
“A44IN -\u003e globalcache:itachFlex:7c4b1a24:sl-m1#c1-direct”: {
“class”: “org.eclipse.smarthome.core.thing.link.ItemChannelLink”,
“value”: {
“channelUID”: {
“segments”: [
“globalcache”,
“itachFlex”,
“7c4b1a24”,
“sl-m1#c1-direct”
]
},
“itemName”: “A44IN”
}
}
}

and when editing the file manually I change it to

{}

I would first try to remove the link through the Karaf console.

One thing you haven’t said is whether you stopped OH before trying to edit this file. You should always stop OH when doing so. If you are not stopping OH first, I suspect that OH is dumping the links it has in memory to the JSONDB during exiting. The JSAONDB isn’t like the other config files where OH continuously watches it for updates to load. It is primarily used as a way to keep its state during a reboot.

If you are stoping OH before editing the file I’m going to guess that A44IN still exists somewhere inside OH and is still configured with a link. Grep for that in the jsondb folder and your items folder just to make sure.

1 Like

thanks a lot stopping OH service and manually changing link file indeed worked. Wasn’t aware the json DB was only used at startup and reboot. BTW there was no A44IN item any more so it was a real orphan link :slight_smile:

Stupid me, didn’t think about that easy way to remove orphan links. Thanks for that hint👍

@opus Jurgen I can confirm stopping OH and just deleting the link lines from the json file works as well.

…and using the
smarthome:links removeChannelLink <itemName> <thingUID>
on the Karaf console works WITHOUT stopping OH!

OK, cool something new I learned. I never use this Karaf console, maybe I should start looking into that more actively