Report Unlock code used



One new feature in the latest ST update is the ability to set user codes for locks. Using the available information, I created this piston to report which user opens a lock. I also have it where a user unlocking would set the location mode.

You could modify this in a number of ways, perhaps having particular users do different things. I haven’t figured out how to pull the user name from the device yet, that may come later.


After a bit of trial and error, I got it to use the names as recorded in the device.
If the lock was somehow unlocked with another code (Could this happen?) it will alert me with a text. Otherwise it will just update the piston state, log in notifications, and change to home mode.

The default occurs when the lock is manually unlocked, including remotely by ST, at least on my Kwikset lock…


Although I may modify this piston to use Switch-Case, this is a simple version that includes the type of lock action.


I test this out and I got 3 unknown user messages that I got with Dan_Fox version. Also would like to have it just SMS keypad or have the options to have one or the other.


OK, I figured out the User issue, change the Variable type from Dynamic to String.


Changed the variable for the user to string and it did not report at all. Is that what you mean?


Username and User should be “string” type variable.

string User;  (not set)
string UserName;  Manual
dynamic Type; manually
end define;

Logs for 4 events 2 for lock and 2 for unlock.
12/1/2017, 5:50:11 PM +958ms
+2ms ╔Received event [Side Lock].lock = locked with a delay of 1322ms
+639ms ║Status: locked | User: - Manual | Method: manually
+651ms ╚Event processed successfully (651ms)
12/1/2017, 5:48:38 PM +25ms
+2ms ╔Received event [Side Lock].lock = unlocked with a delay of 316ms
+878ms ║Status: unlocked | User: 1 - Dad| Method: keypad
+886ms ╚Event processed successfully (886ms)
12/1/2017, 3:58:37 PM +485ms
+1ms ╔Received event [Side Lock].lock = locked with a delay of 207ms
+657ms ║Status: locked | User: - Manual | Method: remotely
+675ms ╚Event processed successfully (676ms)
12/1/2017, 3:55:02 PM +375ms
+2ms ╔Received event [Side Lock].lock = unlocked with a delay of 1495ms
+669ms ║Status: unlocked | User: - Manual | Method: manually
+691ms ╚Event processed successfully (691ms)


Nice! Works like a charm. Now just have to figure out how to disable notifications for locked manually and remotely. Just to many notifications going on for someone coming in and out of the door each time


An if statement or restriction for only keypad responses could work. I will see about later.


The restriction worked now I only get notifications for keypad entries. How does the unknown in the expression work?
I tested it out with false keypad entries but did not get a response.


would like to talk to you about your unlock code. im trying to write basically the same unlock commands and statues of the lock and who unlocked it and also firing a routine when b4 it runs to turn off my location to home. if you had time any input would be greatly appreciated or a revised copy of your piston that would be awesome


Here is the code I have been using lately.

Did Restore a piston using a backup code change today?

Thanks way out of my league I guess can’t get anything to work


That is odd. The only things you would need to add are your locks and contacts.


It’s showing me as not having any contacts and only one lock. Ordering another lock as I need one but just testing it out with one gas off now


Try this quick revamp. It is just for a single lock, and I change Send Notifications to Contacts to a Push Notification.

This is the Piston State I see, although it is for the two lock version of the piston.

Activity - Lock StatusTue, 09-Jan-2018

Main Lock: 09:41:52 AM :red_circle: unlocked :ok: Lock Clear by Manual - Human.
Main Lock: 09:42:07 AM :closed_lock_with_key: locked__ :ok: Lock Clear by Manual - Keypad.

Kitchen Lock: 08:08:52 AM :red_circle: unlocked :ok: Lock Clear by Manual - Human.
Kitchen Lock: 08:09:32 AM :closed_lock_with_key: locked__ :ok: Lock Clear by Manual - Keypad.


wont just let me change it to my lock. what kind of lock are you using. i tried entering manually and if wont let me put in the lock tamper in a event. i only have a few


Got the contacts fixed just problems with the lock itself


I have a Yale lock YRD-210-HA. It also look like the lock you have does not have a tamper event option.


No I dont think so. What do you think I could do to just show notifications for contacts opening locks by code. Thats all i really need.