Problem with Persistence maximumSince NULL

Hello, after an update to OpenHAB 2.5.5 you are no longer able to rule, can someone help me?

rule “max_immer”
when
Time cron “0 0/2 * 1/1 * ? *”
then
var Number Max
var String tmp
var SimpleDateFormat df = new SimpleDateFormat( “dd.MM.YYYY/ HH:mm” )

 	if (al_i_ausentemperatur.state instanceof DecimalType)
      {
      Max = al_i_ausentemperatur.maximumSince(now.minusYears(10), "jdbc").state as DecimalType
		    //Thread::sleep(900)
		  df = new SimpleDateFormat( "dd.MM.YYYY/ HH:mm" ) 
		  tmp = (Math::round(Max.floatValue*10.0)/10.0) + " °C (" + df.format(al_i_ausentemperatur.maximumSince(now.minusYears(10), "jdbc").timestamp) + ")"
		  postUpdate(dummy_002, tmp)
	    }

end

2020-06-15 10:27:02.358 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule ‘dummy_minmaxdurchschnitt_immer’: null

Can we see that rule, please?

If it is similar to the one you have shown us, then yes the problem is most likely due to persistence. Use REST API to see if you can access stored data,

rule “max_immer”
when
Time cron “0 0/2 * 1/1 * ? "
then
var Number Max
var String tmp
var SimpleDateFormat df = new SimpleDateFormat( “dd.MM.YYYY/ HH:mm” )
if (al_i_ausentemperatur.state instanceof DecimalType)
{
Max = al_i_ausentemperatur.maximumSince(now.minusYears(10), “jdbc”).state as DecimalType
//Thread::sleep(900)
df = new SimpleDateFormat( “dd.MM.YYYY/ HH:mm” )
tmp = (Math::round(Max.floatValue
10.0)/10.0) + " °C (” + df.format(al_i_ausentemperatur.maximumSince(now.minusYears(10), “jdbc”).timestamp) + “)”
postUpdate(dummy_002, tmp)
}
end

This rule is named max_immer

The rule that reports the problem is named dummy_minmaxdurchschnitt_immer

These are not the same rule

this is the same rule only the name is rewritten when posting!

2020-06-15 10: 27: 02.358 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Fehler bei der Ausführung der Regel ‘max_immer’: null

We’ve no way to know that unless you tell us.

How about looking to see if you can access your persisted data?

Yes that goes back up to 7 days then the error comes, in Grafana I see everything data and I can also look at everything with the SQL tool that has been since the update from 2.2.0 to 2.5.5

Try to break-down your rule to see where the null comes from, eg:

rule “max_immer”
when
   Time cron “0 0/2 * 1/1 * ? *”
then
  var Number Max
  var String tmp 
  var SimpleDateFormat df = new SimpleDateFormat( “dd.MM.YYYY/ HH:mm” )

 	if (al_i_ausentemperatur.state instanceof DecimalType)
      {
      Max = al_i_ausentemperatur.maximumSince(now.minusYears(10), "jdbc").state as DecimalType
      logInfo("debug",Max.toString)
		    //Thread::sleep(900)
/*		  df = new SimpleDateFormat( "dd.MM.YYYY/ HH:mm" ) 
		  tmp = (Math::round(Max.floatValue*10.0)/10.0) + " °C (" + df.format(al_i_ausentemperatur.maximumSince(now.minusYears(10), "jdbc").timestamp) + ")"
		  postUpdate(dummy_002, tmp) */
	    }
end

And now look at your log if you see an null error and/or the logInfo.
If it is code, move the /* a line lower.

On other advice: why do you declare your variables rule-global? They are only needed local within the if.

still
2020-06-15 14:43:04.512 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule ‘max_immer’: null

at

now.minusDays(7)

2020-06-15 14:46:02.989 [INFO ] [eclipse.smarthome.model.script.debug] - 33.1

is OK

at

Max = al_i_ausentemperatur.maximumSince(now.minusDays(3650), “jdbc”).state as DecimalType

2020-06-15 14:49:05.155 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule ‘max_immer’: null

then again the error from> 8 days

Mmm, it looks like it doesn’t have enough data…

Can you try this:
http://ipofOH:8080/rest/persistence/items/al_i_ausentemperatur?serviceId=jdbc&starttime=2020-06-10
And change the starttime to any other date, just to test.

Can you tell us a bit more about your data?
I understand you can see 7 days worth in some way. Is that from rules or REST API or something else?

Are you expecting to see more than 7 days? It sounds like perhaps you can older data with tools outside of openHAB, but that is not very clear.

A lot of data arrives there

I don’t want to make the rest of the API is too complex for me.

And I’m already doing it via Grafana, then I have to rebuild it and leave it in Grafana.

Now try it with a 2010 date, like your rule

Well that’s good. You don’t need the data, it’s just a test if it exists with the method either OH use in your rule.
Now a step further, try as @rossko57 says, pick a date in the year 2010. If you still get a lot of data, the need it has to be something with your rule.
If you get an error or almost the same data as with my example, the data does not exist. That’s the reason of the error.

http:// IP-Adresse :8080/rest/persistence/items/al_i_ausentemperatur?/serviceId=jdbc&starttime=2020-01-01
:Denken:
{“error”:{“http-code”:500,“exception”:{“class”:“java.lang.NullPointerException”}}}

data is there.

That means the data isn’t there.
But what I noticed, in your rule and restapi you want the data of al_i_ausentemperatur, but in your screenshot you show the data of al_i_ausentemperatur_22
See the difference. that’s the reason (I think) your rule won’t work.

1 Like

Please folks this is mariadb who always puts numbers on the back!

And the rule has always gone only since the update to 2.5.5 no longer at 2.2.0 everything was great!