Author Topic: Keep It Simple - Garage door open too long  (Read 352 times)

Offline jgrilo

  • Newbie
  • *
  • Posts: 9
  • Karma: +0/-0
Keep It Simple - Garage door open too long
« on: September 18, 2017, 06:33:38 pm »
Hey all! been trying to wrap my head around all this custom LUA code in the forums but i'm having a hard time. Could someone lend a hand if they can?

My problem is this. I have a door sensor that I mounted on my garage door. I simply want to be notified if I left the house and left the garage door open. Basically

If Garage Door is open and Last Trip (i think) is greater than 5 mins alert me.

I have tried to do it via a scene:

Schedule: 1min
Trigger: Door sensor open and armed.

All it does it email me every min. Here is some extra LUA code i tried. Please help :)

local deviceNo = 37
local period = 1
 
local SS_SID = "urn:micasaverde-com:serviceId:SecuritySensor1"
 
local armed = luup.variable_get(SS_SID, "Armed", deviceNo) or "0"
if armed == "1" then
    local tripped = luup.variable_get(SS_SID, "Tripped", deviceNo) or "0"
    if tripped == "0" then
        luup.variable_set(SS_SID, "TripPeriod", "0", deviceNo)
    else
        local tripPeriod = luup.variable_get(SS_SID, "TripPeriod", deviceNo) or 0
        tripPeriod = tonumber(tripPeriod)
        tripPeriod = tripPeriod + 1
        luup.variable_set(SS_SID, "TripPeriod", tripPeriod, deviceNo)
        if tripPeriod == period then
            return true
        end
    end
end
return false

Offline fitz2380

  • Jr. Member
  • **
  • Posts: 58
  • Karma: +4/-0
Re: Keep It Simple - Garage door open too long
« Reply #1 on: November 19, 2017, 09:29:45 am »