Scene to email stats

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

don’t you miss the id in urn:schemas-micasaverde-com:service

Your service ID is not correct. Change to:

local LS_SID = “urn:micasaverde-com:serviceId:LightSensor1”

Hey thanks for the reply that did the trick. Are you able to tell me where you pull the service Id ?

urn:micasaverde-com:serviceId:LightSensor1

since I must have confused it with the device_type

urn:schemas-micasaverde-com:service:LightSensor:1

Cheers.

Check this links:
http://wiki.micasaverde.com/index.php/Luup_UPnP_Variables_and_Actions
http://wiki.micasaverde.com/index.php/Luup_UPNP_Files

The simple way to get the Service ID for any variable is as follows:

  1. Open the Device on the Vera Dasboard (Wrench Icon)
  2. Goto the Advanced tab.
  3. Let the Mouse hover over the variable name you are interested in. It will show it’s ServiceID.