Rule trigger with declared value, not Triggered

Hi,

I’ve tried have a rule triggered by an update of a certain value, like this:

val int STATUS_DISARMED= 0
rule "Alarm Condition"
when 
    Item Alarm_State received update STATUS_DISARMED
then
    logInfo("rules", "update DISARMED")
end

doing:

Alarm_State.postUpdate(STATUS_DISARMED)

It doesn’t trigger the rule. However, replacing STATUS_DISARMED with its value, it triggers.

val int STATUS_DISARMED= 0
rule "Alarm Condition"
when 
    Item Alarm_State received update 0
then
    logInfo("rules", "update DISARMED")
end

One way to overcome this, would be add an if clause in the beginning of the then block testing the value, and the trigger would be without value.

Anyone has a suggestion to overcome this, in the cleanest way possible?

Thanks.

That is the only way you can currently accomplish this.

@5iver, Thanks.

1 Like

Ah yes … you cannot substitute in the when clause.

And
Alarm_State.postUpdate("STATUS_DISARMED")
posts a simple string, openHAB can have no idea you want to substitute there either.

There was a typo in my original post (edited) I should have mention Alarm_State.postUpdate(STATUS_DISARMED)