Someone had one of those around here for a Yale Lock, but the description was different and didnt handle locking from the keypad. It would be much more polished if this was built into RM. But below is my modification to the Yale Version for the Schlage version. Basically, the app will monitor the descriptionlog for the device and look for specific events. Three events will cause a virtual switch to toggle.
Manually Unlocked from Inside
Manually Locked from Inside
Manually locked from Outside (Schlage Button on Keypad)
That leaves nothing custom for unlocked by keypad, but i have it show which code unlocked. (Leaving all 4 combinations of user interaction with the lock)
definition(
name: "Schlage Lock Events",
namespace: "rvrolyk",
author: "Russ Vrolyk",
description: "Tracks when a lock is manually controlled and updates virtual switch",
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.",
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 virtualKeypadLockedSwitch = [
name: "virtualKeypadLockedSwitch",
type: "capability.switch",
title: "Virtual Keypad Lock Switch",
description: "Virtual switch that should be turned on when lock is locked by Keypad.",
required: true,
multiple: false
]
def enableLogging = [
name: "enableLogging",
type: "bool",
title: "Enable debug Logging?",
defaultValue: false,
required: true
]
preferences {
page(name: "mainPage", title: "<b>Lock to monitor:</b>", install: true, uninstall: true) {
section("") {
input lock
input virtualLockedSwitch
input virtualUnlockedSwitch
input virtualKeypadLockedSwitch
label title: "Assign an app name", required: false
}
section ("<b>Advanced Settings</b>") {
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)
subscribe(lock, "lock.locked", keypadlockHandler)
}
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]')) {
log "${lock.displayName} was locked inside"
virtualLockedSwitch.on()
} 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]')) {
log "${lock.displayName} was unlocked inside"
virtualUnlockedSwitch.on()
} else {
log "${lock.displayName} was unlocked"
}
}
def keypadlockHandler(evt) {
log("Lock event: ${evt.name} : ${evt.descriptionText}")
if (evt.type == 'physical' && evt.descriptionText.endsWith('keypad [physical]')) {
log "${lock.displayName} was locked outside"
virtualKeypadLockedSwitch.on()
} else {
log "${lock.displayName} was locked"
}
}
def log(msg) {
if (enableLogging) {
log.debug msg
}
}