Strange error on UpdateSince

I get a strange error when trying to access the changedSince method of an item.

My item is defined as follows

Switch gardenlightswitch "Garten-Licht [%s]" <light> (licht, reportEveryChange) ["Switchable"]

My rules implements

logInfo("test","outcome2: " + gardenlightswitch.changedSince(now.minusMinutes(2)))

And the error thrown:

Could not invoke method: org.eclipse.smarthome.model.persistence.extensions.PersistenceExtensions.changedSince(org.eclipse.smarthome.core.items.Item,org.joda.time.base.AbstractInstant) on instance: null

last update works as in the following statement

logInfo("test","outcome1: " + gardenlightswitch.lastUpdate)

So the item is correctly persisted. Any idea?

A strange error indeed.

Errors like this usually point to a type error, but I don’t see how that can be the case here, unless it’s trying to convert everything to a String too early. It should return a boolean but I don’t know if it returns a Boolean (primitive versus class with a .toString method). What happens if you add .toString to the call?

not much difference

An error occurred during the script execution: Could not invoke method: org.eclipse.smarthome.model.persistence.extensions.PersistenceExtensions.changedSince(org.eclipse.smarthome.core.items.Item,org.joda.time.base.AbstractInstant,java.lang.String) on instance: null

and it doesn’t work in an if clause, that’s why I put it in a LogInfo to see more…

My only suggestion at this point is to put the persistence binding you after using into trace log mode and see if it tells you anything interesting.

hmm, where di you put .toString? The error message looks odd.

Anyway, if it returns a primitive with no .toString it’ll fail.
Maybe try

if ( gardenlightswitch.changedSince(now.minusMinutes(2)) ) {
   logInfo("test". "changedSince true")
} else {
   logInfo("test". "changedSince false")

Which persistence db do you use?

Unfortunately it throws the same error on instance:null. That if (true) check was my first intention only to find the root course I wanted to show it in the logs using toString. I use influxDB and mapdb for persistence.

If your default persistence is mapdb … changedSince makes no sense with mapdb and its single value storage mechanism.

I think you need to use the extra parameter to changed since to select the service


Make sure you have a sensible strategy for the Item for a sensible return.