I have several Yale locks that we managed to get email notifications when a user unlocks them.
The problem is that regardless of user, it sends the previous user’s info.
Scenario:
John unlocks the lock the very first time… I get John’s info…
Now Jane comes by and unlocks the door… I get John’s info…
But if Jane unlocks it again, I then get Jane’s info…
Basically, I have a Door Entry scene, that has LUUP Event triggers for Bad_PIN… Door_Unlock…etc…
Can anyone see what I’m doing wrong in this LUA? And/or scene?
[code]local smtp = require(“socket.smtp”)
local SMTP_SERVER = “192.168.0.1”
local SMTP_PORT = “25”
local USER_SENDING = “email@domain.com”
local USER_RECEIVING = “email@domain.com”
local DEVICE_NO = 15
local LS_SID = "urn:micasaverde-com:serviceId:DoorLock1"
– local nill = luup.call_action(LS_SID, “Poll”, {}, DEVICE_NO)
– luup.sleep(10000)
local userinfo = luup.variable_get (LS_SID, "sl_UserCode", DEVICE_NO) or 0
local from = USER_SENDING
local rcpt = {USER_RECEIVING}
local mesgt = {
headers = {
to = USER_RECEIVING,
subject = "Door Unlock"
},
body = "Door Unlocked - Date: " .. os.date("%c") .. " - User Information: " .. userinfo
}
local e = smtp.send{
from = from,
rcpt = rcpt,
source = smtp.message(mesgt),
server = SMTP_SERVER,
port = SMTP_PORT
}
if (e) then
luup.log("Broke?" .. e)
end[/code]