- Platform information:
- Hardware: Pi 3B+
- Openhabian 4.0.2
- Java 17
I am migrating from OH 2.5 to 4. Previously I used MAPDB to restore values of some critical Switches and Numeric items (heating temperature setpoints).
I have a system rule which set default values of these items in case these are NULL and persistence data is not available, but in v4 it doesn’t work as I expect.
Items
Number ff_childroom1_heating_setpoint "Gyerekszoba 1 setpoint [%.1f °C]"(Heating_setpoints, High_hysteresis)
Number gf_living_heating_setpoint "Nappali setpoint [%.1f °C]" (Heating_setpoints, Low_hysteresis)
...
System rule
rule "Initialize system"
when
System started
then
heating_setpoints.allMembers.forEach[sp|
if (sp.state == NULL){
sp.postUpdate(21)
}
]
end
mapdb persistence
Strategies {
default = everyUpdate
}
Items {
gf_living_heating_setpoint : strategy = everyChange, restoreOnStartup
ff_childroom_heating_setpoint : strategy = everyChange, restoreOnStartup
ff_childroom1_heating_setpoint : strategy = everyChange, restoreOnStartup
ff_bedroom1_heating_setpoint : strategy = everyChange, restoreOnStartup
ff_workroom_heating_setpoint : strategy = everyChange, restoreOnStartup
...
}
Issue
When I remove the System Rule values are successfully restored from persistence, so seemingly persistence works. But if the system rule is allowed all values will be set to default 21 in every cases. I don’t really understand how it can happen because default should be set only in case if values are NULL and persistence is not available. According to documentation persistence restoration runs before rule engine started, so persistence should be already restored when my system rules runs.
I also don’t know if I should use MAPDB at all. As I can see all Numeric values are stored in rrd4j by default, but I am not sure If those can be restored from there. Additionally I also have some Switches what should be restored and if I am not wrong rrd4j can’t persist those.
Could you please help me to find what do I wrong?
Thank you,