Getting an event from a lock for ONLY when the lock is unlocked by a code

Yup. I'm just saying that my observed behavior is that when I trigger on a specific lock code, any code will cause it to trigger =)

That’s because the event is the unlock, the how is a property of the event, Think of it as

event.unlock[method:”code”, value:”main”]

As a side note - I'm really interested in just fixing these things myself. I've never looked at groovy before, but it all seems pretty straight forward. In the next few weeks I'll start digging in. I'm still in the aftermath of switching from SmartThings, and finding a few hiccups here and there in terms of compatibility. I'm all-in on Hubitat though, so may as well contribute back to the community however I can!

I was really lost the first day, but it's all pretty simple once you dive in. Device subscriptions to attributes and basic if then else structure.

1 Like

I think the best way to learn is find an app you like but doesn't do exactly what you need, then tweak it to work the way you want.

Something to check

Are the events for 'lastCodeName' in your event log for the device(s) ?

Can you subscribe to lastCodeName?

I just ran a test with webcore and it worked....

In all the years I’ve used webCoRE I never saw the event occurs... Learn something new every day. Thanks!

1 Like

It is part of HE (ie that it works)

You have to be on a recent version

2 Likes

Thanks, @nh.schottfam! I too never noticed this "event occurs" option. Learn something new everyday. Seems HE has a few of these special differences (another is device notifications) that lead to healthy debug sessions for anyone coming from SmartThings (which might be viewed as an opportunity to improve code compatibility).

Is your lock a Schlage?

I created a test piston that does exactly what you show (thanks again for sharing the insight), but alas, the code does not execute when I lock/unlock my Schlage locks via keypad codes. I'd paste a screenshot but haven't earned that ability in the forums yet =) I log {$currentEventDevice} and {$currentEventValue} and nada. Tracing shows the event does not occur.

I poked around in Rule Machine and I can't find where this lastCodeName event is available. Again, trying hard to determine if this is a WebCore application specific thing, or if it's more broad.

Lastly, I tried this same WebCore piston with a virtual lock device "Test unlock with code" and the event also does not cause log output.

In the meantime, I did get what I was looking for by using an expression to parse the keypad code name via the event description text. I'm looking forward to shifting this to using this lastCodeName event once the ghost in the machine is sorted (I could very well be the ghost).

{keypad_user} = substring($currentEventDescription, lastIndexOf($currentEventDescription, " ")+1)

If {keypad_user} is "[digital]" the Schlage button was used to lock the door.

Can I appeal to any moderator of this forum to grant me the ability to reply more than 3 times in a 24 hour period, and to post images =) I will pay it forward by sharing code to anyone who asks.

I think @bobbyD may be able to grant that request...

1 Like

make sure you have the latest webcore, you should be able to reproduce my piston with the virtual lock.

My understanding is the locks only give this event if you use a code that is in the named codes list.

ie the lock has a table of names to codes, and it is matching this on an unlock that sends the event.

Other codes not in the 'name list' will not cause this event to fire.

That has been my read on on how things work in HE.

Thanks for all the insights here.
I am running the latest Hub firmware, and latest WebCore application (v0.3.110.20201015_HE). I reset to factory each lock and deleted the built-in user codes. I then added codes via the Lock Manager application. I can see from the device page for each lock that these codes are installed, and I can lock/unlock via the keypad with these lock codes. I noted earlier that I can see names specified for each of these lock codes via the event description text. Is there something specific I need to do beyond what I described here to ensure the named code list? It's weird that I'm seeing this behavior and others here are not. Usually means it's me. I'm digging hard and coming up short.

Can anyone share how to lever this event with a virtual lock using the Rule Manager application?

I suggest you install the latest webcore

I suggest you ensure your devices are enabled in webcore, and ensure on device settings you done your way out (at bottom of each page).

On you browser, ensure you clear your caches, etc.

Otherwise I would expect you to see the same results as others.

I would also run the latest hub firmware, (if you are not), so you have the latest device handlers from HE

If you read my very last post, I indicated I am running the latest Hub Firmware and the latest WebCore for HE. If your WebCore version is newer than the version I listed, I'd love to know that as it could be I'm off in the weeds and looking at an old repo. Long time WebCore user, so devices must be added otherwise you can't reference them in pistons. I rebooted the hub. I cleared all my browser cache.

@bobbyD, can you gift me the ability to post images so the wonderful community members here can see my code?

You are now gifted -:wink:

2 Likes

Face palm! Full tracing.
@nh.schottfam, any idea why the evaluation of my conditional block (#154) fails? Same thing happens with a virtual device. What version of webCore and Hub firmware are you running?

Paying it forward, here is the piston that pulls it all together using the event description text.

Install the latest webcore. It has a patch this morning

1 Like

Voila! After applying the webcore patch released this morning, I can access the value of lastCodeName event. What a ride! Thanks all for the grace you gave me, and your help. I'll post an updated piston that levers this event for extracting the code name. @mike.maxwell, a feature request is to fire this lastCodeName event when the button on the keypad is used to lock the door, rather than just a pin code. It's not happening now. For example, a hard-coded name like KeypadButton. Otherwise, there isn't a single event that can be used to determine lock/unlock via the keypad as the only way to determine keypad lock via (Schlage) button is via parsing the description text from separate lock events.

Still don't know how to access this event via Rule Machine, but that's for another day.

Download the Hubitat app