openHAB 5.1 - Rules that use members.forEach are ignored because of missing context

Hi there,

i just updated openHAB from 5.0.2 and 5.1.
I checked the breaking changes and adjusted all my persistence files before.
Maybe i missed an annoucement to this topic but my rules worked until the upgrade.

Every rule where i use <group>.members.forEach is ignored due to this error:

DSL model 'XYZ.rules' has errors, therefore ignoring it:
There is no context to infer the closure's argument types from. Consider typing the arguments or put the closures into a typed context.

Some examples:

gEchoCommands.members.forEach[ i | i.postUpdate('')]
gLicht.members.filter[i | i.state != OFF].forEach[i | i.sendCommand(OFF)]
Tankstellen.members.forEach[ i | GasPrices.append(i.label+": " + String::format("%.3f", (i.state as Number).doubleValue)+"€/l (" + String::format("%.3f", (i.minimumSince(now.minusDays(1), "influxdb").state as Number).doubleValue)+"€/l)\n")]

But i“m also using some more complex approaches:

AralTankstellen.members.filter[i | i.state != UNDEF].forEach[ i | 
        val String stationNameItem = i.name.split("_").get(0) + "_Name"  
        val stationName = ScriptServiceUtil.getItemRegistry.getItem(stationNameItem)?.state.toString ?: "Unbekannt" 
        val String stationPrice = String::format("%.3f", (i.state as Number).doubleValue)
        val String minimumPrice = String::format("%.3f", (i.minimumSince(now.minusDays(1), "influxdb").state as Number).doubleValue)
        GasPrices.append(stationName + ": " + stationPrice + "€/l (" + minimumPrice + "€/l)\n")
    ]

I“ve already seen this thread with a similiar problem:

The solution was to add SwitchItem as a context.
I“m not sure what i need to add to my rules to get them working again.
Is there a documentation what context i need to use for different types of groups?

Honest question, shouldn“t this be declared as a breaking change?

Cheers

Are you sure the rules are ignored and not working?
I have this error for rules with members.forEach every time after clearing the cache, but the rules are working fine.
The second start does not show the error anymore …
Therefore I did not yet invest any time to find the culprit.

Yeah, the rules were ignored.
The first reboot still showed them as ignored and a bunch of others errors.
For example the telegram action was shown to be missing in org.openhab.actions
The second reboot fixed the issue and the rules with groups and forEach are working again.

1 Like