Incorrect behavior of <item>.previousState(true) command


First my configuration: openhab 4.1 on ubuntu 22.03 on Raspberry Pi 4 with influxdb persistence.

I observe that .previousState(true) and .previousState() and item.state are giving the same output - which is probably incorrect.

The item values in influx db are:

0	AgnieszkaTelefonBudzik	value	1704951600000	2024-01-10T04:50:00.000Z	time	
0	AgnieszkaTelefonBudzik	value	1705034700000	2024-01-11T05:50:00.000Z	time

The rule is as below:

var AgnieszkaBudzikPrevious = items.getItem("AgnieszkaTelefonBudzik").history.previousState().state;
var AgnieszkaBudzikPrevioustrue = items.getItem("AgnieszkaTelefonBudzik").history.previousState(true).state;
var AgnieszkaBudzikActual = items.getItem("AgnieszkaTelefonBudzik").state; + "Agnieszka Budzik Previous state: {}", AgnieszkaBudzikPrevious); + "Agnieszka Budzik Previous true state: {}", AgnieszkaBudzikPrevioustrue); + "Agnieszka Budzik Actual state: {}", AgnieszkaBudzikActual);

And the log output:

2024-01-11 12:01:34.285 [INFO ] [org.openhab.rule.1e6d052a7d         ] - TEST: Agnieszka Budzik Previous state: 2024-01-12T05:45:00.000+0100
2024-01-11 12:01:34.286 [INFO ] [org.openhab.rule.1e6d052a7d         ] - TEST: Agnieszka Budzik Previous true state: 2024-01-12T05:45:00.000+0100
2024-01-11 12:01:34.287 [INFO ] [org.openhab.rule.1e6d052a7d         ] - TEST: Agnieszka Budzik Actual state: 2024-01-12T04:45:00.000+0000

Are you certain that InfluxDB is your default persistence? If not it’s not querying InfluxDB but whatever the default is (rrd4j? mapdb?).

If you are certain InfluxDB is your default this is indeed incorrect (in particular the previousState(true)) but it’s not clear where the error resides. Based on looking at the code for openhab-js, I’d guess that it’s openHAB core.

The only persistence I have is influxdb. Data above are taken from influx.

If you started with OH 3 then you also have rrd4j and rrd4j is the default persistence unless you took action to remove it and change the default.

I removed rrd4j.