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:
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.
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
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!
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.
Here’s my super quick and super dirty Lua string parsing solution:
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
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.
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 …
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
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.