I’m currently running 2.5.0-SNAPSHOT (Build #1601) as I needed a recent build of the Z-Wave binding for my home configuration.
I noticed that the rule parser chokes on the following boolean expression:
if ( ( (intState >= 0) && (intPrevState >= 0) && (intState != intPrevState) ) || (stateStr != prevStateStr) ) {
sendNotification(notificationRecipient, ruleTitle + ": " + logLine)
}
According to the Xtend documentation on infix operators this is a valid expression.
There’s no way I could avoid the rule engine reject processing the rule due to “errors”. Here are a couple errors reported on the line containing the boolean expression:
2019-06-05 18:10:46.469 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'roller-shutter-new.rules' has errors, therefore ignoring it: [318,80]: no viable alternative at input ' '
[318,81]: missing ')' at '('
[318,107]: mismatched input ')' expecting ']'
[323,2]: extraneous input ']' expecting 'end'
2019-06-05 18:11:53.907 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'roller-shutter-new.rules' has errors, therefore ignoring it: [318,71]: no viable alternative at input '||'
[318,73]: no viable alternative at input ' '
It appears that the rule processor dislikes lines that contain boolean expressions that combine multiple (space-separated) bracket levels, logical &&
(AND) and logical ||
(OR)…
If I rewrite this valid boolean expression as follows, it works without complaining:
if (intState >= 0 && intPrevState >= 0 && intState != intPrevState) {
sendNotification(notificationRecipient, ruleTitle + ": " + logLine)
} else if (stateStr != prevStateStr) {
sendNotification(notificationRecipient, ruleTitle + ": " + logLine)
}
I suppose this is a side effect of the particular way round brackets are used in the rules DSL?