OH3: Unlinking an item from item side possible?

Hi,
simple question: Is it possible to unlink the relationship between a channel and an item from ITEM side as well? Or is unlinking only possible from channel side?

Thank you,
Boby

I just delete the link from the text definition so I know it is possible.
Whether the Main UI permits it, I cannot say. The REST API also permits unlinking.

1 Like

Thanks, text definition is not accessible anymore as soon as you define the items via the GUI.
But the REST API sounds promising - I’ll have a look at it, thanks!

But I did not assume how you created the Item and you did not say so I just provided one answer I doubt the REST API will do what you wish.

My problem is: I created database-based items (by copy/paste the definion) at a moment where the .things files (file-based) were still in place and used. Later I created the things in the GUI and removed the .things file, but the items are still linked to the channels/items of the textual definition (in the meantime not visible anymore). Therefore I can’t go to the thing and unlink the channel, because it’s not there anymore. But the item is still somehow linked to the “old” channel…

Why did you not state that in your first post??

I wasn’t aware this is crucial, sorry.

Like everything else in OH there are multiple ways to do things.

You have to be careful when comparing text .items and the UI for stuff like this. When you have .items files, every time the .items file is loaded, all the Items and Links that were previously defined get deleted and then brand new ones created.

When operating through the UI you are actually modifying stuff in place.

The distinction is important because while it appears certain things like this should be easy or possible when using .items files, that’s really a side effect of the fact that the Items are deleted and recreated on every change.

Yes. Go to the Item, click on the Channel Link (bottom of the page) which will bring up the same Link page as you get when you click on the linked Item from the Channel side. From there you can unlink.

Notice that you can also create a Link from the Item in this way too.

1 Like

@rlkoshak, unfortunately, the section “Channel Links” doesn’t show up in my case. It shows up, when the thing and the item were defined via GUI. But it doesn’t show when you accidentally mixed up text-based things and database-based items like I did unknowingly.

I was not comparing. The original post did not state anything about how their Items were created.

If Items are defined in. items files then the items are read only in the GUI. So if course you can’t change anything from the Item page.

I know but you mentioned something was easy which only appears to be easy because of how text based items get created and destroyed.

What really happened:

  1. I migrated using the openHABian procedure
    → everything was in files and read only in the GUI
  2. Then I renamed the .items file to .items_old
  3. Then I created the items by copy/paste (“from textual definition”) in the database world
  4. Afterwards I renamed .things file to .things_old and started to create things on database level as well

But now my items are linked to things which aren’t available anymore, at least not in the GUI. Under the hood they still seem to be there and active because the items still get values although they haven’t been linked to the new things.

That’s the situation I’m in and that’s why I asked if it’s possible, to release the link from item side. And currently the answer is “no”.

Is there a way to kill this link between channels and items on console level?

I have so many problems after migrating from 2.5 to 3.0 that I decided to completely set up a new instance from the scratch. Maybe I’m the only one, but I cannot really recommend to use the migration path at it may lead to many, many problems - especially when you’re not extremely deep into the system.

OK, in that case what you’ll need to do is stop openHAB and edit the links JSONDB file to remove the links. The file is in the userdata/JSONDB folder. When you start it again they will be gone.

1 Like

I hope it is ok to still post to this question, as I have a similar question.

I migrated from 2.5 with a “mixed” scenario, i.e. I defined most things in UI, but items in config files (so all items appear with a lock-sign).

Now for example, I went to one of my Shelly-Things and clicked “Unlink all items” which worked. If I want to relink it to an item, I open the channel, select “Existing item” but the list of items is empty.

If I create an item via frontend, it is visible and I can link it.

Now this is very confusing to me, is there a way to “transfer” textual items into the database, or do I have to create them all by hand? And why textual items are not available when linking a channel via frontend?

I experienced the same issue where only a small subset of my text file defined Items showed in the “link existing items”. I submitted a bug report on GitHub. For most existing items you can link them by selecting the item from Items and then link to a thing a channel rather than selecting a thing channel an attempting to link an existing item.

I don’t think this is right and agree it looks like a bug. Links are stored independently from the Item’s and the Things. So you should be able to create them even if you Items are in. items files. However, those Items should not have the link defined in the .items files if that’s the way you want to go. Pick decimating the links one way or the other.

Yes, when you click the icon to add an Item there is an option to “add items from textual definition”… You can paste in a .items file’s contents and add them that way. Be sure to remove the .items files afterword.

I started it doing that but found just using Add equipment from Thing on the model age to be faster and less work.

Theoretically I could see that it wouldn’t show any items that already define a link in the. items files. In that case what’s in there file will override what you do in the UI anyway so it really isn’t possible to have links defined both ways on the same item.

It was a deliberate decision of mine to discourage adding links in the UI to items that are not editable in the UI: [MainUI] Channel links have to be locked when defined in conf files · Issue #413 · openhab/openhab-webui · GitHub
The reason is that it’s not possible to know whether or not the link itself is editable or not, or can be deleted. So if you’re defining your items in a file you can probably link them there too and not use the UI.

1 Like