OH4: Blockly persistence with non default service

Hi All

I have started moving some rules to Blockly. (Which I am enjoying)

I need to retrieve a persisted state of a STRING items, so it has been persisted using MAPDB, which is not my default persistence service (I use RRD4J for all the main stuff).

Is there anyway to retrieve the persisted values from the NON default persistence service using Blockly? I have not been able to find anything in my searches.


If the current set of blocks do not allow you to supply the DB, you’ll have to use the inline script block and call the action directly. In OH 3 it’ll look something like:

var ZonedDateTime = Java.type('java.time.ZonedDateTime');
var histState = actions.Persistence.historicState(items.getItem('MyItem'), ZonedDateTime.now().minusDays(1), 'mapdb');

In OH 4 it’ll look something like:

var histState = items.MyItem.histState(time.toZDT().minusDays(1), 'mapdb');
1 Like

No, unfortunately it is not possible yet. There has already been a request in the past to allow that but I haven’t had the time to implement it, though, it is on my list.


Thank you Stefan

On review however I have realized that MAPDB does not really help much as all it sores in the “CURRENT” state of the string (persistence set to : strategy = everyChange, restoreOnStartup

So as soon as the string changes, this is “persisted”, so you cannot retrieve the previous state.

I will need to investigate other options for STRING persistence I guess.

But there are other services that may work better and benefit from the added feature.