Problem with Persistence maximumSince NULL

Okay. So when you show us some_item_22 records from your database, it does not mean that openHAB persistence service can access records from some_item.
That’s the problem you are trying to track down. This is why we’ve suggested using REST API etc. to access through the OH service.

Let’s try another track, add diagnostics to your rule.

var testit = al_i_ausentemperatur.historicState(now.minusDays(1), "jdbc")
logInfo("test1", testit.state.toString)
testit = al_i_ausentemperatur.historicState(now.minusDays(5), "jdbc")
logInfo("test5", testit.state.toString)
testit = al_i_ausentemperatur.historicState(now.minusDays(100), "jdbc")
logInfo("test100", testit.state.toString)
testit = al_i_ausentemperatur.historicState(now.minusDays(1000), "jdbc")
logInfo("test1000", testit.state.toString)

In each case, historicState() should return the last data from before the target date. If your records only go back 7 days, the 100 day version will I expect fail as null.
Let’s see if that works as expected, and we wlll know at least some of your records are accessible.

If that does work as expected, you could go on to do a similar exercise using maximumSince().
The difference here is that we DO expect a result even at 1000 days.

1 Like

rule “test_dummy_error”
Time cron “0 0/1 * 1/1 * ? *”
var testit1 = al_i_ausentemperatur.historicState(now.minusDays(1), “jdbc”)
logInfo(“test1_error”, testit1.state.toString)
var testit5 = al_i_ausentemperatur.historicState(now.minusDays(5), “jdbc”)
logInfo(“test5_error”, testit5.state.toString)
var testit100 = al_i_ausentemperatur.historicState(now.minusDays(100), “jdbc”)
logInfo(“test100_error”, testit100.state.toString)
var testit1000 = al_i_ausentemperatur.historicState(now.minusDays(1000), “jdbc”)
logInfo(“test1000_error”, testit1000.state.toString)

I get that

2020-06-18 13:43:00.483 [INFO ] [e.smarthome.model.script.test1_error] - 26.2

2020-06-18 13:43:00.489 [INFO ] [e.smarthome.model.script.test5_error] - 29.8

2020-06-18 13:43:00.496 [INFO ] [smarthome.model.script.test100_error] - 6.2

2020-06-18 13:43:00.503 [INFO ] [marthome.model.script.test1000_error] - 3.9

Alright, this shows you have access via OH persistence service to data over 1000 days old. That’s a good step forward, now we can focus on maximumSince()


var testit = al_i_ausentemperatur.maximumSince(now.minusDays(1), "jdbc")
logInfo("test1d", testit.state.toString)
testit = al_i_ausentemperatur.maximumSince(now.minusDays(1000), "jdbc")
logInfo("test1000d", testit.state.toString)
testit = al_i_ausentemperatur.maximumSince(now.minusYears(1), "jdbc")
logInfo("test1y", testit.state.toString)
testit = al_i_ausentemperatur.maximumSince(now.minusYears(10), "jdbc")
logInfo("test10y", testit.state.toString)

I’m expecting we’re going to uncover a bug about reaching back before records exist.

var testit1d = al_i_ausentemperatur.maximumSince(now.minusDays(1), “jdbc”)
logInfo(“test1d_error”, testit1d.state.toString)
var testit1000d = al_i_ausentemperatur.maximumSince(now.minusDays(1000), “jdbc”)
logInfo(“test1000d_error”, testit1000d.state.toString)
var testit1y = al_i_ausentemperatur.maximumSince(now.minusYears(1), “jdbc”)
logInfo(“test1y_error”, testit1y.state.toString)
var testit10y = al_i_ausentemperatur.maximumSince(now.minusYears(10), “jdbc”)
logInfo(“test10y_error”, testit10y.state.toString)

2020-06-18 14:08:00.794 [INFO ] [.smarthome.model.script.test1d_error] - 28.2

2020-06-18 14:08:05.145 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule ‘test_dummy_error’: null

doesn’t look that good

That’s interesting.
We can get a historic record for 1000 days, but not a max.
I take it you are actually expecting data from three years ago? You mentioned 7 days earlier.

I wonder if something is timing out due to the time taken for max search.

There is also the possibility with data that old, that there is some kind of glitch in your database - say, the method of writing records has changed in some way between then and now. Changed timezone, perhaps.

If you’re not getting any logs from JdbcPersistenceService, we’d better try some debug. In the console -
log:set DEBUG org.openhab.persistence.jdbc

and try the 1-day, 100-day max queries again