Persistence deltaBetween error

Hi,

I’m struggeling using deltaBetween with rrd4j persistance service. I get the following error:

2022-07-03 16:11:42.580 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'zaehler-2' failed: 'deltaBetween' is not a member of 'org.openhab.core.library.items.NumberItem'; line 34, column 25, length 51 in zaehler

Documentation says: <item>.deltaBetween(ZonedDateTime, ZonedDateTime) Gets the difference in value of the State of a given Item between certain points in time

So, I’m using it just like deltaSince which is working fine.

val Number DayOfMonth = now.getDayOfMonth()
val Number StromVerbrauchM  = vzloggerMQTTThing_Zaehler.deltaSince(now.minusDays(DayOfMonth).with(LocalTime.MAX))
val Number StromVerbrauchM1 = vzloggerMQTTThing_Zaehler.deltaBetween(now.minusMonths(1).minusDays(DayOfMonth).with(LocalTime.MAX),now.minusDays(DayOfMonth).with(LocalTime.MAX))

Also I have a strange issue that the deltaSince line throughs an error every day at 1am and only at 1am:

2022-07-09 01:00:15.116 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID ‘zaehler-2’ failed: null in zaehler
2022-07-09 01:00:45.116 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID ‘zaehler-2’ failed: null in zaehler
2022-07-10 01:00:15.201 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID ‘zaehler-2’ failed: null in zaehler
2022-07-10 01:00:45.189 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID ‘zaehler-2’ failed: null in zaehler

How do I protect against “null” in deltaSince? This is using OH-3.3.0.M5 in Docker.

Thanks

There is no 3.3.0.RC5. Can you check which version you are actually using?

… upps, sorry - I mean 3.3.0.M5

Then that is the answer. This feature was merged one day after 3.3.0.M6 was released, so it’s in the RCs and the release but nor in any milestone.

OK, great - that - using release version 3.3.0 now - resolves the deltaBetween error.

What about the other issue - how to catch “null” for deltaSince and deltaBetween calls? I understand rrd4j returns null in case no data can be found for that date & time. Can I ignor the error if valid data is sent later?

Thanks

The question is what is null. I guess you use the values returned for another calculation. You should add a check for null in the rule, because null is a valid return value and you need to exit the rule if you encounter that.