Replacement of mapdb by jsondb

(SiHui) #36

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


Don’t delete /userdata/persistence/mapdb if you are using mapdb as a persistence service!

No, not necessary.

(davorf) #37


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

Best regards,

(Matthew Valeri) #38

I didn’t delete the database, no issues either.

(Wouter Born) #39

@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?

(John Chiasson) #40

The only caveat I have with json is it doesn’t allow comments.

(John Cocula) #41

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.

(John Chiasson) #42

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.

(John Cocula) #43

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!

(John Chiasson) #44

I’m no expert on performance, but what about XML?

(John Cocula) #45

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.

Apt upgrade or brand new install?
(Wouter Born) #46

@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:

(Magnus) #47

What database should I us for my “restoreAtStartup” items? Json or mapdb?

(lipp_markus) #48

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.

(Magnus) #49

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).

(lipp_markus) #50

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

(Magnus) #51

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.

(Udo Hartmann) #52

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.

(Rich Koshak) #53

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.

(Magnus) #54

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?

(Rich Koshak) #55

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.