Author Topic: Garage Door Open? Flash Hallway Light - Make it Stop?  (Read 86 times)

Offline Dill

  • Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
Garage Door Open? Flash Hallway Light - Make it Stop?
« on: March 11, 2017, 02:36:21 pm »
I've scoured this forum and Googled like crazy for days, but can't seem to find what I'm looking for. Surely someone has done this and by asking the question here, I believe others would find it useful if an answer is documented.

Situation:

  • Garage door magnetic contact open for longer than 5 min @ night? Flash hallway light on/off, 1 sec interval.
  • Garage door magnetic contact closed? Stop flashing hallway light.

Bullet 1, garage door open > 5min = light flash was super simple using PLEG triggers/conditions/actions.

What I can't seem to figure out is how to stop the flashing after the garage door sensor is returned to a closed state. Creating a closed trigger/condition/and off action does not affect the perpetually running script below.

This is the PLEG logic action I'm using when the door is open (copied from this forum). Perhaps adding another if statement which detects the state of the magnetic contact as closed, then sets the light to off and ends, may work? Just not sure how to write it and can't find any similar examples.

Thank you in advance!

-----  SET THESE TWO VARIABLES to match needs of your system -----
Secs   = 1   ---->>  Secs: Number of seconds between "Blinks"
Device = 49 ---->>  Device: Device#  of Outlet or Light to "BLINK"
-------------------------------------------------------------------
Call ='urn:upnp-org:serviceId:SwitchPower1';Do ='SetTarget';Nil =""
function BlinkOn()
 luup.call_action(Call,Do,{newTargetValue=1},Device)  -->BlinksOn
  if (Run == "1") then luup.call_timer("BlinkOff",1,Secs,Nil,Nil) end
end
function BlinkOff()
 luup.call_action(Call,Do,{newTargetValue=0},Device)  -->BlinksOff
  if (Run == "1") then luup.call_timer("BlinkOn",1,Secs,Nil,Nil) end
end
if (Run == "1") then Run = "0" --> NewClick while running=Stop,i.e.Run=0
 else Run = "1" luup.call_timer("BlinkOff",1,Secs,Nil,Nil) -->Else go on
end
« Last Edit: March 11, 2017, 02:41:10 pm by Dill »

Offline Dill

  • Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
Re: Garage Door Open? Flash Hallway Light - Make it Stop?
« Reply #1 on: March 11, 2017, 09:28:02 pm »
Well, I know this is not perfect yet but think I'm getting closer; it seems to work. 

Created another trigger and condition for closed sensor.

Complementary action is as follows:

-----  SET THIS VARIABLE to match needs of your system -----
Device = 49 ---->>  Device: Device#  of Outlet or Light to "STOP BLINKING"
-------------------------------------------------------------------
Call ='urn:upnp-org:serviceId:SwitchPower1';Do ='SetTarget';Nil =""
function BlinkOn()
 luup.call_action(Call,Do,{newTargetValue=0},Device)  -->Turn light off end
end
function BlinkOff()
 luup.call_action(Call,Do,{newTargetValue=0},Device)  -->Turns light off end
end
if (Run == "1") then Run = "0" --> Stops BlinkOn & BlinkOff functions from running??
 else Run = "0" --> Really mean it this time...stop blinking!!
end