MapDB Persistence Not Working?

Hi all,

Taken my first step into persistance today but it doesn’t seem to be going too well…I wanted to install mapdb so I can use the previous state of my items in rules. Heres what I have done:

  1. Installed mapdb as per instructions
  2. restarted OH
  3. Set up my mapdb.persist file
// mapdb persistence - store every item previous state - restore them on startup

Strategies {
	default = everyChange
}
Items {
	gMapDB* : strategy = everyChange, restoreOnStartup
}
  1. Added the gMapDB to an items file
Group   gMapDB            "gMapDB Presistence"
  1. Then added the group gMapDB to the items I want to store the previous state, eg
String   vGPCurrLoc      "Current Location [%s]"       (gMapDB)
  1. Restarted OH again

  2. Made sure the item vGPCurrLoc updated it’s status, (this item actually updates every 5 minutes anyway)

  3. Added the following code into a rule

vGPCurrLoc.previousState("mapdb").state.toString
  1. Am currently getting the following in the log:
Rule 'GP iPhone Location detection': An error occurred during the script execution: Could not invoke method: org.eclipse.smarthome.model.script.actions.BusEvent.sendCommand(org.eclipse.smarthome.core.items.Item,org.eclipse.smarthome.core.types.Command) on instance: null

Now that reads to me like the item previous state is null, ie it hasn’t been assigned a value yet…

I know it has certainly updated so I’d expect to see something in there.

Does anyone have any ideas or pointers please???

previousState doesn’t make any sense with mapdb. It stores one value only, and it is the one the Item last changed to - i.e it is “nowState”.

Ah, so how do I refer to it in a rule?

You’ll have to use another persistence such as rrd4j (numbers only) or influxdb.

Ah, so…that was probably going to be my next question. I didn’t quite know which persistence option to go for.

From what you’ve just said, I now assume:

mapdb is good for system restart state
Influxdb is good for item previous state

Is that right? If so, how does the system / do you / rules determine how to use which one?

Hint

So the bit in brackets determines the persistence service it calls?

As described here

It’s the last string in the bit in brackets that is the selector
xxx.previousState() - use default service
xxx.previousState(“influxdb”)
xxx.previousState(true,“influxb”)

Wonderful, thanks…

I’m now off to see how easy / hard getting influxdb onto my OH setup is…:+1: