Hello,
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 and worked well for years. Any help is greatly apreciated.
triggers:
- id: "0"
configuration:
itemName: XiaomiDoorWindowSensor1_OpenStatus
state: OPEN
previousState: CLOSED
type: core.ItemStateChangeTrigger
- id: "1"
configuration:
itemName: XiaomiDoorWindowSensor1_OpenStatus
state: CLOSED
previousState: OPEN
type: core.ItemStateChangeTrigger
[deleted multiple same triggers here ]
conditions: []
actions:
- inputs: {}
id: script
configuration:
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(doorName)
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")
if(alert){
msg.append("!")
aAlert.sendCommand(msg.toString)
}
else {
logInfo(logName, msg.toString)
}
type: script.ScriptAction