Vera - Smarter Home Control Forum

General => Remote Control => VeraAlerts => Topic started by: SirMeili on August 15, 2013, 11:48:41 am

Title: Get Lock Pin User
Post by: SirMeili 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.
Title: Re: Get Lock Pin User
Post by: SirMeili 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.
Title: Re: Get Lock Pin User
Post by: ChrisAZ 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!


Title: Re: Get Lock Pin User
Post by: RichardTSchaefer 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 ...
Title: Re: Get Lock Pin User
Post by: shmixx 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.
Title: Re: Get Lock Pin User
Post by: Javelin 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.
Title: Re: Get Lock Pin User
Post by: silencery 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
Title: Re: Get Lock Pin User
Post by: RichardTSchaefer 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.

Title: Re: Get Lock Pin User
Post by: shmixx 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.
Title: Re: Get Lock Pin User
Post by: RichardTSchaefer 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 ...


Title: Re: Get Lock Pin User
Post by: shmixx 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.
Title: Re: Get Lock Pin User
Post by: SirMeili 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.
Title: Re: Get Lock Pin User
Post by: RichardTSchaefer 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:


Title: Re: Get Lock Pin User
Post by: SirMeili 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.
Title: Re: Get Lock Pin User
Post by: SirMeili 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.
Title: Re: Get Lock Pin User
Post by: silencery on March 21, 2014, 03:06:20 pm
Awesome! Much prettier than my dirty version :)

Thanks Richard!
Title: Re: Get Lock Pin User
Post by: shmixx on March 21, 2014, 03:41:42 pm
Looks to be working perfect for me too! At first I forgot to put the device number in, corrected that mistake, and WALA!

@RichardT you are the man!!
Title: Re: Get Lock Pin User
Post by: RichardTSchaefer on March 21, 2014, 04:03:26 pm
There is also a String.LockUserID()  if you want the ID!
This file  will be in the next official  release.
Title: Re: Get Lock Pin User
Post by: PJJP on April 17, 2014, 09:06:54 am
Am I correct in thinking that this will allow me to have one notification for each lock and VeraAlerts will get the username from the lock for me? If so, which notification option are you choosing?

"A PIN code is entered" makes you choose one particular index number.
"A door is locked or unlocked" will give me alerts when the lock is operated manually

Title: Re: Get Lock Pin User
Post by: RichardTSchaefer on April 17, 2014, 09:14:20 am
It will only work for:
   "A PIN code is entered" makes you choose one particular index number.
Use * as a pin code.
The alert will tell you wich user actually opened the door.
Title: Re: Get Lock Pin User
Post by: PJJP on April 17, 2014, 05:47:12 pm
wildcards.... Thanks
Title: Re: Get Lock Pin User
Post by: clippermiami on May 22, 2014, 09:31:28 am
{Deleted}

Solved the problem, formatting of the template string.
Title: Re: Get Lock Pin User
Post by: Aaron on June 12, 2014, 10:41:31 am
I've been using this but it is not sending the User Name...

OPEN Front Door Lock {Device([172].service[urn:upnp-org:serviceId:VSwitch1].Status) | Choose(0={tone:3},1={tone:1})}{Device([139].Lock.sl_UserCode) | String.LockUserName()}

... any ideas why?
Title: Re: Get Lock Pin User
Post by: Aaron on June 21, 2014, 09:58:19 am
Anyone have this working? No matter what I try I never get the user  name

Sent from my SAMSUNG-SGH-I747 using Tapatalk

Title: Re: Get Lock Pin User
Post by: Aaron on July 12, 2014, 10:00:30 pm
Richard,
Is there something wrong with my code? It never works for me?
Title: Re: Get Lock Pin User
Post by: RichardTSchaefer on July 14, 2014, 01:53:32 pm
Did you break it down and try something simpler ? Are you sure you have the right device ID?
Title: Re: Get Lock Pin User
Post by: Aaron on July 14, 2014, 04:37:02 pm
*UPDATED TESTING*


OPEN Front Door Lock {Device([137].Lock.sl_UserCode)}
... works as expected

OPEN Front Door Lock {Device([137].Lock.sl_UserCode) | String.LockUserName()}
... only provides UserName, not UserCode

OPEN Front Door Lock {Device([137].Lock.sl_UserCode) | String.LockUserName()}{Device([172].service[urn:upnp-org:serviceId:VSwitch1].Status) | Choose(0={tone:3},1={tone:1})}
... provides no lock data
Title: Re: Get Lock Pin User
Post by: Aaron on July 23, 2014, 02:25:09 pm
*UPDATED TESTING*


OPEN Front Door Lock {Device([137].Lock.sl_UserCode)}
... works as expected

OPEN Front Door Lock {Device([137].Lock.sl_UserCode) | String.LockUserName()}
... only provides UserName, not UserCode

OPEN Front Door Lock {Device([137].Lock.sl_UserCode) | String.LockUserName()}{Device([172].service[urn:upnp-org:serviceId:VSwitch1].Status) | Choose(0={tone:3},1={tone:1})}
... provides no lock data

Richard, any help here?

I'd like VeraAlerts to display only LockUserName - and also follow the tone rules set by the Choose statement.

thanks
Title: Re: Get Lock Pin User
Post by: Aaron on August 05, 2014, 08:54:16 pm
no help?
Title: Re: Get Lock Pin User
Post by: mlawell on November 26, 2014, 09:40:32 pm
This is nice, except when we unlock through the interface. It only alerts with the last user to unlock... how do we filter out or return the user logged into the interface?
Title: Re: Get Lock Pin User
Post by: RichardTSchaefer on November 26, 2014, 09:51:42 pm
You would need to add some code to clear the last lock user from the device ...
Title: Re: Get Lock Pin User
Post by: tdubbs on November 15, 2017, 10:41:18 pm
Bringing up an old topic...

Attempting to set up Vera Alerts to send the name for the specific pin entered as others have worked on previously.

I'm running a new Vera Plus with the latest 1.7 firmware to date.

I've uploaded veraTemplateString.lua as directed.

Selected the door lock, pin entered, *, advanced editor, added vera alerts, Send Alert, with a message {Device([13].Lock.sl_UserCode) | String.LockUserName()} entered Basement Door. (ID 13 is the door lock)

Saved the scene, rebooted for good sake, and when I run the scene I get "Code 4 Entered Basement Door" (Code #4 being the code I entered)

Where am I going wrong? What can I test?

thanks!