RRD4J Persistence does not (re-)store integer values


it seems like the RRD4J persistence service always restore number values as double, but not as integer, e.g. the Item.state is: 1, RRD4J internally stores it as 1.0 and returns 1.0 when using “restoreOnStartup” as system start.

This is causing a problem when using mappings in a sitemap, because none of the mappings matches anymore:

Number SET_Scene_Autoswitching “Szenen-Automatik”

SET_Scene_Autoswitching : strategy = everyChange, everyMinute, restoreOnStartup

Selection item=SET_Scene_Autoswitching mappings=[0=“Aus”, 1=“An”, 2=“Feiertag”]

After a system restart, SET_Scene_Autoswitching is e.g. set to 1.0, and therefore no value is highlighted for this item.

This behaviour is different in Openhab 1.x, which stores the value as integer
2019-01-30 15:28:36.834 [DEBUG] [.p.internal.PersistenceManager] - Restored item state from ‘30-Jan-2019 15:27:00’ for item ‘SET_Scene_Autoswitching’ -> ‘1’

Is this a desired behaviour or rather a bug?

RRD is the wrong persistence service for that task (it averages over a defined period). Use MapDB or any other option.

MapDB is the one and only database that is build for that task!
This database saves ONLY the last state of every persisted item, therefore using it for every item is possible.
Any other database does save either each state of the persisted item or ( as in the case of rrd4j) all states over a fixed period,. Doing such for all items would be waisting memory.

1 Like

Not to mention that rrd4j doesn’t support Switch, Contact, Color, DateTime, or String Items IIRC whereas MapDB does.

Thanks for the hint to MapDB and its advantages over RRD4J!

However, it worked fine for several years in Openhab1 (also for Switch and Contact btw, but of course not for DateTime, String etc.) :wink:

It’s just one of these small annoying things which when migrating to OH2, which take a lot of time for debugging.

In OH 2 rrd4j no longer supports Switch and Contact.

But Jan and Jürgen’s comments applied even for OH 1.