[SOLVED] Move thing configuration from UI to files

Dear,

when starting playing around with OpenHab2 (2.2.0, Build #1098), I configured my items via PaperUI. After reading a lot, I switched to HabMin. And now, I realise that the “best” way for me is rather to add the thing via UI and to configure the items via configuration file.
Which would be the best approach to move the UI-configured items to the file?
I am asking to prevent doublettes in the logfile.

Thank you for sharing your thoughts,
best regards,

Connor

I have also taken that route.

That did not go well for me.(the first time) I have some duplicate items when I look in my log files and they are ignored.
In theory I would say that deleting the items in paper UI and recreating them in an item file is sufficient.

hopefully someone else has good tips

You can mix and match in terms of creating things in PaperUI and Things or Items files. So best is to pick something within your existing setup and then migrate that.

Just pick on Item and try and put that in a file. You’ll get a duplicate warning if you leave it in PaperUI but obviously you can just use PaperUI to delete the original :slight_smile:

The PaperUI creates text based JSON database files in the main installation folder something like openhab2/jsondb and you can read those in any text editor (be careful not to modify unless you know what you are doing and OH isn’t running). Reading them you should be able to see what PaperUI did and translate it to what you need in your Thing/Item file.

1 Like

Would it be possible for a script to parse the jsondb files from a configured paperui system and generate things and items files so the the jsondb data can be dumped?

1 Like

very good answer!

I am using the jsonDB only for my Z-Wave Things (because I am too lazy to transition to *.thing files) and for my Homekit settings (another type of stored config using the jsonDB). For everything else, I use flat config files since I find them easier to manage.

one minor comment: the *.json files are being read only once (when OH2 starts up), so if you modify them manually (not recommended), you need to restart OH2 to re-read them.

Also, you can see what PaperUI has created by using the openHAB console and the following commands:

items list
links list
things list

To move from a PaperUI defined (and jsonDB stored) Item: First use PaperUI to break (delete) the Link to the Thing Channel, then delete the Item (turn off Simple Linking Mode to see the Items), then create a new *.items file and define the Item and it’s “connection” (link) to the proper Thing Channel.

I would say that it is possible, but I don’t think that anyone would be willing to create such script due to the bad “cost/benefit” ratio :slight_smile: It’s not too much trouble to “transition” from jsonDB to *.items files and you will learn ALOT about openHAB2 if you go through this process (yes, I must admit that the learning curve is steep… :stuck_out_tongue:)

2 Likes

Dear,

thank you for your continued support.
I will try it as you suggested,
Just a further question from my side: I tried to remove an item using the approach you suggested here.
Unfortunately, this item is not really removed, but occurs in the jsondb file after a restart.

Is there any approach to remove it in any other way?

Thank you in advance,
best regards,

Connor

Do you see two of the same Item listed in the PaperUI? Are there any errors/warnings in the openhab.log file during startup?

As @Dim said you should remove any channel links to Things via PaperUI first then delete the Item. If you click delete in PaperUI on a file based configuration Item it will not delete it so you are safe to try either if both are listed and you’re not sure which one is which. PaperUI will see and display all file based Things, Items and Channels but any editing of them will fail in PaperUI.

As a last resort you can edit the jsonDB files by hand, make sure OH is not running, you’ve got a backup etc as it does carry a serious health warning and you need to be very confident in your skills and editing.

Dear,

thank you for your ongoing support. I finally decided to take my configuration files so far and to rebuild everything from scratch - which finally wasn’t such a bad thing to do.
The main reason was that I searched any file and setting, but was unable to track down the doublettes.
So I chose the easiest way - which is working for me so far.

Once again, thank you for your supprt,
best regards,

Connor

If you’re interested in exporting all your items to the textual form, please find my little tool that gets all your Items from REST API and serializes them nicely.

Note that this is just a quick and dirty proof of concept! :slight_smile:

4 Likes