How to write item just before midnight?

I would like to write a item just before midnight to get the date logged with data for that day.

I was going to use a rule but is there a function in JS to write item to persistent data store ?

rules.when().cron(“55 59 23 * * ?”).then(event => {
item1.persist() ??


You can define a persistence strategy for that. No need to do that via JS.

everyDayBeforeMidnight  : "55 59 23 * * ?"

Its true that persistence strategy will work, however in some extreme cases system under heavy load might not process things fast enough. Think of situation when you have bunch of items stored before midnight and very slow I/O - unless you tweak configuration you might be at risk of exceeding expected time window. The cron persistence strategy as far I remember dispatches a write to database, does not determine write time at all.

Truly reliable way to store things at given time (I use 23:59:59.999) is calling modifiable persistence service.

Thanks, Can you give me a example of that code?

1 Like

Call this method from your rule: openhab-core/ at 3e8905bcb741767e40e35fc5d83eba51b18adf97 · openhab/openhab-core · GitHub

It will store given state for an item at given time.

Is that available from javascript as well?