Hey guys im having some trouble with a little scene im setting up. The idea is to get all sorts of sensors to email me their current status.
The email function works fine but I cant seem to get the right value. It keeps sending me a “0” instead of the actual value.
Can anyone see where ive gone wrong?
local DEVICE_NO = 31
local LS_SID = "urn:schemas-micasaverde-com:service:LightSensor:1"
local currentLevel = luup.variable_get (LS_SID, "CurrentLevel", DEVICE_NO) or 0
local smtp = require("socket.smtp")
local SMTP_SERVER = "mail.xxx.com.au"
local SMTP_AUTH_USER = "xxx"
local SMTP_AUTH_PW = "xxx"
local SMTP_PORT = "25"
local USER_SENDING = "vera@xxx.com.au"
local USER_RECEIVING = "xxx@gmail.com"
local from = USER_SENDING
local rcpt = {USER_RECEIVING}
local mesgt = {
headers = {
to = USER_RECEIVING,
subject = "Vera Status"
},
body = "Status on " .. os.date("%A %c") .. " is " .. currentLevel
}
local r, e = smtp.send{
from = from,
rcpt = rcpt,
source = smtp.message(mesgt),
server = SMTP_SERVER,
port = SMTP_PORT,
user = SMTP_AUTH_USER,
password = SMTP_AUTH_PW
}
if (e) then
luup.log("Yikes " .. e)
end