First, why not use the persitence
properties on the Item? You don’t need to import PersistenceExtensions
.
var rrd4ValueCount = rrd4Item.persistence.countBetween(begin, end);
Even if you didn’t want to use that (which is the recommended way), you still don’t need to import the Java class yourself. It’s already imported for you in actions
.
var defaultPersistenceExtensions = actions.PersistenceExtensions;
You have to tell it which persistence you want to use when you don’t use the default. Since rrd4j is the default persistence, you need to tell it to use JDBC.
var JdbcValueCount = jdbcItem.persistence.countBetween(begin, end, "jdbc");
See JavaScript Scripting - Automation | openHAB
The last argument to all the persistence methods is an optional one and it’s the name of the service to query if you don’t want to use the default service.