OH3 migration upgraded rules don't work-and sytem gets unresponsive in hours. Can't figure it out, suspect triggeringItem.name issue


I migrated my openhabian 2.5 - which was working stable. Now OH3 works OK for a few hours then gets slower and unresponsive until restart. I suspected some rules not working and I also saw a few errors in the logs. I re- created those - mostly they were around Xiaomi actions like button press or cube actions.

I also tried to recreate this rule, but when I use triggeringItem.name it gives me the group the contact belongs to- and this doesn’t not have the right info.

2020-12-27 20:58:44.228 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'contacts-1' failed: cannot invoke method public java.lang.String org.openhab.core.items.GenericItem.getName() on null in contacts

This one however drives me nuts… I am using a open window/door reminder, that was a design pattern which I copied shamelessly :grinning: and worked well for years. Any help is greatly apreciated.

  - id: "0"
      itemName: XiaomiDoorWindowSensor1_OpenStatus
      state: OPEN
      previousState: CLOSED
    type: core.ItemStateChangeTrigger
  - id: "1"
      itemName: XiaomiDoorWindowSensor1_OpenStatus
      state: CLOSED
      previousState: OPEN
    type: core.ItemStateChangeTrigger
 [deleted multiple same triggers  here ]
conditions: []
  - inputs: {}
    id: script
      type: application/vnd.openhab.dsl.rule
      script: >
        // context: contacts-1

        val door = triggeringItem as ContactItem

        // Update LastUpdate

        val last = gDoorsLast.members.filter[dt | dt.name == door.name+"_LastUpdate"].head as DateTimeItem

        last.postUpdate(new DateTimeType)
        // Set/cancel the Timer

        if(door.state == OPEN) sendCommand(door.name+"_Timer", "ON")

        else postUpdate(door.name+"_Timer", "OFF")

        //logInfo("Testing","POST UPDATE "+door.name)

        // Log and alert

        val StringBuilder msg = new StringBuilder

        val doorName = transform("MAP", "en.map", door.name)


        msg.append(" was")

        msg.append(if(door.state == OPEN) " opened" else " closed")

        var alert = false

        if(vTimeOfDay.state.toString == "NIGHT" || vTimeOfDay.state.toString == "BED"){
              alert = true
              msg.append(" and it is night")

        //if(vPresent.state == OFF) {
          //  alert = true
         //   msg.append(" and no one is home")


        else {
          logInfo(logName, msg.toString)
    type: script.ScriptAction

triggeringItem now only works with members of group it appears.

As you are triggering just on one item, you may replace triggeringItem with the exact item XiaomiDoorWindowSensor1_OpenStatus.

I removed the 15 other identical sensors in my example :grin: So that makes the problem that I need 15 independent instances of reminders, as for venting always multiple windows get opened ( and forgotten)

OK, i overread this. :smiley:

Then put all your sensors in a group and use Member of [your new sensorgroup] as trigger. For Member of the triggeringItem is still working as far as i read and @garyfree already wrote.

What I did for compass points - add to a group and it still works as triggeringItem