Rule using findFirst stopped working


I’m running openhabian with openhab 2.3.0 and just realized that my rules which are controlling my heating stopped working in some of the last updates. Unfortuately I don’t know when exactly I installed the version which broke things but it used to be working until at least two weeks ago.

Currently I’m running Build #1240 and with some guidance from the logs I could find that findFirst makes some problems.

I’m using the same method in several rules but the simplest one showing errors when loading the rules files is the following:

rule "Badheizung aus"
    Item Bad_Heiz_Soll changed or
    Item Wohn_Heiz_Soll changed
    var raum ="_").get(0)

    var modus = Alle_Heiz_Modus.members.findFirst[name.equals(raum+"_Heiz_Modus")].state

    if (modus == "MANU-MODE")
            if (triggeringItem.state == 4.5)
                    postUpdate(raum+"_Heiz_HeizModus", "OFF")
            else if (triggeringItem.state == 30.0)
                    postUpdate(raum+"_Heiz_HeizModus", "HEAT")
                    postUpdate(raum+"_Heiz_HeizModus", "MAN")

It gives the following error:

2018-03-31 16:12:20.429 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'homematic.rules' has errors, therefore ignoring it: [84,47]: mismatched character '.' expecting ']'
[84,79]: mismatched input ']' expecting 'end'

With some try and error and could solve the issue with changing square brackets with normal ones. It’s a bit wired but at least rule file is not ignored anymore.

Is there any known issue or did behavior just change?

Unfortunately afterwards I ran into another issue with the same line when the rule is executed:

2018-03-31 16:19:17.388 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Badheizung aus': The name 'name' cannot be resolved to an item or type; line 84, column 48, length 4

Until now I couldn’t find any solution or why it stopped working.

Is there anybody who is more familiar to all the rule stuff then me having any idea?

I bet you are on the 2.3 snapshot. There was a change made somewhere down stream (probably in Xtend) that made it into OH recently that now requires you to put a space after the [ and before the ].

Alle_Heiz_Modus.members.findFirst[ name.equals(raum+"_Heiz_Modus") ].state
1 Like

Hi Rich,

Again saved me. That did solve all my issues.

I got that something recently changed that broke my rules and since I couldn’t find somebody else reportingg the issue thought my writing is wrong. Tried so many different possibilities but guess that was the only one I missed.

Regards Christian


Does this mean, I have to change this too?

gRestoreStateDT.members.forEach[item | 

to this:

gRestoreStateDT.members.forEach[ item |  <== this space is OK, no real impact
] <== Do I have to put a space here too? Or is the return enough?

I use this for better syntax reading

Yes. There must always be white space (space, tab, newline?) after [ and preceeding ] for now. I don’t know if this will be permanent or not but suspect it will be.

I don’t know if you need a doesn’t it tab if you put the closing bracket on a new line. I’m not running the snapshot do can’t test.

It you can use ( ) without the extra white spaces.

If I put a space before ‘]’ my rule crashed with null exception. Just to know.