Best and simplest option for persisting dates with historical values

Right now I have rrd4j for numeric values, and MapDB for dates, but I’d like historical values for dates too. I’m not clear which of the persistence options will do this, and what difficulty is involved in setting them up. Some of the docs I’ve found date back quite a few years.

What’s the current recommendation?

I’d say any other supported database would be fine ( for example influxDB). MapDB doesn’t work since it keeps the last setting only, rrd4j doesn’t work since it’s special and can handle numericals only.
What makes you think documentation is outdated, did you look here? Use the lefthand sidebar and look for Data Persistence.

What are you trying to persist with “historical dates”? The persistence service of openHAB would persist a date with the date it was persisted, is that what you are looking for?

You might clarify that a bit - I’m reading as you want to store data values that just happen to represent some datetime but are unrelated to the recorded timestamp.

Well, only the docs I found. I ended up on a GitHub page from 2016. That does, indeed, look more up-to-date.

Yes, I have lots of date items (for example: when a sensor last received a reading), and I’d like to be able to go back and check previous values.

From what I can see, all the other options are a bit more involved than rrd4j and MapDB.

Hi @LordLiverpool,

For my date related items I’ve been using the MySQL/MariaDb persistence for a while now. It all depends on what you want to do next with the information. I still haven’t decided what I’m going to do with the data. I also track both mine and my wife’s car location, by storing the GPS details. My intention with this data is check traffic against the location the car has been to each day. So in the morning I can announce the expected journey time to the said destination on a given day.

I hope that helps.



1 Like

You seem to missunderstand how the persistence service of openHAB is working ( for any implemented database). This service stores the data always WITH the time of storage.
I’d say you simply need a numerical item (temperature) persisted. All values will have a time with it.
If you want to keep the EXACT data over the whole time ( and no data consolidation) rrd4j is not your candidate. However are you really interested in the exact values from “long ago”? If not I’d suggest rrd4j!

You can interrogate persistence about when a sensor last changed, without storing datetime. It’ll use the built in record time stamping.
You can ask what state the sensor was last Tuesday.
More difficult is asking what the last change before last Tuesday was - the information is there, but there are no integrated methods to query it.

The “last update” item for a sensor reading was just one example. I have other date-time values that I need to be able to see the history of, for example the last time an alert was issued, a date-time stamp sent from the PC indicating when it was last used, or a date-time set for a particular state to end.

I understand that one of the big advantages of rrd4j is that it automatically limits the size of the database. How does MariaDb compare?

I found instructions for setting it up here - not too bad.

I think there was an update that allows rrd4j to support dates. At it’s lowest level a date time is just the number of milliseconds since epoch (1970-01-01T00:00:00.000Z) which rrd4j can easily handle. However, rrd4j’s decimation/compression process might not be the right choice for date time data itself.

1 Like

Is that in a recent build of openHab?

It was pretty soon after OH 3.0 was released so it should be in 3.1, definitely in the milestone release.

I migth not get it correctly but how are you going to handle/store all those on a single openHAB item. IMHO such diverse events are commonly stored in log-files.

I’m not sure I follow. I have many date-time items.

I have openHAB 3.1.0-1, so I’ll give it a test. Thanks!

“it” being rrd4j?
Beware -

Under many circumstances, rrd4j will give you a single ‘average’ of what was stored as two different datetimes, This is how the data compression gives the fixed table size.

1 Like

Hmm, that doesn’t sound so great.

If you really want to stay with rrd4j a custom setup with only one “archive” would give you a fixed size without any data compression.

1 Like

OK, I’ll look into it. First I’d better test whether it really does store date-time items.

I switched to influxDB since one year.
Works like a charm.
I can fully check & analyse the heating system parameters for instance.
And in openhab 3 this is great. Just put the field, define it in your persistence strategy and clicking on the field gives you automatically the graphs.

1 Like