Door lock information (Kwikset 910)


#1

1) Give a description of the problem
I’m trying to build a piston to monitor when the door is unlocked - when it IS unlocked, I’d like to send a notification stating how (manual, keypad, etc.) and by who (assigned code). I can access the data I need through the lockcodes and $args, but I don’t understand the format of the data. I am familiar with programming data types like lists, dictionaries, etc. - the results look like these, but I don’t get how to access the items.

2) What is the expected behaviour?
I get back what look like a list and a dictionary. I’d like to access items from them both. Examples: lockcodes: {“1”:“Matt and Christine”,“2”:“Housecleaner”,“3”:“Rosie”}; args: [codeId:1, codeName:Matt and Christine, lockName:Front door lock, method:keypad, usedCode:1]

I’d like to access elements like in python (dictionary.get(“1”) and list[1]) if possible.

3) What is happening/not happening?
I don’t get how to access these items!!

**4) Post a Green Snapshot of the piston![image|45x37]

5) Attach logs after turning logging level to Full

4/18/2020, 11:11:26 AM +178ms
+2ms ╔Received event [Front door lock].lock = unlocked with a delay of 807ms
+67ms ║RunTime Analysis CS > 47ms > PS > 6ms > PE > 13ms > CE
+69ms ║Runtime (38846 bytes) successfully initialized in 6ms (v0.3.110.20191009) (67ms)
+70ms ║╔Execution stage started
+76ms ║║Comparison (enum) unlocked changes_away_from (string) locked = true (1ms)
+77ms ║║Cancelling condition #2's schedules...
+78ms ║║Condition #2 evaluated true (5ms)
+79ms ║║Cancelling condition #1's schedules...
+80ms ║║Condition group #1 evaluated true (state changed) (6ms)
+81ms ║║Cancelling statement #3's schedules...
+87ms ║║[codeId:1, codeName:Matt and Christine, lockName:Front door lock, method:keypad, usedCode:1]
+88ms ║║Executed virtual command log (1ms)
+93ms ║║1
+94ms ║║Executed virtual command log (1ms)
+103ms ║║{"1":"Matt and Christine","2":"Housecleaner","3":"Rosie"}
+104ms ║║Executed virtual command log (1ms)
+106ms ║╚Execution stage complete. (37ms)
+107ms ╚Event processed successfully (107ms)

#2

I believe you can use:

args.codeId
args.codeName
args.lockName
args.method
args.usedCode

I usually store the incoming data into local variables, and then run conditional checks on those variables to decide what blocks to execute in the piston.


Pro Tip:

If you leave {args} up top (no value set)… and add the following line later in your code:
Set variable {args} = $args
you will get the added benefit of always being able to see the last data set that came in.


#3

Thanks @WCmore! I am now able to get done everything I wanted. Here is my final code.

I’d still like to understand the data types better - do you know where I can find out more? Have a great day!


#4

One more Pro Tip, if you are interested…

I really like your trigger on line 36. That inverted coding is great for catching “unlocks”, but also “unknowns” and “errors” as well.

To really take advantage of this possibility, you can add a new line right after line 44:
Set variable {status} = [Name of Lock : lock]

… and then everywhere in your code you currently have the word “unlocked”, replace it with the new variable {status}. (which should be a string)

Normally, your alerts will still say “unlocked”, but on the occasions there is any strange behavior, the alerts will identify what SmartThings sees.