Author Topic: Get Lock Pin User  (Read 10946 times)

Offline SirMeili

  • Hero Member
  • *****
  • Posts: 1052
  • Karma: +43/-20
Get Lock Pin User
« on: August 15, 2013, 11:48:41 am »
Ok, so I'm using vera alerts, and I'm loving it so far. However, there is one thing I miss over the normal notifications in vera. When I set up a notification for my door lock for when any pin (*) is entered, the vera notifications still tell me what user's pin was used (the name associated with the pin). I don't know how hard this would be do, or if it's even possible.

I entered the following string as the message override to see what would be available for the message:

Name={Name} Description={Description} DeviceID={DeviceID} Service={Service} Variables={Variables}

and I get (split to separate lines for readability)

Name=Code entered to open Front Door
Description= Pin Code #* is entered on Front Door
DeviceID=3
Service= um:micasaverde-com:serviceId:DoorLock1
Variables=sl_UserCode

Is there any way to use the information above to get to the user that entered the pin? For instance, when I add a pin to my door lock, I put a name ("Frank") and a Pin. I know I could set up separate notifications for each user, but using the * was easier and I just want  to make sure that there isn't a way to handle it globally before I do separate ones.
VeraLite (Live); ISY 994i (Live); Vera 3 (Waiting to replace VeraLite); Vera Edge (Waiting for all the bugs to be fixed); Xuan StackBox (Testing and waiting for more plugins and for it to mature)
Countless z-wave and insteon devices :D

Offline SirMeili

  • Hero Member
  • *****
  • Posts: 1052
  • Karma: +43/-20
Re: Get Lock Pin User
« Reply #1 on: August 17, 2013, 10:59:01 am »
Ok, so when I use this:

{Device([3].Lock.sl_UserCode)}

I get this:

UserID="2" UserName="Sara"

where Sara was the last person to unlock the door by a pin. I'm curious if there is now a way for me to just get the Sara part, so that I could have my alert day

Sara just unlocked the door.
VeraLite (Live); ISY 994i (Live); Vera 3 (Waiting to replace VeraLite); Vera Edge (Waiting for all the bugs to be fixed); Xuan StackBox (Testing and waiting for more plugins and for it to mature)
Countless z-wave and insteon devices :D

Offline ChrisAZ

  • Full Member
  • ***
  • Posts: 104
  • Karma: +1/-0
Re: Get Lock Pin User
« Reply #2 on: August 17, 2013, 12:13:27 pm »
That's about as far as I got when I tried it that way. You can use the string commands to parse the username out, and then concatenate that into the rest of your alert message. But ever since PLEG came out I refuse to do anything in luup if there is another way.

After RTS pointed me in this direction, I created separate notifications on each lock for each pin code, have Vera Alerts process the notifications,  and then hard coded the message I want: Pin 7 on front door lock = "The housecleaner unlocked the front door".

Now I get an alert letting me know who opened what door and when, and my children know they are going to have to seriously up their game if they want to sneak in after curfew!



Offline RichardTSchaefer

  • Moderator
  • Master Member
  • *****
  • Posts: 10091
  • Karma: +763/-142
Re: Get Lock Pin User
« Reply #3 on: August 17, 2013, 01:14:00 pm »
I was busy with another project ... I do not have a better answer yet ... but let me think about it ...

Offline shmixx

  • Full Member
  • ***
  • Posts: 171
  • Karma: +2/-1
Re: Get Lock Pin User
« Reply #4 on: November 07, 2013, 02:10:47 pm »
@RichardT

Were you able to come up with anything more here? I'm interested in doing the same on my notifications, without having to hard code multiple notifications as were indicated above. Trying to reduce the amount of different messages being managed if possible.

Offline Javelin

  • Full Member
  • ***
  • Posts: 146
  • Karma: +1/-0
Re: Get Lock Pin User
« Reply #5 on: January 12, 2014, 11:08:55 pm »
If anyone figures this out id be interested to test it out on my Yale touchscreen.

Would enable logging of users as I cant do this with vera or haven't yet figured it out.

A brief guide would be appreciated.

Offline silencery

  • Sr. Member
  • ****
  • Posts: 254
  • Karma: +14/-1
Re: Get Lock Pin User
« Reply #6 on: March 21, 2014, 03:55:59 am »
Here's my super quick and super dirty Lua string parsing solution:

Code: [Select]
local devID = 999
local lastopeneduser = luup.variable_get("urn:micasaverde-com:serviceId:DoorLock1","sl_UserCode",devID)
local username = ''

for token in string.gmatch(lastopeneduser, '[^"]+') do
  username = token
end

luup.call_action("urn:richardgreen:serviceId:VeraAlert1", "SendAlert", {Message = "PIN code for " .. username .. " has been entered on the front door.", Recipients = "VeraAlertsProfile"}, 000)

Where:
999 is the device id for your lock.
VeraAlertsRecipients is the profile you want to alert
and 000 is the id for your VeraAlerts plugin

Offline RichardTSchaefer

  • Moderator
  • Master Member
  • *****
  • Posts: 10091
  • Karma: +763/-142
Re: Get Lock Pin User
« Reply #7 on: March 21, 2014, 07:48:40 am »
I will release some functionality to Vera Alerts Template so you can do this as a template:


{device([999].Lock.sl_UserCode) | String.LockUserName() }
or:
{device([Front Door].Lock.sl_UserCode) | String.LockUserName() }

For now just upload the attached file.

999 is the device ID for your Lock ... You can also use the Lock Name if it's unique.

« Last Edit: March 21, 2014, 12:11:24 pm by RichardTSchaefer »

Offline shmixx

  • Full Member
  • ***
  • Posts: 171
  • Karma: +2/-1
Re: Get Lock Pin User
« Reply #8 on: March 21, 2014, 08:47:13 am »
@RichardT

Forgive my ignorance here but trying to understand how this needs to happen. If I upload this LUA and reload vera, I am able to substitute {device([999].Lock.sl_UserCode) | String.LockUserName() } into my notification text and it will provide the name of the user who's PIN was used? Just curious how to use the output.

Offline RichardTSchaefer

  • Moderator
  • Master Member
  • *****
  • Posts: 10091
  • Karma: +763/-142
Re: Get Lock Pin User
« Reply #9 on: March 21, 2014, 09:36:49 am »
Upload file with Apps ->  Develop Apps Luuo Files ->  Upload
Click the restart Lup after reload ... then GO.

To use as an alert use a message string like:

{device([Front Door].Lock.sl_UserCode) | String.LockUserName() } came in  through the front door.

If you use a device NOTIFICATION ... then you can override the standard notification in Vera Alerts Notification Configuration.
Use something like the above in the message ovveride.

If you use notifications in a scene or PLEG/PLTS action use something like the above in the message.
Same is true if you use LUA to send messages ...



Offline shmixx

  • Full Member
  • ***
  • Posts: 171
  • Karma: +2/-1
Re: Get Lock Pin User
« Reply #10 on: March 21, 2014, 09:46:36 am »
Thanks RichardT, clearly my coffee hasn't kicked in this AM.  ;D

I'll take it for a spin later. This is exciting to finally have this ability.

Offline SirMeili

  • Hero Member
  • *****
  • Posts: 1052
  • Karma: +43/-20
Re: Get Lock Pin User
« Reply #11 on: March 21, 2014, 11:19:49 am »
I tried this, and I think it is working, my only problem now is that for some reason it returns nothing. so I have:

{device([49].Lock.sl_UserCode) | String.LockUserName() } is home.

and it only says " is home."

I don't know if vera is not finding the correct value or what.
VeraLite (Live); ISY 994i (Live); Vera 3 (Waiting to replace VeraLite); Vera Edge (Waiting for all the bugs to be fixed); Xuan StackBox (Testing and waiting for more plugins and for it to mature)
Countless z-wave and insteon devices :D

Offline RichardTSchaefer

  • Moderator
  • Master Member
  • *****
  • Posts: 10091
  • Karma: +763/-142
Re: Get Lock Pin User
« Reply #12 on: March 21, 2014, 12:10:46 pm »
Oops ...
There are two code paths .. I test one ... but not the one used in this example ...
Try the new file:



Offline SirMeili

  • Hero Member
  • *****
  • Posts: 1052
  • Karma: +43/-20
Re: Get Lock Pin User
« Reply #13 on: March 21, 2014, 02:26:25 pm »
Still no go. I turned back on "email notifications" for the vera and when I unlocked via a pin, I got this:

Code: [Select]
Your trigger "A Pin is Entered " occurred.

The originating device ID:49 Front Door in room: Foyer

The ID is: 2709124321
Code: DL_USERCODE Value:UserID="1" UserName="Frank"

And this is what I had in the notification test:

{device([Front Door].Lock.sl_UserCode) | String.LockUserName() } is home.

I've also tried:

{device([Front Door].Lock.dl_UserCode) | String.LockUserName() } is home.

(I tried the above because of the "DL_USERCODE" in the email notification). This did not work

I then tried:

{device([Front Door].Lock.DL_USERCODE) | String.LockUserName() } is home.

which failed to work as well.
VeraLite (Live); ISY 994i (Live); Vera 3 (Waiting to replace VeraLite); Vera Edge (Waiting for all the bugs to be fixed); Xuan StackBox (Testing and waiting for more plugins and for it to mature)
Countless z-wave and insteon devices :D

Offline SirMeili

  • Hero Member
  • *****
  • Posts: 1052
  • Karma: +43/-20
Re: Get Lock Pin User
« Reply #14 on: March 21, 2014, 02:49:20 pm »
Ok..this worked for me... I guess "Front Door" isn't unique?

{Device([49].Lock.sl_UserCode) | String.LockUserName()} is home

Edit: Oh, and thanks RTS for adding this! It has really cleaned up my notifications list in veraAlerts.
« Last Edit: March 21, 2014, 02:59:07 pm by SirMeili »
VeraLite (Live); ISY 994i (Live); Vera 3 (Waiting to replace VeraLite); Vera Edge (Waiting for all the bugs to be fixed); Xuan StackBox (Testing and waiting for more plugins and for it to mature)
Countless z-wave and insteon devices :D