Control over things' storage

Hello,

So far i used discovery to create Things. Looking at files on my linux machines :

  • i have nothing under /etc/openhab2/things which is normal since i didn’t write things by myself
  • i found things inside /var/lib/openhab2/jsondb/org.eclipse.smarthome.core.thing.Thing.json

What i want is to get control of those Things for source control , backup & sharing accross multiple computers reasons. So i want to move them under /etc/openhab2/things . Later , I would create new things manually directly under /etc/… by mimicing existings ones.

So for now, can i just “move” (reformat) the Things from one file to another and be sure everything will be working ? Are Things created by discovery also having footprint somewhere else that i’d need to clean (seems some kind of databases are also used) ?

To be more complete, if i focus on “network” things, the content of the .json file is far more complete than the doc (http://docs.openhab.org/addons/bindings/network/readme.html) says. From what i see, only the “configuration” block has to be put in the /etc/… file . But what should i do with the rest of the json (label, channels, uid, thingTypeUID,…) ?

Other thoughts ?
Tx for your help,
P.

If you want to configuration control the automatically discovered Things, you need to preserve the entier JSON DB as it exists in /var/lib/openhab2/jsondb.

You can create a copy of it under your /etc/openhab2 folder if you want, just don’t change it and don’t name it .things.

The JSON DB is what OH operates under and it uses a significantly different format than .things Items. Not all bindings have a documented way to represent Things in .things files (zwave being the primary one). So it is not clear you can easily figure out the correct information and format to move those Items to a .things file.

And beyond that you have the issue that some bindings may have a slightly different naming format and configuration if you reset up the binding. For example, the zwave binding has a Serial device Thing that represents the controller. If you reset up your zwave binding, unless you manually configure it as such, this Serial device will not have the same Thing. If you pay attention you will notice that the Zwave device Thing ID includes the Serial device’s ID as part of it. Consequently your Things may become disconnected unless you are certain to create this Serial device with the same ID.

I beleive all of this gets saved and preserved in the JSON DB. So I highly recommend if you want to CM control this sort of thing, just CM your JSON DB. If it is a problem of having them in two widely different folders, move the JSON DB folder to the /etc folder and create a softlink to it in /var/lib/openhab2.

You will probably want to do this with your /var/lib/openhab2/etc folder as well as that is where you might make some logging configuration changes that you may want to persist.