historicState stopped working after update to OH4 M2

Hi,
recently I updated to OH4 M2 and one of may rules stopped working. I was already able to narrow it down to one specific line, but I still don’t get what I am doing wrong.

I order to debug, I made a script

val mowedToday = (mowerHours.historicState(now).state as Number).doubleValue

[edit: I now, that using “now” does not make any sense, but I try to keep out everything which could be a reason for the error. The rule uses now.withHour(0).withMinute(0).withSecond(0)]

resulting in following error

Script execution of rule with UID 'test_mowerhours' failed: cannot invoke method public abstract org.openhab.core.types.State org.openhab.core.persistence.HistoricItem.getState() on null

This is also the same error I got from the rule.

Perrsistence seems to work

Can someone support me with a hint where to look?

Thank you very much
BR
PeterK

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.