DateTime is removed?

Hi, I´m using the “DateTime” item here is an sample link

Switch DEV_01 "Device1 - Status" (PresenceDev, PresenceDetails)
DateTime PRAESENZ_01 "Device1 last detection [%1$tA, %1$td.%1$tm.%1$tY %1$tT]" <calendar> (PresenceDetails)

This is updated by a rule:

import org.openhab.core.library.types.*
import java.util.Calendar
import java.util.Date
import java.util.TimeZone

 
rule "Device1 - Presence Detected"
when
    Item DEV_01 changed to ON
then
    var local_time = java::util::Calendar::getInstance(TimeZone::getTimeZone("Europe/Berlin"))
    postUpdate(PRAESENZ_01, new DateTimeType(local_time))
end

Its working fine. When I click on my switch seen in my sitemap it updated the field with the date. However after some time the entry is reset to “-, -.-.- -”.

Is that normal? Shouldn´t the last time be persistent here?

Well, neither items nor variables get reset all by themselves.
But this can happen on a number of occasions, e.g. on reloads that happen if you change rules files.
I’m just guessing, but that string is possibly the equivalent of ‘Uninitialized’.
Try persisting PRAESENZ_01 using ‘restoreOnStartup’.

Ah, that might explain the “issue”. I currently “playing” a lot with the rules and the other config files. So this “testing” could then reset that. As long as it isn´t supposed to be in the “normal use” I´m happy with that :D.

Thanks for the fast reply.