- Platform information:
- docker image: openhab/openhab:3.2.0.RC1
- openHAB version: 3.2.0
- Issue of the topic: Error when trying to use PersistenceExtensions with MongoDB persistence service.
- Please post configurations (if applicable):
I’m writing a script in EcmaScript 2021 (JSScripting addon)
openhab = require('@runtime'); logger = Java.type('org.slf4j.LoggerFactory').getLogger('org.openhab.rule.' + this.ruleUID); openhab.PersistenceExtensions = Java.type('org.openhab.core.persistence.extensions.PersistenceExtensions'); var last = openhab.PersistenceExtensions.lastUpdate(openhab.itemRegistry.getItem('Thermometer')); logger.info(last.toString());
When I change persistence service to RRD4j - everything works as expected, but when I change it to ‘mongodb’, I’m always getting this error (the same error appears for all other methods, like for example “previousState” and so on).
Script execution of rule with UID '86c39f1c99' failed: java.lang.ClassCastException: class java.lang.String cannot be cast to class java.lang.Number (java.lang.String and java.lang.Number are in module java.base of loader 'bootstrap')
Is there another way, how I could query mongodb from scripts instead of using PersistenceExtensions which it seems doesn’t support MongoDB? Or am I doing something wrong? Thanks.