I have openhab 2.4 running on a raspberry Pi 2 using the openhabian image. I just upgraded openhab from version 2.3 to version 2.4. Before that all my rules worked just fine.
I now have the problem that previousState
and previousState(true)
no longer return a historic state other than the latest one in my database. I am using sqlite with jdbc as persistence service. This works fine as I verified the contents of the database with the sqlite command line utility. I have a MAX heating item that I use with the homematic binding and homegear. The item has 3 entries in its persistence table:
sqlite> select * from item0013;
time|value
2018-12-21 18:40:44.060|20.0
2018-12-21 19:21:23.907|12.0
2018-12-21 19:37:41.462|21.0
As you can see I have three different states for this item in the database.
Here are some basic rules and their log output
logInfo("heating.rules", "Heating contact alert")
logDebug("heating.rules", "Buero status " + Thermostat_buero_1_SetTemperature.state)
logDebug("heating.rules", "Buero previous state " + Thermostat_buero_1_SetTemperature.previousState().state + " datetime: " + Thermostat_buero_1_SetTemperature.previousState().getTimestamp())
logDebug("heating.rules", "Buero previous state true " + Thermostat_buero_1_SetTemperature.previousState(true).state + " datetime: " + Thermostat_buero_1_SetTemperature.previousState(true).getTimestamp())
logDebug("heating.rules", "Buero historic state " + Thermostat_buero_1_SetTemperature.historicState(now.minusMinutes(70)).state + " datetime: " + Thermostat_buero_1_SetTemperature.historicState(now.minusMinutes(70)).getTimestamp())
here is the log output
2018-12-21 20:27:09.579 [INFO ] [smarthome.model.script.heating.rules] - Heating contact alert
2018-12-21 20:27:09.587 [DEBUG] [smarthome.model.script.heating.rules] - Buero status 21.00 °C
2018-12-21 20:27:09.602 [DEBUG] [smarthome.model.script.heating.rules] - Buero previous state 21.0 datetime: Fri Dec 21 19:37:41 CET 2018
2018-12-21 20:27:09.620 [DEBUG] [smarthome.model.script.heating.rules] - Buero previous state true 21.0 datetime: Fri Dec 21 19:37:41 CET 2018
2018-12-21 20:27:09.644 [DEBUG] [smarthome.model.script.heating.rules] - Buero historic state 20.0 datetime: Fri Dec 21 18:40:44 CET 2018
So as you can see both previousState
commands return the wrong state. it is the current state they return. But querying the persisted seems to work correctly with the historicState
function.
here is the persistence config.
Strategies {
default = everyChange
}
Items {
* : strategy = everyChange, restoreOnStartup
}
All items in question were created with paper ui.
Anyone an idea whats going on? I used previousState(true)
with openHab 2.3 successfully.
One thing comes to my mind tough. I had to update or better said I had to set up all my MAX heater items again after the update because the channel for setting the temperature had changed from type number to number:temperature. Might this be the problem? But I already deleted all items and MAX things and started over. I also let openhab jdbc create a complete new persistence database.