Replacement of mapdb by jsondb

I did that, caused no problems (because it is not used anymore after the update)

/userdata/mapdb

Donā€™t delete /userdata/persistence/mapdb if you are using mapdb as a persistence service!

No, not necessary.

Hello!

Thank you for your help. Iā€™m using MapDB as primary persistence service, so, your insight about folder locations is really helpful.

Best regards,
Davor

I didnā€™t delete the database, no issues either.

@Mherwege I donā€™t think the issue has to do with JSON DB. Although I have the same issue, and thought it was resolved with a newer version of OH, it hasnā€™t. Iā€™m also seeing the issue for the LIFX fadetime configuration property (on restarts) regardless of whether .0 is appended in org.eclipse.smarthome.core.thing.Thing.json.

In PR #2633 a similar issue is addressed. Iā€™ve done some analysis on this yesterday, see the last post of PR #2633. Perhaps @Kai knows who is familiar with the Configuration logic and when the properties of a Configuration should be normalized to integers?

The only caveat I have with json is it doesnā€™t allow comments.

If the JSON is deserialized in such a way that unknown members are ignored, you could add your own bogus members to serve as comments! But I donā€™t know if the JSON is deserialized so as to ignore unknown members.

True, but that wouldnā€™t all you to put comments in at the end of a line.
I think if someone were to mod the code on the deserializer side, it would
be useful just to add in code to ignore comments.

The comments would all be lost on re-serialization, most likely. I doubt there would be a satisfying ā€œbridgeā€ between database-stored configuration vs. properties-file based configuration. But openHAB at least gives us a choice!

Iā€™m no expert on performance, but what about XML?

It would basically have the same limits as the JSON storage for supporting annotation with comments ā€“ the (de)serializer would have to read and write them in the correct places, and I doubt that would be good for resource consumption (processor, memory). Thereā€™s a lot you can do in your own .things, .items, .cfg files, which all support comments.

@Mherwege @pathec
Today @chris fixed with PR #2685 the issue where integer configuration values are returned with a .0 decimal. After testing it, my issue seems to be resolved with it! :slight_smile:

What database should I us for my ā€œrestoreAtStartupā€ items? Json or mapdb?

You may want to search for some discussions on this in this forum Rich (@rlkoshak) and others have posted quite a bit on that and recommend mapDB for a variety of reasons.

So the recomendation is JsonDB for things and items (not a chooise anymoore), mapdb for ā€œrestoreAtStartupā€, rrd4j for rules and graphs (and maybe MySQL for storage of values for external data consumers).

:+1:
for graphs there is also grafana and influxDB; but to make that work, you will need to read up extensively in the forum and here: InfluxDB+Grafana persistence and graphing

Yes, Grafana creates really nice graphs. Unfortunately you can only run it on Linux if I understand the installation manual correctly. As I am running my OH systems on Windows I think it is a too steep learning curve for me and to much work.

In fact, you can use any db for different usecases, but there are ups and downs:

  • influxdb: you will have to learn how to use, (yes, there is a windows version), database is growing, you have to maintain (if not purging old data via configuration), only few tools for using the data outside influxdb.

  • (my)sql (or something similar): even more complex than influxdb, althoughā€¦ maybe you already have an installation and can just use it :wink: database is growing and you have to maintain, but there are way more tools to use data, sql is very common, so maybe you could even produce your own tool if needed.

  • rrd4j: database is not growing, but the data is the less precise, the older the data is, you can only store numbers, no strings, no dates, no time, no boolean (but openhab does boolean as 1 and 0).

  • mapdb: only the last state is persisted, so no historical data.

So, if you want to persist every item just to restoreOnStartup, mapdb would perfectly fit. If you only want a bunch of items to restoreOnStartup (and they are already persisted in another database), there is no need for mapdb.
If you want graphs and do not have much space for data, donā€™t want to think about maintaining, use rrd4j.
If the default graphs do not fit (poor graphic qualityā€¦) you would have to use grafana,which fits perfectly to influxdb.
If you need very precise data over years and years, or string data to be persisted, you will have to use a sql-like-database.

Just to be clear, JSONDB is only used by PaperUI and Habmin. You cannot use it to persist states of Items and whether or not to use it isnā€™t a choice you can make.

Thanks for the clarification.

Is it possible or wise to use (only) MySql for all kind of persistence (restoreOnStartup, historical data for rules, historical data for graphs and provider to outside systems)? As I am used to work with MySql as a developer and already have an MySql server up and running it would be nice to just have one place to persist my data.

Would it be possible to use Grafana with MySql?

I personally prefer to only use an external DB for historic data and charting and keep restorOnStartup in MapDB. MapDB is fast and never grows. But there is nothing preventing you from using MySQL for this. You will want to periodically go in and clear out the junk though.

Gradana does not support MySQL out of the box. I did find a presentation from Instagram about how they built an adapter but I did not find any code anywhere.

I too am more familiar with MySQL but Influx is very light weight (doesnā€™t use enough resources to appear in the list when I run top) and you can learn everything you need to know to use it with OH in an couple hours.