@5iver thanks for that. I was missing that gLock group item and just added it. Getting closer but still not working. I manually unlocked here for instance and get the following. When I update the rule now it no longer gives me an error.
2018-04-25 23:18:10.459 [vent.ItemStateChangedEvent] - Door_AlarmRaw changed from {"notification":"ACCESS_CONTROL__MANUAL_LOCK","level":"1","type":"ACCESS_CONTROL","event":"1","status":"255"} to {"notification":"ACCESS_CONTROL__MANUAL_UNLOCK","level":"1","type":"ACCESS_CONTROL","event":"2","status":"255"}
==> openhab.log <==
2018-04-25 23:18:10.702 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Lock: Update lock states after alarm_raw event': cannot invoke method public abstract java.lang.String org.eclipse.smarthome.core.items.Item.getName() on null
Also here is my Lambda and Rule ( basically a copy from above with a few of the SMS Notification, Kodi, and Alarm Notifications commented out.)
import org.eclipse.xtext.xbase.lib.Functions
val Functions$Function1<GenericItem,Boolean> alarmRawParser = [
inputItem |
val actionItem = gLock.members.findFirst[ item | item.name.toString == inputItem.name.toString.replace("_Alarm_Raw","") ]
logDebug("Rules", "Lock: Alarm events: {}=[{}]",actionItem.name,inputItem.state.toString)
switch (transform("JSONPATH","$.type",inputItem.state.toString)) {
case "ACCESS_CONTROL" : {
switch (transform("JSONPATH", "$.event", inputItem.state.toString)) {
case "1", case "3", case "5" : {
actionItem.postUpdate(ON)
logDebug("Rules", "Lock: Alarm events: {} updated to ON (locked)",actionItem.name)
}
case "2", case "4" : {
actionItem.postUpdate(OFF)
logDebug("Rules", "Lock: Alarm events: {} updated to OFF (unlocked)",actionItem.name)
}
case "6" : {
val StringBuilder message = new StringBuilder(actionItem.name)
message.append(" was unlocked with")
switch (transform("JSONPATH", "$.code", inputItem.state.toString)) {
case "1" : {
message.append(" Scott's code")
if (Scott_Region.state != "Home") {
Scott_Region.sendCommand("Home")
message.append(" and presence state was updated")
}
}
case "2" : {
message.append(" Lisa's code")
if (Lisa_Region.state != "Home") {
Lisa_Region.sendCommand("Home")
message.append(" and presence state was updated")
}
}
}
Thread::sleep(100)//wait for Presence state to update so alarm doesn't trigger
actionItem.postUpdate(OFF)
logDebug("Rules", "Lock: {}",message.toString)
//SMS_Notification.sendCommand(message.toString)
}
case "11" : {
logDebug("Rules", "Lock: Alarm events: {} is jammed, so setting lock to OFF (unlocked)",actionItem.label)
actionItem.postUpdate(OFF)
//SMS_Notification.sendCommand(actionItem.label + " is jammed")
//Kodi_Notification.sendCommand(actionItem.label + " is jammed")
}
case "16" : {
val String message = actionItem.label + " keypad is disabled due to too many failed codes"
logDebug("Rules", "Lock: Alarm events: {}",message)
//SMS_Notification.sendCommand(message)
//Kodi_Notification.sendCommand(message)
}
default : {
val String message = "Unknown Event in alarmRawParser, " + inputItem.state.toString
logDebug("Rules", "Lock: Alarm events: {}",message)
//SMS_Notification.sendCommand(message)
}
}
if (transform("JSONPATH", "$.event", inputItem.previousState(true).state.toString) == "11" && transform("JSONPATH", "$.event", inputItem.state.toString) != "11") {
val String message = actionItem.label + " is no longer jammed"
logDebug("Rules", "Lock: Alarm events: {}",message)
//SMS_Notification.sendCommand(message)
//Kodi_Notification.sendCommand(message)
}
}
case "BURGLAR" : {
//gSiren.sendCommand(ON)
val String message = "Intruder at " + actionItem.label
logDebug("Rules", "Lock: Alarm events: {}",message)
//SMS_Notification.sendCommand(message)
//Audio_Notification.sendCommand(message)
}
case "POWER_MANAGEMENT" : {
val String message = "Power Management alarm for " + actionItem.label + ", " + inputItem.state.toString
logDebug("Rules", "Lock: Alarm events: {}",message)
//SMS_Notification.sendCommand(message)
}
default : {
val String message = "Unknown Type in alarmRawParser, " + inputItem.state.toString
logDebug("Rules", "Lock: Alarm events: {}",message)
//SMS_Notification.sendCommand(message)
}
}
true
/*
{"notification":"ACCESS__MANUAL_LOCK", "type":"ACCESS_CONTROL","event":"1","status":"255"}
{"notification":"ACCESS__MANUAL_UNLOCK", "type":"ACCESS_CONTROL","event":"2","status":"255"}
unlocked with zwave? event 3
locked with zwave? event 4
{"notification":"ACCESS__KEYPAD_LOCK", "code":"1", "type":"ACCESS_CONTROL","event":"5","status":"255"}
{"notification":"ACCESS__KEYPAD_UNLOCK","code":"1", "type":"ACCESS_CONTROL","event":"6","status":"255"}
{"notification":"ACCESS__LOCK_JAMMED", "type":"ACCESS_CONTROL","event":"11","status":"255"}
{"notification":"ACCESS__KEYPAD_LOCK", "type":"ACCESS_CONTROL","event":"5","status":"255"}
{"notification":"ACCESS_CONTROL__KEYPAD_TEMPORARILY_DISABLED", "type":"ACCESS_CONTROL","event":"16","status":"255"}
{"notification":"BURGLAR__TAMPER_UNKNOWN", "type":"BURGLAR","event":"2","status":"255"}
{"notification":"HOME_SECURITY__INTRUSION_UNKNOWN", "type":"BURGLAR","event":"2","status":"255"}
{"notification":"POWER__REPLACE_BATTERY_SOON", "type":"POWER_MANAGEMENT","event":"10","status":"255"}
{"notification":"POWER_MANAGEMENT__REPLACE_BATTERY_SOON", "type":"POWER_MANAGEMENT","event":"10","status":"255"}
*/
]
rule "Lock: Update lock states after alarm_raw event"
when
Item Door_AlarmRaw received update
then
alarmRawParser.apply(triggeringItem as GenericItem)
end