It isn't too big of a deal if the description changes although if the lock is not being upgraded, I would be surprised if something changed the text. I am just putting this out there in case someone else out there has a Schlage lock and wants to use this. The purpose for this will vary per user but it was a GREAT starting point that you provided.
For the Schlage lock, there are several Events that can be looked at. I wanted this app to account for everything other than a user code unlocking the door. So I added some or statements to your if conditions. Now the virtual switches will be set correctly if I lock or unlock the door from inside, from the keypad outside, or using the "Lock" dashboard tile. The Dashboard tile is still technically manually locking or unlocking the door in my opinion but that event is digital instead of physical.
For my purpose I am having the virtual switches turn off after a short time otherwise when a user code is entered to unlock the door, the "Locked Manually" switch stays on and doesn't toggle off like it would if the door was manually unlocked. In the end, I will most likely only use the Unlocked switch and set the Locked switch required to false since my rule is just checking to see if the Unlocked Manually switch is off to proceed. I just wanted to update the if statements to learn and give more options in case they were needed.
I am still tweaking things and just learning this but thought I would share to give others some ideas on what can be done with your app.
def lockHandler(evt) {
log("Lock event: ${evt.name} : ${evt.descriptionText}")
if (evt.type == 'physical' && (evt.descriptionText.endsWith('thumb turn [physical]') || evt.descriptionText.endsWith('keypad [physical]'))) || (evt.type == 'digital' && (evt.descriptionText.endsWith('locked [digital]'))) {
log "${lock.displayName} was locked manually"
virtualLockedSwitch.on()
if (virtualUnlockedSwitch) {
virtualUnlockedSwitch.off()
}
} else {
log "${lock.displayName} was locked"
}
}
def unlockHandler(evt) {
log("Unlock event: ${evt.name} : ${evt.descriptionText}")
if (evt.type == 'physical' && evt.descriptionText.endsWith('thumb turn [physical]') || (evt.type == 'digital' && (evt.descriptionText.endsWith('unlocked [digital]'))) {
log "${lock.displayName} was unlocked manually"
virtualLockedSwitch.off()
if (virtualUnlockedSwitch) {
virtualUnlockedSwitch.on()
}
} else {
log "${lock.displayName} was unlocked"
Schlage Lock Events for Reference
Lock name = Front Door Lock. (Varies per installation)
Locked using keypad Schlage button or code.
Lock event: lock : Front Door Lock was locked by keypad [physical]
Locked using inside dial.
Lock event: lock : Front Door Lock was locked by thumb turn [physical]
Locked using automation or dashboard tile.
Lock event: lock : Front Door Lock was locked [digital]
Unlocked using code.
Unlock event: lock : Front Door Lock was unlocked by John
Unlocked using inside dial.
Unlock event: lock : Front Door Lock was unlocked by thumb turn [physical]
Unlocked using automation or dashboard tile.
Unlock event: lock : Front Door Lock was unlocked [digital]