Description text logging - actionable?

I am interested in knowing if an unlock or lock was performed by a person via code entry (lock), manually (unlock), or programatically (lock, unlock) by Hubitat. Descriptive Text logging exposes this, but events are generic.

dev:3032019-06-27 10:20:02.757 am infoFront Door Lock was unlocked by digital command
dev:3032019-06-27 10:20:00.530 am infoFront Door Lock was unlocked

Is there a way to grab the descriptive text logging info and use it in a rule?

Example:
If unlock = manual
then
disarm alarm
and
announce alarm is disarmed

YF

You'd need to write your own app to do this. I threw something together for my Yale for a similar reason but my use case is inverted - I wanted to arm the alarm when the lock wasn't manually locked. Your handler method can look at the event type and the description; e.g,

def lockHandler(evt) {
	if (evt.type == 'physical' && evt.descriptionText.endsWith('by manual')) {
		log "${lock.displayName} was locked manually"
	} else {
		log "${lock.displayName} was locked"
	}
}

I doubt the description format is guaranteed to remain stable but it seems reasonable as long as you're aware of that :slight_smile:

It looks like your lock has a slightly different format so maybe you'd want to change the if condition a bit but the syntax shouldn't be drastically different.

I have a Yale Assure SL so they should be the same. Pardon my "pseudo code" example.

I am not a coder, but have done some scripting. Feel like sharing your app?

YF.

Sure. I haven't used it much so I can't speak to how reliable it is but it seemed to work ok the few days it was used (we don't use the front door much and my use case is for a pet sitter). I can't remember why but I added the ability to bind two types of virtual switches - one that is on when manually locked and off when manually unlocked and the other is the opposite (on when manually unlocked).

definition(
    name: "Manual 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: false,
    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
			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)
}

def lockStatus() {
	return lock.currentValue("lock")
}

def lockHandler(evt) {
	log("Lock event: ${evt.name} : ${evt.descriptionText}")
	if (evt.type == 'physical' && evt.descriptionText.endsWith('by manual')) {
		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('by manual')) {
		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
    }
}

Thanks! This gives me something to play around with.

There isn't much effort spent in unifying an events displayText attribute across all drivers, nor is there any guarantee it wouldnt get changed, cleaned up or otherwise modified when a specific driver gets updated for whatever reason. This type of change won't ever be in the realase notes since its an optional attribute whos content has no schematic definition.

Thanks Mike, that's more or less what I meant to imply :slight_smile:
I'm certainly not counting on the code I wrote to work forever and won't be surprised if/when it breaks because the description format changed. I probably should figure out some way to detect that but my use case isn't critical enough or frequent enough for me to have bothered yet.

1 Like