changedSince doesn't work


I have problems using changedSince:
String Abus_Motion “Bew. Abus [%s]” (G_jdbc)

if(now.getHourOfDay >= 22 && !Abus_Motion.changedSince(now.minusMinutes(20))) {
if(G_Lights.state == ON) {

The rule fires as soon as it’s after 22 o’clock even though Abus_Motion changed 2 minutes ago (the string contains the time stamp of the jpg generated by an IP cam).

I store all items in mapdb and additionally strings and switches in jcdb-h2.
I might still have problems with JCDB, because it seems that my db (/var/lib/openhab2/persistence/jdbc-h2.trace.db) is not updated very often.
Beside that I find a file named, which was modified the last time several weeks ago).

JDBC errors:
2016-12-02 11:30:11.022 [DEBUG] [ence.jdbc.internal.JdbcConfiguration] - No jdbc:user parameter defined in openhab.cfg
2016-12-02 11:30:11.024 [DEBUG] [ence.jdbc.internal.JdbcConfiguration] - No jdbc:password parameter defined in openhab.cfg.


Failed to initialize pool: Wrong user name or password [28000-191]

But for JDBC h2 there is no user name required but optional, right?
This user / pwd is for a (real) SQL DB only I guess!?

I used the default user / pwd (sa / “”) and I am a step further.
But I still get:
Failed creating the component instance; see log for reason

Any suggestion?

Now it’s working…
JDBC: Stored item ‘Abus_Motion’ as ‘02.12. - 15:09’ in SQL database at Fri Dec 02 15:09:50 CET 2016 in 15 ms.

checking for !Abus_Motion.changedSince… next

Even though persistence seems to run I get the following error:

2016-12-02 21:00:34.616 [INFO ] [ ] - Last Motion: 02.12. - 20:54 -> Night_Mode activated

Is is possible that changedSince does not work with Strings?

With Switches I get:
rule "previousState monitoring"
Item Z_WoZiLicht changed
logInfo(“lights.rules: >”, "Z_WoZiLicht state / previousState = " + Z_WoZiLicht.state + " / " + G_Lights.previousState)

As a result in the log:
Z_WoZiLicht state / previousState = OFF / org.openhab.core.persistence.internal.QueryablePersistenceServiceDelegate$1@149457f

Z_WoZiLicht.previousState.state.toString did the job:

state is always = previousState ???
Z_WoZiLicht state / previousState = ON / ON

I just don’t get it…

I know it’s confusing how I jump from changedSince to previousState, but both are persistence related.
And I hope it helps someone stuggling with this topic a little :wink:

I found that this doesn’t work:
if (WoZiLicht.previousState == OFF)

But this one does:
if (WoZiLicht.previousState(true,“jdbc”).state == OFF)

(jdbc is not my default persistence, just used for everything but numbers)

Analog to previousState the following works for changedSince now:
if (Abus_Motion.changedSince(now.minusMinutes(30),“jdbc”)) {

I need to re-open this issue because the changedSince funtion is not reliable.
I use the following rule:

rule "All in bed? -> Nightmode"
 	Time cron "30 0/10 * * * ?"
   	if(now.getHourOfDay >= 22 && Night_Mode.state == OFF) {
 		if(!Abus_Motion.changedSince(now.minusMinutes(45),"jdbc")) {
			sendTelegram("OH_TeleBot", "Nacht Modus aktiviert.\nLetzte Bewegung: " + Abus_Motion.state)
			logInfo("abus.rules: ", "Last Motion: " + Abus_Motion.state + " -> Night_Mode activated")
		else {
			logInfo("abus.rules: ", "Abus Motion changed in last 45 min. Last Motion: " + Abus_Motion.state)			

But the time of Night_Mode Activation is not reliable (sometimes 2 min after the last change, sometimes close to 45 min.

The openhab.log shows:
2016-12-13 22:50:30.443 [INFO ] [.smarthome.model.script.abus.rules: ] - Last Motion: 13.12. - 22:30 -> Night_Mode activated

and events.log:
2016-12-13 22:30:50.274 [ItemStateChangedEvent ] - Abus_Motion changed from 13.12. - 21:56 to 13.12. - 22:30

Is this a known issue???

No one?

I just started to implement something similar and the changedSince never worked for me.

Which default persistance are u using?

I am coming back to this issue… :frowning:My default persistence is mapdb, but I use jdbc for switches and rrd4j for numbers.
Have you been able to make it run?

I tried all persistences (JDBC, mapdb, …etc.) it was working sometimes and sometimes not.
The one with more probability to work correctly was the influxDB persistence, but still was not reliable.

I ended up doing different workarounds like creating other items to store changed datetime, variables within the rules, hashmap variables to store the name of the item and the last change datetime, …etc.

Either i’m so stupid with persistence or there is something really not working and i can’t find it.

Anyway i spent several days on it to decide that is enough, and my workarounds works more reliably now

:smiley: That’s what I was thinking sometimes, too
But there IS something not working reliable - that’s for sure.
Thanks. I will play around a bit more.