Hi everyone,
I’m encountering an issue with the persistence.lastUpdate()
function not returning the expected result. I have the following setup:
- Item:
Illuminance_Garden_MiFlora1
is persisted, and I can see the data in the persistence store:
ItemId ItemName
59 Illuminance_Garden_MiFlora1
Time Value
2025-01-24 00:00:01.375 115
In my script, I have:
let itemNames = ["Illuminance_Garden_MiFlora1"];
let itemNamesPresence = ["Switch_Garden_MiFlora1_Presence"];
for (let i = 0; i < itemNames.length; i++) {
var itemName = itemNames[i]; // Item to monitor
var itemNamePresence = itemNamesPresence[i];
var last10Minute = time.ZonedDateTime.now().minusMinutes(10);
var lastUpdateTime = items.getItem(itemName).persistence.lastUpdate();
console.log("Testlastupdate" + lastUpdateTime);
}
However, when I check the logs, I see:
[ab.automation.script.file.miflora.js] - Testlastupdate null
My question: Why is persistence.lastUpdate()
returning null
in this case? The item Illuminance_Garden_MiFlora1
is correctly persisted, and I can see the timestamp and value in the persistence store.
I also noticed that if I add the following persistence strategy to Illuminance_Garden_MiFlora1
:
Illuminance_Garden_MiFlora1: strategy = everyChange, everyMinute, everyDay, restoreOnStartup
then persistence.lastUpdate()
works as expected and doesn’t return null
.
or reference, my standard persistence rule is:
*: strategy = everyDay, restoreOnStartup
Has anyone encountered a similar issue or knows why this might be happening? I’d appreciate any help!
Thanks in advance!