Having trouble with a scene w/ SecuritySensor

Hi,

Please forgive the newb-ness in advance.

I’m using a VeraEdge on 1.7.1419. I have installed DSC Alarm Panel Plugin 0.40.

Trying to keep things fairly simple with Vera so far, I’d like to create a scene with the following logic using built-in scenes:

“If it’s 9:00 PM and my garage door is open, send me an email, whether I’m in armed mode or not”

To me - this should be super simple, but it hasn’t worked out like that. Vera seems to be “Edge” triggered (and I don’t mean the device name here). If the door has been open since 8:50 PM, and is still open when we reach 9:00 PM, nothing seems to happen.

I see that the “Switch Sensor” in the GUI is “open”, and if I ask http://my-ip:3480/data_request?id=lu_variableset&DeviceNum=27&serviceId=urn:micasaverde-com:serviceId:SecuritySensor1&Variable=Tripped&Value=1 , I can see what the Value for the Tripped state is.

Can anybody tell me if I’m doing something really dumb, or I should be using PLEG, RTFM, or whatever. Thanks!

Don’t everyone answer at once! :slight_smile:

So I solved my own issue - writing it down here.

-Scene-> Add Scene

  1. Select Trigger → Schedule → Daily → 9:00PM → Validate → Next Step
  2. Device Actions → Next Step
  3. Finish the Scene
  • Runs in any mode
  • Do not notify
  • Execute LUUP code:
local tripped = luup.variable_get("urn:micasaverde-com:serviceId:SecuritySensor1", "Tripped", 18) or "0"
if (tripped == "1" ) then
local myEmail     = "your@email.com"

local message_out = "Close the Door!!"
local send_to     = myEmail
local sender      = myEmail
local subject_out = "Garage Door Notification"

local smtp = require("socket.smtp")

local mesgt    = {
      headers  = {
      to       = send_to,
      from     = sender,
      subject  = subject_out},
      body     = message_out}

local result   = smtp.send {
      from     = sender,
      rcpt     =  {send_to},
      source   =  smtp.message(mesgt),
      server   = "mail.server.com",
      port     = "25"}
return true
else
return false
end
  • Select Room → Garage
  • Name Scene → Garage Check
  • Finish

My DSC/Envisalink/Vera list my Garage door as device 18.

Not sure why this needs to be done like this? I figured that this would have been easy.

I’m still curious if there is another way to do this… but for now - this works.

Actually Vera triggers a scene based on events …
I.e.

  1. a device state changes (an input trigger)
  2. an input schedule happens
  3. A user manually starts a scene.

Then you have condition code in the LUA portion of the scene to decide if the scene should continue.
This is how you get the AND of the triggering event (9:00 PM in this case) and the garage Door is open.

You can also use PLEG if you need more sophisticated logic or do not like to work with the details of LUA.