Zwave - Yale YRD220 Lock

z-wave
Tags: #<Tag:0x00007f51ea8aa168>

(Hector G) #90

@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


(Scott Rushworth) #91

Double check your item names with the example. The String item should end with _Alarm_Raw or the very first line of the lambda will error. You should also comment out the lines in the section for user codes… unless you have also Scott_Region and Lisa_Region. :wink:


(Hector G) #92

Since I created the lock items with PaperUI, all may Alarm Raw items end in _AlarmRaw so I changed the line up top instead.

 val actionItem = gLock.members.findFirst[ item | item.name.toString == inputItem.name.toString.replace("_AlarmRaw","") ]

I assume this is ok. I am only testing with one lock at the moment.

Doesn’t look like it fixed the issue but I do see where the issue would have occurred since it did not match.

==> openhab.log <==
2018-04-26 01:19:27.633 [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

Here is my rule now…

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("_AlarmRaw","") ]
    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


(Scott Rushworth) #93

Yes, that would work too! If it is still not working, what is the name for your lock Switch item? The lambda would expect it to be Door.


(Hector G) #94

I understand it’s not very descriptive. I was just testing so made it simple. It is Door_AlarmRaw. I just changed it to say GarageDoor_AlarmRaw and updated rule.

rule "Lock: Update lock states after Alarm Raw event"
when
        Item GarageDoor_AlarmRaw received update

==> events.log <==
2018-04-26 07:26:32.405 [vent.ItemStateChangedEvent] - GarageDoor_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-26 07:26:32.421 [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

==> events.log <==
2018-04-26 07:26:36.120 [vent.ItemStateChangedEvent] - GarageDoor_AlarmRaw changed from {"notification":"ACCESS_CONTROL__MANUAL_UNLOCK","level":"1","type":"ACCESS_CONTROL","event":"2","status":"255"} to {"notification":"ACCESS_CONTROL__MANUAL_LOCK","level":"1","type":"ACCESS_CONTROL","event":"1","status":"255"}

==> openhab.log <==
2018-04-26 07:26:36.128 [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



(Scott Rushworth) #95

I was asking about the other item. It should be a Switch item and named GarageDoor, based on the current name of your String item. This is the item that you would toggle in a sitemap, and which the lambda is updating based on the info it is receiving through the alarm_raw channel. The error you are getting could be caused by this item not being created yet or if it is not in the gLock group.

I also just noticed your GarageDoor_AlarmRaw item is not in gLock either. You will need to add the two items to a group named gLock or modify the group used in the lambda.


(Hector G) #96

Hmm, I must be confused. I have this switch configured here as well as in my items file. In the items file I have the group. I think what you are saying is that what I need is a proxy switch instead of redefining the same switch in items file? I’ll look it over tonight. I must have missed something. It didn’t make sense to me that I was redefining the switch again. So if I got this straight, in the items file the name I should define is the proxy switch name. And leave this as is in the paper you?

This is what I have in my items file currently. The z-wave channel is pointing to the thing switch that was created with with Paper UI as is the alarm raw respectively.

Group:Switch:OR(OFF,ON) gLock "Locks [MAP(lock.map):%s]" <lock>                                        

Switch GarageDoor_DoorLock "Lock (Garage Home) [MAP(lock.map):%s]" <lock> (gUS_GarageHome,gLock,gSleep_Security) {channel="zwave:device:56857ebd:node37:lock_door"}                                         

String GarageDoor_AlarmRa![Screenshot_20180426-125005_Chrome|243x500](upload://b6zDiRj7K2KTqkcrB41gQQxwwMk.jpg)w "Lock (Garage Home): Alarm Raw [%s]" <shield> (gUS_GarageHome) {channel="zwave:device:56857ebd:node37:alarm_raw"}                                                                    

Finally here is the item you were expecting in last post…


(Scott Rushworth) #97

If the String item is named XXXXX, the lambda is expecting the Switch item to be named XXXXX_Alarm_Raw. I suggest you delete the items you have created in PaperUI and use items defined in an items file. Just get the names formatted properly and you should be good to go.


(Hector G) #98

Ok I will try that out. So I should leave the thing in Paper UI, delete the Paper UI items and leave the items I have created in the items file correct?


(Scott Rushworth) #99

Correct


(Hector G) #100

ok I just tried it and still getting the error. I also added the gLock group to both items.

==> events.log <==
2018-04-26 20:50:21.654 [vent.ItemStateChangedEvent] - GarageDoor_AlarmRaw changed from {"notification":"ACCESS_CONTROL__MANUAL_UNLOCK","level":"1","type":"ACCESS_CONTROL","event":"2","status":"255"} to {"notification":"ACCESS_CONTROL__MANUAL_LOCK","level":"1","type":"ACCESS_CONTROL","event":"1","status":"255"}

==> openhab.log <==
2018-04-26 20:50:21.659 [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

(Scott Rushworth) #101

Try restarting OH. If that does not help, confirm again that you have both the JSONPATH and MAP transform services, and post your items, rule and MAP file.


(Hector G) #102

Restarted OH

and still having same issue.

Here is my config below.

Verified installed Transformations
-transformation-jsonpath - 2.3.0.SNAPSHOT
-transformation-map - 2.3.0.SNAPSHOT

/opt/openhab2/conf/items/my.Items

Group:Switch:OR(OFF,ON) gLock "Locks [MAP(lock.map):%s]" <lock>

Switch GarageDoor_DoorLock "Lock (Garage Home) [MAP(lock.map):%s]" <lock> (gLock) {channel="zwave:device:56857ebd:node37:lock_door"}
String GarageDoor_Alarm_Raw "Lock (Garage Home): Alarm Raw [%s]" <shield> (gLock) {channel="zwave:device:56857ebd:node37:alarm_raw"}

/opt/openhab2/rules/lock.rules

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 GarageDoor_Alarm_Raw received update
then
        alarmRawParser.apply(triggeringItem as GenericItem)
end

/opt/openhab2/transform/lock.map

0=CLOSED
ON=CLOSED
252=CLOSING
253=STOPPED
254=OPENING
255=OPEN
OFF=OPEN
-=Unknown
NULL=Unknown

and the error

2018-04-26 21:27:36.507 [vent.ItemStateChangedEvent] - GarageDoor_Alarm_Raw 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-26 21:27:36.712 [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

(Scott Rushworth) #103

Change your items to this…

Switch GarageDoor_DoorLock "Lock (Garage Home) [MAP(lock.map):%s]" <lock> (gLock) {channel="zwave:device:56857ebd:node37:lock_door"}
String GarageDoor_DoorLock_Alarm_Raw "Lock (Garage Home): Alarm Raw [%s]" <shield> (gLock) {channel="zwave:device:56857ebd:node37:alarm_raw"}

The lambda is expecting the names in this format. This would cause the error.


(Hector G) #104

Finally :scream:

:smiley:

Thank you so much this was driving me crazy!!! That did the trick but I also had to make an update to the rule as shown below… ( in case anyone needs this going forward…) Ill have to study the code to see why the names that matched didnt work … I guess its expecting both items to be identical + “_Alarm_Raw” for the raw item…

rule "Lock: Update lock states after Alarm Raw event"
when
        Item GarageDoor_DoorLock_Alarm_Raw received update
then
        alarmRawParser.apply(triggeringItem as GenericItem)
end

(Scott Rushworth) #105

You are welcome… I’m glad it is all working now!


(Hector G) #107

I claimed victory too soon. I noticed shortly after I got it working that the sitemap was no longer updating. A restart gets it to work again but only a few times. Recreating the situation with logs enabled I see when it is working that it goes through the rule and the debug logs are reflected. When it stops working I see the entries from the locks when I manually lock and unlock them but I no longer see the debug from the rule. Any clue in what could be happening?other than the the system seems to be working properly.


(Scott Rushworth) #108

If the rule works for a while and then stops, then it must be a deeper issue. Are you on a Pi?

If you look back at my original post of the rule, I’ve modified it to remove the lambda and simplify things a bit. I do not think this will help with your current issue though.


(Hector G) #109

No I am actually running it on a laptop. Not very powerful, but fast enough for what I am doing with it. I am running Ubuntu desktop so maybe I will remove the desktop and see if that frees some resources. I’ll do some more research tomorrow.


(Hector G) #110

I changed the rule to reflect the new one above without the Lambda. I also replaced the Ubuntu desktop with XFCE which is much lighter on resources. I am still experiencing the same issue where on reboot it works a few times and just stops working.

I don’t believe its a system resource issue as my CPU is at 1.2% average and I have 3GB of Memory and only about 1.32% is being used when idle. Since it looks like my lock issue is fixed but now having other issues, should I create another post? Thanks again and of course if you think of something I could try , please let me know.

This is what my logs shows.

After a reboot ( when it works)

==> openhab.log <==
2018-04-29 08:07:36.432 [DEBUG] [eclipse.smarthome.model.script.Rules] - Lock: Alarm events: GarageDoor_DoorLock=[{"notification":"ACCESS_CONTROL__MANUAL_LOCK","level":"1","type":"ACCESS_CONTROL","event":"1","status":"255"}]
2018-04-29 08:07:36.450 [DEBUG] [eclipse.smarthome.model.script.Rules] - Lock: Alarm events: GarageDoor_DoorLock updated to ON (locked)
2018-04-29 08:07:39.368 [DEBUG] [eclipse.smarthome.model.script.Rules] - Lock: Alarm events: GarageDoor_DoorLock=[{"notification":"ACCESS_CONTROL__MANUAL_UNLOCK","level":"1","type":"ACCESS_CONTROL","event":"2","status":"255"}]
2018-04-29 08:07:39.375 [DEBUG] [eclipse.smarthome.model.script.Rules] - Lock: Alarm events: GarageDoor_DoorLock updated to OFF (unlocked)
2018-04-29 08:07:41.338 [DEBUG] [eclipse.smarthome.model.script.Rules] - Lock: Alarm events: GarageDoor_DoorLock=[{"notification":"ACCESS_CONTROL__MANUAL_LOCK","level":"1","type":"ACCESS_CONTROL","event":"1","status":"255"}]
2018-04-29 08:07:41.341 [DEBUG] [eclipse.smarthome.model.script.Rules] - Lock: Alarm events: GarageDoor_DoorLock updated to ON (locked)
2018-04-29 08:07:43.926 [DEBUG] [eclipse.smarthome.model.script.Rules] - Lock: Alarm events: GarageDoor_DoorLock=[{"notification":"ACCESS_CONTROL__MANUAL_UNLOCK","level":"1","type":"ACCESS_CONTROL","event":"2","status":"255"}]
2018-04-29 08:07:43.931 [DEBUG] [eclipse.smarthome.model.script.Rules] - Lock: Alarm events: GarageDoor_DoorLock updated to OFF (unlocked)
2018-04-29 08:07:45.626 [DEBUG] [eclipse.smarthome.model.script.Rules] - Lock: Alarm events: GarageDoor_DoorLock=[{"notification":"ACCESS_CONTROL__MANUAL_LOCK","level":"1","type":"ACCESS_CONTROL","event":"1","status":"255"}]
2018-04-29 08:07:45.632 [DEBUG] [eclipse.smarthome.model.script.Rules] - Lock: Alarm events: GarageDoor_DoorLock updated to ON (locked)

Without me doing anything other than locking and unlocking the lock, a few seconds later it stops working and the logs change from the above to this below.

2018-04-29 08:20:18.972 [vent.ItemStateChangedEvent] - GarageDoor_DoorLock_Alarm_Raw changed from {"notification":"ACCESS_CONTROL__MANUAL_UNLOCK","level":"1","type":"ACCESS_CONTROL","event":"2","status":"255"} to {"notification":"ACCESS_CONTROL__MANUAL_LOCK","level":"1","type":"ACCESS_CONTROL","event":"1","status":"255"}
2018-04-29 08:20:20.328 [vent.ItemStateChangedEvent] - GarageDoor_DoorLock_Alarm_Raw 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"}