Difference between OH3 & OH4 for .maximumBetween

In OH3 I have a rule with the line

var Number maxBetween = mqtt_dsmr_electricityPeak.maximumBetween(firstDay, lastDay, "influxdb").state as DecimalType

This gives me a number 3.351

Now, I use the exact same rule in OH4 and I get a complete different result (5.676).
The variables firstDay and lastDay giving the same output.
Both items are created the same way:

Number     mqtt_dsmr_electricityPeak    "electricity peak"   (dsmr)     ["Status","Energy"]    {channel="mqtt:topic:mosquitto2:dsmr:electricity_peak_current_month"}

The result of OH3 is the correct one.

Actually this rule loops over all months of the year and for some month’s it’s ok, but for some not…

month OH3 OH4
1 3.351 5.676
2 5.31 5.31
3 2.19 5.31
4 2.33 2.33
5 5.01 5.01
6 0.46 5.01
7 0.9 0.9
8 0.56 0.56

What am I missing?

I believe there were some changes to some of the persistence actions’ implementations regarding which values are and are not included in the range. Before, I think the first entry after firstDay was skipped or something like that and that has been corrected in OH 4.

Also double check your clocks on the two machines. Even a second or two difference could cause the inclusion/exclusion of points at the borders of the timerange if the time part of firstDay and lastDay isn’t fixed.

You’ll probably need to tool at the raw data in the database to verify.

I dived into the influxdata, and indeed I found the incorrect values, but I don’t understand.
The incorrect value (5.676) is on 30/11/2022 and I’m requesting the data between 01/01/2023 & 31/01/2023.

It seems that it looks to the data from 22:00 and not 00:00 (24:00). I need to figure out why this data is not correct for some month. I know that I entered these values manual for a while, because some automation was not yet in place.
The strange thing is still that in OH3 al values were correct, and yes, my both OH instances are set to the same timezone :slight_smile:

The time matters to.

What time is firstDay and lastDay? Is there a difference between 3 and 4?

I don’t think the timezone matters because ZonedDateTime includes the timezone. Even if the timezones were different the results should be the same.

they give exactly the same results:
OH3
firstDay: 2023-01-01T00:00+01:00[Europe/Brussels]
lastDay: 2023-01-31T23:59:59+01:00[Europe/Brussels]

OH4
firstDay: 2023-01-01T00:00+01:00[Europe/Brussels]
lastDay: 2023-01-31T23:59:59+01:00[Europe/Brussels]

But I solved it by removing the incorrect values between 22:00 & 24:00… Not so clean, but everything works now in OH3 & OH4…