[OH3] Switch between JSONDB and text files

Hi there,

currently I set up a second OH based on OH3. With OH2 I am using textual configuration of things, items, sitemaps, etc. for

  • my system is approx. 100% KNX and there is almost broad autosensing on the KNX bus (or did I miss a point)
  • text files are very resilient and future proof
  • text files are very easy (well sort of;-) to read with plain tools (compared to any DB)
  • text files are easy to version and compare (I know, that rlkoshak said, this could be done through the UI as well, alas I don’t know how)
  • I use the same CSV file as a starting point for KNX programming as well as OH config files

Now, using the OH3 UI during the first steps, I entered test things and so on using the nice UI. But in the end I would like to see the outcome in text files to compare and study textual representation.

How can I easily switch and convert between JSONDB and text files? Can I “export” the DB in text config files and vice versa?

If this is not the way to go, I think (maybe regret saying it now) I won’t mind using JSON instead of good old plain text. A little more of “everything that goes with it”, but OK.

Kind regards!

You should be able to use your OH2 text files with OH3 of you prefer text files.

Hi Bruce,

thank you for answering. I am pretty aware of this fact and should ask more precisely:
how can I convert from text into JSONDB and vice versa. Detour via JSON is OK.

I understand that things (in a world wide meaning, not OH) entered in the UI will end up in a JSONDB. As one can still use textual config, I understand, that the text format hasn’t changed and there are no new text files compared to OH2.

Is there any advantage to either use JSONDB or text files? Will text files be continued in the future? Maybe I will be more comfortable with JSON and the REST API, because I can put attribute names next to their value rather than to rely on positioning and spaces / tabs?

In the end I need to configure OH by scripting from simple text lists - my aforementioned CSV files.

You cannot. Unless you develop a tool to do that yourself.
There’s a GUI option in ‘Developer Tools’ to bulk load item files (not sure if it also takes things files),
but there is no software to write it back in Xtext format.

See Configuration | openHAB

Hi Markus,

thank you for pointing this out and the link. Is this true for the REST-API also? Meaning: isn’t it possible to add / change / delete all config (things, items, models, …) via REST-API?

Otherwise it is hard to understand the recommendation in the docs to use the Main UI. If you share the creation of items / functionality between a couple of persons and try to automate the linking to things and channels, I can not see how to get far with the UI.

Why? You have to come up with a solution to the same coordination issues , no matter if you use the UI or text input.
Text still works exactly like it has in 2.X so what’s wrong with that? Yes you can also use the API (although I’m not familiar with that so can’t tell what’s working and what’s not).

The text file to version control and compare will be in $OH_USERDATA/jsondb. It’s text so diff, grep, and all that sort of stuff works.

Unfortunately you pretty much have to start over. There is no import/export to go between the two right now except for the ability to import Items.

It does not.

Yes, those are all ways to interact with JSONDB. In fact that’s what the UIs use to interact with OH to create and edit things.

That is a rare (not unheard of, just rare). And if that is the case, I would encourage you to use text configs. The vast majority of users though are maintaining one set of configs for one openHAB instance.

As far as I’m aware there are no problems with the REST API and if you can do it through a UI you can do it through the REST API directly since that’s what the UIs use too.

Thanx. That gives me something to play with.