Problem with the items state in a rule trigger

Hi all,

I have got a problem with the items state in a rule trigger.

There is the item:

Contact doorbell "Klingel betätigt" <contact> { channel="zwave:device:71a23be9:node14:sensor_door" }

and a rule:

rule "Es hat geklingelt"
when Item doorbell changed
then
// ...
end

Everything works fine, but the trigger of this rule is also fired when the system starts up.

To prevent this, I added:

when Item doorbell changed to CLOSED

and I also tried:

when Item doorbell changed from OPEN to CLOSED

But the rule is not executed anymore.

I added:

logInfo("Rules","previousState="+previousState)
logInfo("Rules","currentState="+doorbell.state)

and got:

13:51:00.249 [INFO ] [eclipse.smarthome.model.script.Rules] - previousState=OPEN
13:51:00.254 [INFO ] [eclipse.smarthome.model.script.Rules] - currentState=CLOSED

So I am confused about my failure.

I am using openhabian with the current unstable release openHAB 2.1.0 Build #934.

Does anyone understand what is going wrong?

Thank you in advance, Nico

There is currently a bug in OH that makes it so the to and from only works with numbers right now.

What you are trying to do actually is valid normally. It is just broken right now.

I do not know if it is fixed in the snapshot or not but it is definitely broken in the release.

1 Like

Hi @rlkoshak,

thank you for your quick and helpful answer!

I will workaround with an if statement against the current state inside the rule unless this bug is fixed.

Thank you again and best regards, Nico.