ST's new Smart Locks


#1

1) Give a description of the problem
Understanding how to incorporate ST’s new Smart Locks into WebCoRE
2) What is the expected behavior?
How to parse information that is reported, specifically which code opens the lock. Also, is there a way to pull the user name from lockCodes automatically?

3) What is happening/not happening?
If I unlock the door, codeReport seems to return a random number. In the log below, I used code 2, but the log reported code 3.
Here is what’s shown in the IDE:
Current States
battery: 80 %
lock: unlocked
codeChanged: 3 set
lockCodes: {“3”:“Aaron”,“2”:“Dan”,“1”:“Debbie”}
scanCodes: Complete
maxCodes: 30
codeReport:
checkInterval: 3600

4) Post a Green Snapshot of the pistonimage

5) Attach any logs (From ST IDE and by turning logging level to Full)
11/14/2017, 11:25:15 AM +309ms +1ms ╔Received event [Front Door Lock].lock = unlocked with a delay of 949ms +134ms ║RunTime Analysis CS > 18ms > PS > 86ms > PE > 31ms > CE +144ms ║Runtime (42200 bytes) successfully initialized in 86ms (v0.2.0fe.20171109) (142ms) +145ms ║╔Execution stage started +166ms ║║Comparison (enum) unlocked gets (string) unlocked = true (10ms) +168ms ║║Cancelling condition #7's schedules... +168ms ║║Condition #7 evaluated true (16ms) +170ms ║║Cancelling condition #1's schedules... +170ms ║║Condition group #1 evaluated true (state changed) (19ms) +177ms ║║Comparison (string) :467745ba74b17d0ba382451b50109027: is_not (string) :467745ba74b17d0ba382451b50109027: = false (2ms) +178ms ║║Condition #10 evaluated false (5ms) +179ms ║║Condition group #8 evaluated false (state did not change) (7ms) +182ms ║║Evaluating switch with values [[i:11:null:0, v:[t:integer, v:3, vt:string]]] +186ms ║║Comparison (integer) 3 is (integer) 1 = false (2ms) +190ms ║║Comparison (integer) 3 is (integer) 2 = false (2ms) +194ms ║║Comparison (integer) 3 is (integer) 3 = true (1ms) +196ms ║║Cancelling statement #21's schedules... +203ms ║║Executed virtual command setVariable (4ms) +206ms ║║Cancelling statement #2's schedules... +214ms ║║Calculating (string) Front Door unlocked by + (string) Aaron >> (string) Front Door unlocked by Aaron +217ms ║║Calculating (string) Front Door unlocked by Aaron + (string) on >> (string) Front Door unlocked by Aaron on +220ms ║║Calculating (string) Front Door unlocked by Aaron on + (string) Tue, Nov 14 2017 @ 11:25:15 AM EST >> (string) Front Door unlocked by Aaron on Tue, Nov 14 2017 @ 11:25:15 AM EST +223ms ║║Executed virtual command setState (1ms) +231ms ║║Calculating (string) Front Door unlocked by + (string) Aaron >> (string) Front Door unlocked by Aaron +234ms ║║Calculating (string) Front Door unlocked by Aaron + (string) # >> (string) Front Door unlocked by Aaron # +236ms ║║Calculating (string) Front Door unlocked by Aaron # + (string) 3 >> (string) Front Door unlocked by Aaron #3 +241ms ║║Executed virtual command sendNotification (3ms) +244ms ║╚Execution stage complete. (100ms) +252ms ╚Event processed successfully (252ms) 11/14/2017, 11:25:06 AM +963ms +1ms ╔Received event [Front Door Lock].lock = locked with a delay of 916ms +138ms ║RunTime Analysis CS > 38ms > PS > 72ms > PE > 28ms > CE +147ms ║Runtime (42198 bytes) successfully initialized in 72ms (v0.2.0fe.20171109) (145ms) +148ms ║╔Execution stage started +161ms ║║Comparison (enum) locked gets (string) unlocked = false (1ms) +163ms ║║Condition #7 evaluated false (7ms) +164ms ║║Condition group #1 evaluated false (state did not change) (8ms) +166ms ║╚Execution stage complete. (18ms) +173ms ╚Event processed successfully (173ms)


#2

As far as I know, there’s no way to pull the names associated with the code and regarding the code number used, your lock might have a master code sitting in code1 so you’ll probably have to offset all your codes by 1 to arrive at the correct user.


#3

This was my thought also. For my lock, the slots begin not at lock #0 but lock #1.

Dan, It can be tested by trying all the codes you have. Try each one, and see what reports out. If ech is offset by one in your list, then eibyer’s hypothesis is correct and you simply make the offset.

That said, I like the way you built this. My piston has an independent if-then for each code. Slightly more cumbersome than your approach.


#4

OK, I must be doing something wrong. I unlocked the door 3 times, once with each of my 3 user codes. All three times, codeReport returned 3, so that apparently is not the correct parameter.


#5

The trigger in my pistion can recognize users, but I don’t see anywhere the value can be saved.


#6

In row 33, aren’t you telling it to do exactly that - set the codereport to #3??


#7

I figured out the problem. First a logic problem, I was setting the variable inside the “If Location mode is not Home”.

codeReport apparently doesn’t return the user slot. But usedCode does. See the attached, this works. It also returns #null if the door is manually unlocked. I need to clean up the code to eliminate that.


#8

Looks great… if it’s working for you maybe you would consider posit this in a new thread under the examples category.


#9

Done