Can't get variable from motion sensor

Okay, I’m ready to pull my hair out on this, I’ve created other scenes using LUUP, but I can’t get this one to work. I’m trying to send an alert when the alarm is set and the garage door is open.

Right now I’m just trying to get an email sent when the garage door sensor shows tripped. I’m using the email plugin that is available and I’ve tested that portion of the code is working. It doesn’t appear that I am retrieving the variable correctly or evaluating correctly:

local alarm=45
local DSC_sid=“urn:schemas-micasaverde-com:device:AlarmPartition:2”
local garagesensor=49
local garage_sid=“urn:schemas-micasaverde-com:device:MotionSensor:1”
local tripped = luup.variable_get (garage_sid,“ArmedTripped”,garagesensor)

local alarmset=luup.variable_get(DSC_sid,“Armed”,alarm)

if (tripped==“1”) then
luup.call_action(“urn:upnp-org:serviceId:SmtpNotification1”, “SendEmail”, {Recipient_Name=“”,Recipient_eMail=“”, Subject= “Title”, Message=“Message” }, 50)
end

You are using Device specifications where you need Service IDs. This is in DSC_sid and garage_sid. You can see what the Service IDs should be by hovering over the variable name in the device’s Advanced tab.

They are usually like: urn:micasaverde-com:serviceId:MotionSensor1

Rex,

I finally got what you were saying, but still no luck:

local garagesensor=49
local garage_sid=“urn:micasaverde-com:serviceID:SecuritySensor1”
local tripped = luup.variable_get (garage_sid,“ArmedTripped”,garagesensor)
if (tripped==“1”) then
…

Case is important in these strings.

Try: local garage_sid=“urn:micasaverde-com:serviceId:SecuritySensor1”

… Id … not … ID …

You can do this all without any LUA with the PLEG plugin:

Two Input Triggers:
Armed When the Alarm indicates Armed
Motion When the Motion detector indicates Motion

One Condition:
SendAlert Armed and Motion
One Action for condition:
SendAlert Send an alert … need to use Advanced tab … select SMTP device … SendEmail Action.

Richard,

I thought about using the PLEG plugin, but I couldn’t figure out how to put a delay in. What I want to do is after the motion sensor is tripped, wait 5 minutes, if the sensor is tripped and alarm is on then do X.

If you could tell me how to do that with the plugin that would be great, but I’m also still very curious what I have wrong that I can’t pull the status via LUUP as I’ve written.

Thanks

You are not using Service IDs.
To find a service ID … Go to the Advanced TAB of the device that has a variable you are interested in. Let the mouse hover over the name of the variable … It will show the service ID. These look very similar to what you have … but what you have is wrong … The name and case is very important.

Most Service IDs have :serviceId: in the name (by convention, not enforced)

IN PLEG you never worry about typing a ServiceID or Variable Name (both spelling and case sensitive) because you just pick them from a menu.
[hr]
If it’s a batter powered motion sensor … It will likely stay tripped for 5 or more minutes … even without any motion … Do you want two separate trips separated by 5 minutes when armed … Or do you want the alert 5 minutes after tripped if the alarm is still armed ? Not sure what you are looking for.

Richard & Rex,

Thank you both so much for your help. I kept missing the part about being case sensitive on the variables. I feel kinda dumb on that. I got the LUUP code to work today.

Richard I would still like to learn to use the PLEG if possible. I have installed the plugin. This is the goal:

I’m trying to send a text message if I leave the garage door open when I leave. I figure if the alarm is on and the garage door is open than I must have forgotten to lower it. So what I was doing, was creating a scene that was triggered when the garage door sensor was tripped. The scene waits 5 minutes and then runs the LUUP code that I have written which again checks to see if the garage door is open and if the alarm is armed. If both are true then it sends a text message.

Again thank you both for your help and patience.

See:
http://forum.micasaverde.com/index.php/topic,14197.msg108586.html#msg108586

There are other examples if you search PLEG and Garage Door