RestoreOnStartup does not restore NULL value


Im using OH3 and MapDB with the following strategy:

Strategies {
default = everyChange
Items {

  • : strategy = everyChange, restoreOnStartup

Unfortunately NULL values are not restored, but only the value before the item changed to NULL. I need the NULL value to be restored - is it possible?

Best regards,

I can’t think of a valid use case for this … NULL means unset, uninitialized.
So when an item already has a value you shouldn’t be setting it to NULL, and if you don’t noone will because it is already initialized. If you use NULL to signal some special state, that’s sorta misuse. Consider switching to use UNDEF instead.

Thanks, I changed to UNDEF, but the value is still not restored on startup.

I don’t understand. Either restoration does not work at all (if so you incorrectly described your issue), or the value that was persisted last will be restored (which is exactly the purpose of this).
So what “value” is not restored ?


It is the value UNDEF that is not restored. Other values are restored as expected.

I use a DateTime Item to create a “OpenHab-restart-resistant-timer”, and would like to use the value UNDEF if the timer is turned off. But if I restart OpenHab then the value before UNDEF is restored instead of UNDEF. I guess MapDB can’t handle the value UNDEF and skip it?

Best regards,

Quite right too. UNDEF signifies undefined, incalculable, not possible to store in a database, so not possible to restore either.
This is all working as designed - NULL and UNDEF are not persisted and so cannot be restored.

You will have to think of another means to signal your timer is inactive or whatever it is.


I now use a String to store the timer value. If the string is empty the timer is inactive. It is working just perfect :slight_smile:

Best regards,

1 Like

One reason of setting a value to NULL is that such is visible in a Chart - if Chart period does not contain a !NULL value. I my case: Exterior temperature sensor (Gardena Smart Sensor) provides temperature - until it is sent to winter sleep. Temperature and other values are persisted through openHAB in rrd4j. Switch for winter sleep sets those items to NULL, to not appear in short term charts after a while. But a restoreOnStartup restores last !NULL value, which also lets that temperature value appear in Charts.
I can only re-set that by manual winter off/on toggle, to rewrite NULL for that runtime.
Don’t see a way yet to grab the moment during startup where items are restored, to trigger a rule or make them NULL again, depending on winter sleep item status.