As it might be useful for others I first want to share the (partial) solution for an issue I encountered after migrating my rules to Jython: When calling PersistenceExtensions.minimumSince() and maximumSince() I got a “ClassCastException: java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Integer” exception.
It turned out, that these exception was thrown when calling the persistence functions for my humidity items. In my setup these items are of type “Dimmer”, to be compatible with the values send on the KNX bus. In the database (PostgreSQL in my case) they where persisted using a value column of type “int8”. Turned out, that was the problem, after changing the column type to int4 it seems to work as expected.
But this resulted in an other strange issue, for “Dimmer” types maximumSince() returns an result that is the actual value * 100
The maximumSince value is what I would expect (same value as in your database), but the minimumSince looks like it is divided by 100. What is the line in your script that you are using to log the values? I’ll do a test and see if I get the same results, but I’m using MariaDB with JDBC. Also, are you using JDBC or JPA?
I am using the JDBC binding with PostgreSQL 9.6 on macOS, installed via macports. The JDBC database driver is the one supplied by the binding (2.4 Release), which is tested but quite old.
I tested this behavior with several items and could reproduce it with every humidity item which is defined as Dimmer, but not with Number items. In the DSL rules the persistence functions return a value as expected (0<= value <=100).
You are right I just checked this again and the values in the DSL rules are the same as in Jython. I am sure, that this worked when I first wrote the rule many, many years ago
I would file a bug, but I am not sure if the openhab2-addons repro would be the right place. In the meantime I changed the tags of this thread, as the issue is obviously not related to Jython alone,
Thanks for the hint! With the DSL rules I was somewhat overcautious with type casting and I guess, that stayed!
Today I tested this issue with the rrd4j persistence service, with the same result. So I assume, that it s a problem within openHAB itself and not the jdbc binding.
I am really surprised, that this problem has not been noticed by others before…
I would, if I had any clue in which repository. As the issue is not related to one specific persistence service, I suspect, that it is in some underlying layer and not one of the bundles in the “openhab1-addons” repository