[SOLVED] Automatic creation of item when thing channel is added

I’ve noticed that, when adding channels to an MQTT thing (using PaperUI), sometimes an item is created automatically (and linked) and sometimes I need to create the item manually and manually link it to the channel. The automatically created items do not have a delete (trash can icon) option next to them in the item list, whereas the ones I had to create manually do have a delete option. Simple mode is disabled in all cases (I have never enabled simple mode on this instance of OpenHAB).

This doesn’t seem to affect functionality, but it’s bothering me that the behavior is intermittent. Any ideas why this would be?

1 Like

What version of OH and the binding (if different)?

OH and MQTT are both version 2.4.0.

I know there have been many bug fixes to the MQTT 2 binding since 2.4. Try upgrading to the 2.5 Milestone 1 release and see if the problem persists.

Okay, I upgraded to 2.5.0.M1. The items are still there and in their respective states (i.e. the trash icon is missing from the ones that were automatically created).

I’ll try to get another one to automatically create, but it’s only happened a handful of times so it may be hard to reproduce.

Question: Is it expected that the item should be created automatically or manually? If it’s expected that I should have to manually create the item, should I just delete and create the channels associated with the items that don’t have the trash icon? I know if I delete the channel and restart openhab the items that were automatically created will be removed…so I could clear them out that way.

1 Like

It should not be creating the Items automatically if you do not have Simple mode turned on.

To delete the automatically created ones I’d recommend stopping OH and editing the JSONDB files to first remove the Links from the Links file and then remove the Items from the Items file. Just removing the Channel should not cause the Item to be deleted.

Only edit the JSONDB files when OH is not running.

FYI, I was able to reproduce it again on 2.5.0.M1. I haven’t been able to figure out what steps are required to reproduce.

I’ve been able to delete the automatically created items with this process…

  1. Delete the channel under the thing. This does not automatically delete the item.
  2. Restart OpenHAB. When OpenHAB starts up, it seems to prune out the unlinked items.

Does that process make sense, or do you think I should edit the JSONDB files? I don’t want to leave any remnants behind, but I’m also not sure I won’t screw something up by editing those files by hand.

Check to see if those Items are still in the DB. OH creates a backup of those files quite frequently. But if you are worried, create a backup yourself before editing. If you mess something up you are just one file copy and OH restart away from being back to where you started. It’s pretty low risk.

1 Like

Okay, it looks like I did have a bunch of orphaned entries in the org.eclipse.smarthome.core.thing.link.ItemChannelLink.json file. I was doing a bunch of deleting and creating of things, channels and items as I’m trying to learn the PaperUI…so maybe an orphan entry in that file was the source of my problem. Hopefully the 2.5.0.M1 release has some fixes for those orphans. I’ll mark this one as solved for now, and re-open if I see another instance like this. Thanks again for your help!