I have mapdb configured to persist all Items, along with restoreOnStartup.
I have some temperature sensors that occasionally fail, so I’m using the Expire binding to set these Items to UNDEF if they don’t receive an update at their expected interval (this avoids having erroneous values showing in sitemaps).
However, I’ve found that these UNDEF values aren’t being stored in mapdb, so when restoreOnStartup is called, I get the last decimal value. Example here:
@Moxified Oh absolutely I’ll fix the sensors, I just want to ensure I gracefully handle any failure that may occur in the future.
One of the reasons I’m doing this is to more easily spot if/when they do fail (battery exhaustion usually). Using UNDEF seems to work very elegantly, except this persistence issue. Do you know of a better way of doing this, generally?
@rlkoshak Thanks for the System started rule suggestion. I wonder if that rule could go further than that and check lastUpdate itself to avoid waiting for the Expire binding to trigger.
I would not restoreOnStartup. You already have to deal with the fact that the Items might be NULL at some point, so I would leave them as NULL until you get a valid reading. This ensures that you are not acting on stale and incorrect data. When the Item has a value you know that the Item value is valid and recent.
For my sensors, I implement what Moxified describes as well.