With Update to 5.1 I get There is no context to infer the closure's argument types from in switch rule

After updating to OPENHab 5.1 I have error in one of my rules file:

There is no context to infer the closure’s argument types from. Consider typing the arguments or put the closures into a typed context.

I have narrowed to following rule:

rule “3state”

when

Item My3stateSwitch changed

then

val Boolean log = true

switch (My3stateSwitch.state as Number) {

case  0 : {

  gAllTelevisions?.members.forEach\[sw|

    sw.sendCommand(OFF)

    Thread::sleep(1000)

    if (log) logInfo('rules', ' Regel 3state Fernseher alle aus: ' + sw.name + ' = ' + sw.state.toString())

  \]

}

case  1 : {

  gAllTelevisions?.members.forEach\[sw|

    sw.sendCommand(ON)

    Thread::sleep(1000)

    if (log) logInfo('rules', ' Regel 3state Fernseher alle ein: ' + sw.name + ' = ' + sw.state.toString())

  \]

}

case 2 : {}

}

end

the items definition:

// Televisions

Group gTelevisions

Group gTvsOff0245

Group gTvsOff0545

Number My3stateSwitch “Fernseher Strom ein [MAP(3states.map):%s]”

Switch TvBuero “Büro [MAP(einaus.map):%s]” (gAllTelevisions, gTelevisions, gTvsOff0245) {channel=“homematic:HMIP-PS:3014F711A0001F58A9A72225:000218A995F548:3#STATE”}

Switch TVWohnzimmer “Wohnzimmer [MAP(einaus.map):%s]” (gAllTelevisions, gTelevisions, gTvsOff0545) {channel=“homematic:HM-LC-Sw1-PCB:3014F711A0001F58A9A72225:PEQ0662618:1#STATE”}

Switch TvNicole “Nicole [MAP(einaus.map):%s]” (gAllTelevisions, gTelevisions, gTvsOff0545) {channel=“homematic:HM-LC-Sw1-Pl-DN-R1:3014F711A0001F58A9A72225:OEQ1359807:1#STATE”}

Switch TvBedroom “Schlafzimmer [MAP(einaus.map):%s]” (gAllTelevisions) {channel=“homematic:HM-LC-Sw1-Pl-DN-R1:3014F711A0001F58A9A72225:OEQ1359811:1#STATE”}

Switch TvFittness “Fitness [MAP(einaus.map):%s]” (gAllTelevisions, gTelevisions) {channel=“homematic:HMIP-PS:3014F711A0001F58A9A72225:000218A995F432:3#STATE”}

Switch TvGaeste “Gäste [MAP(einaus.map):%s]” (gAllTelevisions, gTelevisions, gTvsOff0545) {channel=“homematic:HMIP-PS:3014F711A0001F58A9A72225:00021A498F91D7:3#STATE”}

I know there where a lot of changes with OPENhab 5.x but do not find what I have to change to make the rule work again.

OpenHab Version 5.1

Based on the error message, I’d say try:

gAllTelevisions?.members.forEach[SwitchItem sw|

Thanks, that was the solution!

1 Like