My updated code for my Schlage lock is below. I added the (evt.type == 'digital' && (evt.descriptionText.endsWith('unlocked [digital]') comments to track the difference between a manual and digital unlock event. I then use this Virtual Switch in my If logic in my rule. You will need to see how your Yale lock reports the "Digital" event to see if it is the same as the Schlage or not. I am not a developer, I was just able to tweak this to make it work for me.
/*
Installation Notes:
You must create a Virtual Switch for both the Virtual Lock and Virtual Unlock switches
even if you are not going to use one or the other. The app will not function correctly
if one of the switches are not created.
Schlage Lock Events
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.
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.
Unlock event: lock : Front Door Lock was unlocked [digital]
*/
definition(
name: "Manual Lock Events Monitor",
namespace: "chipworkz",
author: "chipworkz",
original author: "Russ Vrolyk",
description: "Tracks when a lock is manually controlled and updates the virtual switches",
category: "Convenience",
iconUrl: "",
iconX2Url: "",
iconX3Url: "")
def lock = [
name: "lock",
type: "capability.lock",
title: "Lock",
description: "Select the lock to monitor.",
required: true,
multiple: false
]
def virtualLockedSwitch = [
name: "virtualLockedSwitch",
type: "capability.switch",
title: "Virtual Lock Switch",
description: "Virtual switch that should be turned on when lock is manually locked if needed.",
required: true,
multiple: false
]
def virtualUnlockedSwitch = [
name: "virtualUnlockedSwitch",
type: "capability.switch",
title: "Virtual Unlock Switch",
description: "Virtual switch that should be turned on when lock is manually unlocked.",
required: true,
multiple: false
]
def enableLogging = [
name: "enableLogging",
type: "bool",
title: "Enable debug Logging?",
defaultValue: false,
required: true
]
preferences {
page(name: "mainPage", title: "Schlage Lock Events Monitor:", install: true, uninstall: true) {
section("") {
input lock
input virtualLockedSwitch
input virtualUnlockedSwitch
label title: "Assign an app name", required: false
}
section ("Advanced Settings") {
input enableLogging
}
}
}
def installed() {
log.info "Installed with settings: ${settings}"
initialize()
}
def updated() {
log.info "Updated with settings: ${settings}"
unsubscribe()
initialize()
}
def initialize() {
log "Lock status: ${lock.displayName} " + lockStatus()
subscribe(lock, "lock.locked", lockHandler)
subscribe(lock, "lock.unlocked", unlockHandler)
}
def lockStatus() {
return lock.currentValue("lock")
}
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"
}
}
def log(msg) {
if (enableLogging) {
log.debug msg
}
}