Report Unlock code used

lock

#7

Username and User should be “string” type variable.

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

Logs for 4 events 2 for lock and 2 for unlock.
Logs
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)


#8

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


#9

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


#10

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.


#11

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


#12

Here is the code I have been using lately.


Did Restore a piston using a backup code change today?
#13

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


#14

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


#15

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


#16

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.


#17

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


#18

Got the contacts fixed just problems with the lock itself


#19

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


#20

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.


#21

I think my lock has a tamper on it but have to set it manually from the lock and im not sure if that would matter or not


#22

I’m a little late to this thread but here goes.

I have a Schalge BE469 Z-Wave lock. My end goal was to know who came in the front door so I could turn on the appropriate lights when guests came in after close up. We run a small B&B hotel. I started with the Piston from @Dan_Fox and started to make some adjustments. It did not account for empty slots when a code is deleted and I was getting errors in the array. So I added that and then spent 3 days beating my head on the wall, because it was not reliable. I also did away with the array as I discovered I could get the same data from the $args and I don’t really need the String array for any further processing. Then I finally realized that the problem is always when Code 1 is used. Code 0 as discussed, is for any manual unlock (would be nice to know the difference between a key on the outside and the thumb latch on the inside…but I digress). My personal access code happened to be in Slot 1 and the piston worked fine with everyone but me. You can ignore the Push notifications. I will clean them up later. I finally deleted my code and put one of the default codes back in Slot 1 and then re-added myself. So now the DefaultA code in Slot 1 has the problem.

Notice that Unlocked By = null…It should have been DefaultA

I wrote another short piston to:
On Lock events:
Log info to Console

It actually shows the correct name:

image

So what gives??? I originally had UnlockedBy defined as String but changed it to Dynamic and the result was the same. So why does logging to console show it correctly but when pulling the same $arg.codeName in my piston it comes in as “null”.

The lock actually has 2 default codes if you do a factory reset but they were cleared before when I was playing with another lock SmartApp and DTH. I manually added one of them back in after deleting my own personal code. So is there something special about this slot? What am I missing.

Thanks all.


#23

Did you ever figure it out? I’m also looking for a compatible announcement/notification for the schlage lock.


#24

I’m trying to use a similar piece of code to get the code name of the code that was used to unlock the door. When I look at the IDE, there is no $args.codeName defined.
data
{
“lockName”: “Front Door Lock”,
“codeId”: “3”,
“method”: “keypad”,
“usedCode”: 3
}

I can get the array of lock codes and names by:
Set Variable {LockCodes} = {[Front Door Lock : lockCodes]}
(expression) LockCodes »»» (dynamic) {“1”:“Doe”,“2”:“Cory”,“3”:“Jamie”,“4”:“LM”,“5”:“Janet”,“6”:“Zoe”,“8”:“Antonio”,“9”:“Jake”,“7”:“Judy”}

If $args.userCode is 3, how do I return the string “Jamie”?
How do I tell if LockCodes is “not found”, so I can initialize it? I do not want to initialize it on every event. {isEmpty(LockCodes)} returns false.


#25

I am also trying to set something up but I can get this piston to fire. Can anyone help me out.


#26

Been away from the forums for a while as everything has been mostly working well. Here is the piston I ended up with that works well for controling lights based on who came in the door and to make an announcement on my Google Home speaker.

Combined with this piston that figures out if anyone is in a bedroom based on active codes in the lock. This runs every time there is a change in the lock codes.