Zwave - Yale YRD220 Lock

z-wave
Tags: #<Tag:0x00007f1e56e503a0>
(Scott Rushworth) #152

Change the $.code to $.level. And change the codes to match yours.

Yes.

1 Like

(Kris K) #153

Thanks Scott. Do you know if theres a way to remotely unlock the door using codes for testing purposes? ie: not physically entering the code.

I assume by switching the lock on/off via PaperUI it would count this as RF Lock or RF unlock (Alarm type 0x19 or 0x18)

0 Likes

(Scott Rushworth) #154

The codes are only able to be used on the keypad.

Yes. I believe you have examples of both here…

0 Likes

(Kris K) #155

Indeed, Level 1 (RF function), Event 3 - Lock or Even 4, Unlock

Getting my head around it now!

0 Likes

(Kris K) #156

Hi Scott,

In your rule, what is this used for? It appears commented.Id like to build into a dashboard an ability to display who/who unlocked/locked the door last.

/*
        {"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"}
    */
0 Likes

(Scott Rushworth) #157

It’s a multiline comment… just information, in case someone could use it. It’s a list of all alarms I’ve seen. I need to fill in the event 3 & 4.

I think the easiest way to do that may be to add another Item to hold that info. Then set it in case 6. The rule currently doesn’t identify who locked a door with a code, but tthat coud easily be added.

0 Likes

(Kris K) #158

Hi Scott

So define a proxy item

String UserCode                       "Last Code Used on the Door"

With rule modification


                case "6" : {
                    val StringBuilder message = new StringBuilder(actionItem.name)
                    message.append(" was unlocked with")
                    switch (transform("JSONPATH", "$.level", triggeringItem.state.toString)) {
                        case "1" : {
                            message.append(" Jodies Code")
                            UserCode.postUpdate(message.append.toString)
                        }

???

0 Likes

(Scott Rushworth) #159
                case "6" : {
                    actionItem.postUpdate(OFF)
                    val StringBuilder message = new StringBuilder(actionItem.name)
                    message.append(" was unlocked with")
                    switch (transform("JSONPATH", "$.code", triggeringItem.state.toString)) {
                        case "1" : {
                            message.append(" Jodie's code")
                        }
                        case "2" : {
                            message.append(" Kris' code")
                        }
                    }
                    logDebug("Rules", "Lock: {}",message.toString)
                    UserCode.postUpdate(message.toString)
                }
0 Likes

(Hector G) #160

Kris, sorry for the late response, I must have missed the notification on this. I had a few errors. First my mysql persistence was not working due to a misconfiguration on my end. I uninstalled everything and reinstalled and reconfigured everything from scratch and that began working. Then I didn’t understand that you could do persistence for individual items vs groups so I had that configured incorrectly as well. Once I read a little more into it and figured out ow it all worked, I reconfigured and everything began working. It’s been a little bit since I fixed it so there may be more but that was what I remembered from it.

1 Like

(Kris K) #161

Thanks fifo! I managed to get mine all sorted too :slight_smile:

EDIT: Spoke too soon

0 Likes

(Hector G) #162

ok great to hear! :slight_smile:

0 Likes

(Kris K) #163

@5iver

I recently moved my system to a new machine and am encountering this error again.

My PaperUI default persistence is as you suggested, influx.

19:51:34.391 [ERROR] [untime.internal.engine.RuleEngineImpl] - Rule 'Lock: Update lock states after alarm_raw event': cannot invoke method public abstract org.eclipse.smarthome.core.types.State org.eclipse.smarthome.core.persistence.HistoricItem.getState() on null

My persistance file is as it was

MapDB.persist

 FrontDoor_DoorLock_Alarm_Raw : strategy = everyChange
 FrontDoor_DoorLock : strategy = everyChange, everyHour, everyDay, restoreOnStartup

There was nothing relating to the locks in influxdb.persist.

And the rule is as it was. The error triggered when I used a manual twist of the lock.

rule "Lock: Update lock states after alarm_raw event" when
    Item FrontDoor_DoorLock_Alarm_Raw received update then
    val actionItem = gLock.members.findFirst[ item | item.name.toString == triggeringItem.name.toString.replace("_Alarm_Raw","") ]
    logInfo("Rules", "Lock: Alarm events: {}=[{}]",actionItem.name,triggeringItem.state.toString)
    switch (transform("JSONPATH","$.type",triggeringItem.state.toString)) {
        case "ACCESS_CONTROL" : {
            switch (transform("JSONPATH", "$.event", triggeringItem.state.toString)) {
                      case "1" : {
                    actionItem.postUpdate(ON)
                    logInfo("FrontDoor", "Lock: Alarm events: {} updated to Locked",actionItem.name)
                    val StringBuilder message = new StringBuilder("Locked via")
                    switch (transform("JSONPATH", "$.level", triggeringItem.state.toString)) {
                       case "1" : {
                            message.append(" Twist Knob")
                        }
                        case "2" : {
                            message.append(" Lock and Leave")
                        }
                    }
                     logInfo("FrontDoor", "Lock: {}",message.toString)
                    if(gPresenceSensors.state == OFF) {
                        sendBroadcastNotification(message.toString)
                    }
                    if(gPresenceSensors.state == ON) {
                    /*gAllEchoAlerts.sendCommand(message.toString)*/
                    UserCode.postUpdate(message.toString)
                  }
                }
                case "2" : {
                    actionItem.postUpdate(OFF)
                    val StringBuilder message = new StringBuilder("Unlocked via TwistKnob")
                    logInfo("FrontDoor", "Unlock: {}",message.toString)
                    if(gPresenceSensors.state == OFF) {
                    sendBroadcastNotification(message.toString)
                    }
                    if(gPresenceSensors.state == ON) {
                    /*gAllEchoAlerts.sendCommand(message.toString)*/
                    UserCode.postUpdate(message.toString)
                  }
                }
                case "3" : {
                    actionItem.postUpdate(ON)
                    val StringBuilder message = new StringBuilder("Locked via UI")
                    logInfo("FrontDoor", "Lock: {}",message.toString)
                    if(gPresenceSensors.state == OFF) {
                      sendBroadcastNotification(message.toString)
                    }
                    if(gPresenceSensors.state == ON) {
                      /*gAllEchoAlerts.sendCommand(message.toString)*/
                      UserCode.postUpdate(message.toString)
                  }
                }
                case "4" : {
                    actionItem.postUpdate(OFF)
                    val StringBuilder message = new StringBuilder("Unlocked via UI")
                    logInfo("FrontDoor", "Unlock: {}",message.toString)
                    if(gPresenceSensors.state == OFF) {
                      sendBroadcastNotification(message.toString)
                    }
                    if(gPresenceSensors.state == ON) {
                      /*gAllEchoAlerts.sendCommand(message.toString)*/
                      UserCode.postUpdate(message.toString)
                    }
                }
                case "5" : {
                    actionItem.postUpdate(ON)
                    val StringBuilder message = new StringBuilder("Locked with ")
                    switch (transform("JSONPATH", "$.level", triggeringItem.state.toString)) {
                        case "1" : {
                            message.append(" Jodies Code")
                        }
                        case "2" : {
                            message.append(" Kris Code")
                        }
                        case "3" : {
                            message.append(" user code 3")
                        }
                        case "4" : {
                            message.append(" user code 4")
                        }
                        case "5" : {
                            message.append(" user code 5")
                        }
                    }
                    logInfo("FrontDoor", "Lock: {}",message.toString)
                    if(gPresenceSensors.state == OFF) {
                        sendBroadcastNotification(message.toString)
                    }
                    if(gPresenceSensors.state == ON) {
                        /*gAllEchoAlerts.sendCommand(message.toString)*/
                        UserCode.postUpdate(message.toString)
                    }
                }
                case "6" : {
                    actionItem.postUpdate(OFF)
                    val StringBuilder message = new StringBuilder("Unlocked with")
                    switch (transform("JSONPATH", "$.level", triggeringItem.state.toString)) {
                        case "1" : {
                            message.append(" Jodies Code")
                        }
                        case "2" : {
                            message.append(" Kris Code")
                        }
                        case "3" : {
                            message.append(" user code 3")
                        }
                        case "4" : {
                            message.append(" user code 4")
                        }
                        case "5" : {
                            message.append(" user code 5")
                        }
                        case "251" : {
                            message.append(" Master code")
                        }
                    }
                    logInfo("Rules", "Unlock: {}",message.toString)
                    if(gPresenceSensors.state == OFF) {
                        sendBroadcastNotification(message.toString)
                     }
                     if(gPresenceSensors.state == ON) {
                          /*gAllEchoAlerts.sendCommand(message.toString)*/
                          UserCode.postUpdate(message.toString)
                      }
                }
                case "11" : {
                    logInfo("Rules", "Lock: Alarm events: {} is jammed, so setting lock to OFF (unlocked)",actionItem.label)
                    actionItem.postUpdate(OFF)
                    sendBroadcastNotification(actionItem.label + " is jammed")
                }
                case "13" : {
                    val String message = "Front Door Usercode has been deleted"
                    logInfo("Rules", "Door Lock: User Code: {}",message)
                }
                case "14" : {
                    val String message = "Front Door Usercode has been added"
                    logInfo("Rules", "Door Lock: User Code: {}",message)
                }
                case "16" : {
                    val String message = actionItem.label + " keypad is disabled due to too many failed codes"
                    logInfo("Rules", "Lock: Alarm events: {}",message)
                }
                default : {
                    val String message = "Unknown door lock Event, " + triggeringItem.state.toString
                    logInfo("Rules", "Lock: Alarm events: {}",message)
                    sendBroadcastNotification(message)
                }
            }
            if (transform("JSONPATH", "$.event", triggeringItem.previousState(true, "influxdb").state.toString) == "11" && transform("JSONPATH", "$.event", triggeringItem.state.toString)
!= "11") {
                val String message = actionItem.label + " is no longer jammed"
                logInfo("Rules", "Lock: Alarm events: {}",message)
            }
        }
        case "BURGLAR" : {
            FrontDoorLock_Tamper.sendCommand(ON)
            val String message = "Intruder at " + actionItem.name
            logInfo("Tamper Alert", "Lock: Alarm events: {}",message)
        }
        case "POWER_MANAGEMENT" : {
            val String message = "Power Management alarm for " + actionItem.label + ", " + triggeringItem.state.toString
            logInfo("Rules", "Lock: Alarm events: {}",message)
            //SMS_Notification.sendCommand(message)
        }
        default : {
            val String message = "Unknown Type in alarmRawParser, " + triggeringItem.state.toString
            logInfo("Rules", "Lock: Alarm events: {}",message)
            //SMS_Notification.sendCommand(message)
        }
    }
end

0 Likes

(Scott Rushworth) #164

If you are using influx for persistence, then you need an influx.persist file, and FrontDoor_DoorLock_Alarm_Raw needs to be in there.

1 Like

(Kris K) #165

I really need more sleep :frowning: I had the items in the wrong file. Sorry for wasting your time!

0 Likes

(Richard Bergen) #166

Not sure where I’m going wrong, I used @ptmuldoon 's code from Nov 17 for my Yale lock. Here’s my code.

My Yale lock alarm raw status uses “type 21, value 2” when locked with the touch buttons on the front and “Type 22, value 2” when unlocking.

Here’s the rule:

rule "Lock: Update lock states after alarm_raw event"
when
    Item Lock_SideGarage_Alarm_Raw received update
then
    val actionItem = gLock.members.findFirst[ item | item.name.toString == triggeringItem.name.toString.replace("_Alarm_Raw","") ]
   
    logDebug("lock rule triggered")
    
    logDebug("Rules", "Lock: Alarm events: {}=[{}]",actionItem.name,triggeringItem.state.toString)
            switch (transform("JSONPATH", "$.type", triggeringItem.state.toString)) {
                case "21" : {
                    actionItem.postUpdate(ON)
                    logDebug("Rules", "Lock: Alarm events: {} updated to ON (locked)",actionItem.getName)
                }
                case "22" : {
                    actionItem.postUpdate(OFF)
                    logDebug("Rules", "Lock: Alarm events: {} updated to OFF (unlocked)",actionItem.getName)
                }
                case "19" : {
                    switch (transform("JSONPATH", "$.value", lockAlarmRaw.state.toString)) {
                        case "1" : {
				actionItem.postUpdate(OFF)
                        }
                        case "2" : {
				actionItem.postUpdate(OFF)
                        }
                    }
                }
            }
end

Here’s my items

Switch 	               	Lock_SideGarage			"Lock (Garage Side Door) [MAP(lock.map):%s]"	<lock>      	(gLock)	{channel="zwave:device:512:node4:lock_door"}
String 	              	Lock_SideGarage_Alarm_Raw    	"Lock (Garage Side Door): Alarm Raw [%s]"	<shield>        (glock) {channel="zwave:device:512:node4:alarm_raw"}

When the lock updates, it triggers the rule but I just get an error with not very much info in it and not sure how to troubleshoot from here:

[ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Lock: Update lock states after alarm_raw event': An error occurred during the script execution: index=1, size=1

I have JSON Path Transformation installed

Hope someone can point out an obvious mistake I’m making… I’m stumped.

0 Likes

(Scott Rushworth) #167

What is lockAlarmRaw? If this isn’t the cause of the error, add debug lines between every line to see where the script fails. Everything else looks OK, but I’d use the name attribute rather than the getName method. Also, be careful with the group names. You have gLock and glock. Maybe use gLockRaw for one of them?

0 Likes

(Richard Bergen) #168

Good question. Looks like it was a remnant of my copy/paste from other examples. Changed that to “triggeringItem.state.toString”

I commented out all the lines and started to turn them on in small chunks. Looks like the problem was with “logDebug”. As soon as I commented out all the “logDebug” lines, it seemed to work fine. If I change the “logDebug” with “logInfo” as I’ve used in other rules, it seemed to work. Not sure why logDebug doesn’t work. At least the script seems to run now without errors.

0 Likes