Send Distress Message When Door Lock Code Used


(skp19) #1

This app basically sends a text message to someone when a certain code is used to unlock the door. This is similar to how distress codes are setup on alarm systems and I figured most people here aren’t paying for an alarm system. There is a code discovery mode in the app also so that you can find which code is assigned to your unlock code without needing a computer. I have only tested this with a Schlage lock so I’d like to know if this works for other lock types.

https://github.com/skp19/st_door_lock_code_distress_message


If you find this app useful, please support the developer:


(Brian Smith) #2

This is a brilliant idea. Something pretty simple that could have a profound impact, especially if someone is “jumped” as they are entering their house / apartment.


(Alex) #3

@eparkerjr, Which device handler are you using with this app?


(skp19) #4

@625alex It’s connecting to anything with lock capability. What I’m not sure of is if the system reads the codes differently depending on the lock type.


(Ben Edwards) #5

You should submit this into the publishing process when you are ready - to share with everyone.


(Andrew Urman) #6

This is such a cool idea. Dan actually text me to tell me about it when he saw the submission. Super duper cool. I feel like the professor guy in the Bourne Identity movie.


(Marc) #7

I have a separate alarm system but still would love this app. It would be great if the app can alert on multiple codes such as 0000 and 7777 which is a sign someone is trying to break in. Almost like an intrusion detection system…is that possible?


(skp19) #8

@Mbhforum Do you mean when someone enters the wrong code multiple times or specific codes?


(Marc) #9

Yes, if someone entered a group of codes you cared about that are weak such as 0000,1111,1234, etc. It would be a good Intrusion Detection warning if someone came up to your door and tried multiple codes.


(skp19) #10

@Mbhforum I don’t think it’s possible at the moment to detect something like that. Right now the Schlage lock only returns the user code the unlock code is assigned to which means that to detect those codes they would have to exist in the lock already. But that would also mean that the codes would unlock the door.


(Doralee Ziomek) #11

This could also be used to let you know that your contractor/house cleaner/dog walker arrived at your house.


(www.rboyapps.com - Make your home your butler!) #12

@eparkerjr I’ve updated your code slightly to include a push notification and make the SMS optional. Please feel free to include it into your code and thanks a lot for this excellent functionality.

@Ben something for the ST community to include in the apps, custom notifications on user codes.

/**
 *  Door Lock Code Access Message
 *
 *  Taken from skp19
 *
 * UPDATED: 2014-11-17
 *
 */
definition(
    name: "User door unlock notification",
    namespace: "rboy",
    author: "RBoy",
    description: "Sends a notification and text when a specific user unlocks the door",
    category: "Safety & Security",
    iconUrl: "https://s3.amazonaws.com/smartapp-icons/Solution/doors-locks-active.png",
    iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Solution/doors-locks-active@2x.png")

import groovy.json.JsonSlurper

preferences {
	section("Choose Locks") {
		input "lock", "capability.lock", multiple: true
	}
    section("Enter User Slot Number (This is not the code used to unlock the door)") {
    	input "userSlot", "number", defaultValue: "1"
    }
    section("Notification Options") {
    	input "distressMsg", "text", title: "Message to send"
    	input "notification", "bool", title: "Send notification"
    	input "phone", "phone", title: "Phone number to send SMS to (optional)", required: false
    }
    section("User Code Discovery Mode (Enable and unlock the door using desired code. A message will be sent containing the user code used to unlock the door.)") {
    	input "discoveryMode", "bool", title: "Enable"
    }
}

def installed() {
    subscribe(lock, "lock", checkCode)
}

def updated() {
	unsubscribe()
    subscribe(lock, "lock", checkCode)
}

def checkCode(evt) {
    log.debug "$evt.value: $evt, $settings"

    if(evt.value == "unlocked" && evt.data) {
    	def lockData = new JsonSlurper().parseText(evt.data)
        
        if(discoveryMode) {
        	sendPush "Door unlocked with user code $lockData.usedCode"
            return
        }
        
        if(lockData.usedCode == userSlot && discoveryMode == false) {
        	if (phone) {
        		sendSms(phone, distressMsg)
            }
            if (notification == true) {
            	sendPush "$distressMsg"
            }
        	log.info "Distress Message Sent"
        }
    }
}

How to use the lock status to create notification
(www.rboyapps.com - Make your home your butler!) #13

Another great app with this functionality AND a lot more.


(Fast, Good, Cheap...pick two.) #14

@eparkerjr

I’ve installed this and have selected to receive texts but it is not working. I do know text notifications are working in other smart apps…any ideas what to check?


(Barry) #15

Did you find the problem? If not, I’ll take a look at it today…


(Fast, Good, Cheap...pick two.) #16

Hello Barry,

I did finally get it working although I’m not certain what the resolution was as it just started working a few days later.

I appreciate your follow up. Merry Christmas!


(skp19) #17

I expanded on this code to have a little more functionality.