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
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.floatValue10.0)/10.0) + " °C (” + df.format(al_i_ausentemperatur.maximumSince(now.minusYears(10), “jdbc”).timestamp) + “)”
postUpdate(dummy_002, tmp)
}
end
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.
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.
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.
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.