Hi,
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;
logger.info(rule_name + "Agnieszka Budzik Previous state: {}", AgnieszkaBudzikPrevious);
logger.info(rule_name + "Agnieszka Budzik Previous true state: {}", AgnieszkaBudzikPrevioustrue);
logger.info(rule_name + "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