Problems with rule after migration

Hi There,

I’ve done a double-migration. First from openhab 1.7.1 to 1.8.1 and next from Debian Wheezy to Jessie. And now I have a problem with one of my main rules which I cannot explain.

This function is getting called from different rules:

val org.eclipse.xtext.xbase.lib.Functions$Function4 setHeaterOperatingModes = [
    int HeaterModeMainComfortZoneValue,
    int HeaterComfortZoneValue,
    int HeaterOutbuildingsValue,
    int HeaterManualZoneValue |
    
    HeaterModeMainComfortZone?.members.forEach[element1,index1|
      logInfo("Heating","Set State for MainComfortZone: " + HeaterModeMainComfortZoneValue)
      if (element1.state != HeaterModeMainComfortZoneValue) {
        logInfo("Heating","State for MainComfortZone was different from last state")
        sendCommand(element1, HeaterModeMainComfortZoneValue)
      } 
    ]
    HeaterComfortZone?.members.forEach[element1,index1|
      logInfo("Heating","Set State for ComfortZone: " + HeaterComfortZoneValue)
      if (element1.state != HeaterComfortZoneValue) {
        logInfo("Heating","State for MainComfortZone was different from last state")
        sendCommand(element1, HeaterComfortZoneValue)
      } 
    ]
    HeaterOutbuildings?.members.forEach[element1,index1|
      if (element1.state != HeaterOutbuildingsValue) {
        sendCommand(element1, HeaterOutbuildingsValue)
      }
    ]
]

And now, there are multiple crazy things:

  1. I can find entries in my logfiles with “State for MainComfortZone was different from last state” but in the events.log there are no updates for the items in MainComfortZone. So obviously the “sendCommand” wasn’t triggered
  2. None of the logs in the “ComfortZone” section are getting called - but there is exactly one Item in the Group “HeaterComfortZone” so it is absolutely impossible, that HeaterComfortZone is empty

Are there any known issues with the rule engine in 1.8.1 or togehter with Jessie?

I don’t know for sure what is wrong but this is what I would do to debug.

First, change to element1.sendCommand(value) instead of sendCommand(element1, value). It usually works better and often when it doesn’t work you get more meaningful errors.

Second, get rid of the ‘?’ before .members. This causes it to skip over that line of the group is null, i.e. fail silently. When debugging a problem the last thing in the world you want is for something to fail silently.

Third, before each forEach line add a logging statement to print out some information about the group’s members (e.g. members.size) to see if what you think is in each group is actually there.