Persistence for openhab2-addons 2.5.0


As i am new to openhab, i was searching for a simple solution to store the item event stream into some kind of database, so that i could leverage the existing openhab infrastructure for writing my bundles. However, from what i understand, currently only the mapdb persistence bundle is exported to version 2.5.0 and it only stores the last value. I was trying to make org.openhab.persistence.jdbc work with the rest of the 2.5.0 project in eclipse, but was unable to resolve the dependencies by doing the steps described here:

I tried adding the dependencies that i found in the pom of the old version of the org.openhab.persistence.jdbc bundle to the features/openhab-addons/src/main/feature/feature.xml file as so:

<feature name="jdbc persistence" description="Data Query" version="${project.version}">
        <feature prerequisite="true">wrap</feature> 
        <bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.persistence.jdbc/${project.version}</bundle>
        <bundle dependency="true">wrap:mvn:commons-dbutils/commons-dbutils/1.7</bundle>
        <bundle dependency="true">wrap:mvn:com.zaxxer/HikariCP/3.3.0</bundle>
        <bundle dependency="true">wrap:mvn:org.knowm/yank/3.3.0</bundle>
        <bundle dependency="true">wrap:mvn:org.apache.derby/derby/</bundle>
        <bundle dependency="true">wrap:mvn:com.h2database/h2/1.4.199</bundle>
        <bundle dependency="true">wrap:mvn:org.hsqldb/hsqldb/2.4.1</bundle>
        <bundle dependency="true">wrap:mvn:org.mariadb.jdbc/mariadb-java-client/2.4.1</bundle>
        <bundle dependency="true">wrap:mvn:mysql/mysql-connector-java/8.0.16</bundle>
        <bundle dependency="true">wrap:mvn:org.postgresql/postgresql/42.2.5</bundle>
        <bundle dependency="true">wrap:mvn:org.xerial/sqlite-jdbc/</bundle>
        <bundle dependency="true">wrap:mvn:com.codhale.metrics/metrics-core/3.0.2</bundle>

The bundle compiles, but does not package the required dependencies.

As this seems to be non trivial, is there some kind of a solution for storing item data in version 2.5.0 without writing my own persistence layer?

As far as I know all of the existing Persistence add-ons still work in OH 2.5. I’m personally using InfluxDB. But there has been a lot of swirl around the new build system and this problem looks to be related to that.

The persistence addons haven’t been moved from OH1 to OH2 yet. The corresponding pull request is blocked, because it requires package name changes and those can only be done for a breaking change (OH3).

Usually it works to install the OH1 variants, that might indeed be broken with the current OH 2.5 snapshots.

JDBC persistence works fine with S1603.

1 Like

Thank you for the answers.

My problem is that i want to run it on the eclipse demo app, so that i could test out retrieving data etc in the ide. What has been suggested, as i understand, is that i could build the jar in the openhab1 project and install it in the 2.5.0 openhab runtime and it should work. However how do i run it in the eclipse openhab demo app?


I tried working around this by adding:

-runpath: org.openhab.persistence.jdbc-1.12.0-SNAPSHOT.jar
-runsystempackages: org.openhab.persistence.jdbc.db, \
 org.openhab.persistence.jdbc.internal, \
 org.openhab.persistence.jdbc.model, \

to the app.bdnrun file, however i could just not figure out where exactly the “-runpath” is. If i add something like “/home/mysuer/somefolder/some.jar” it says that it cannot find it. I also tried installing the jar in the .m2 repository and putting it into bnd cache folder, but nothing works here.