Jump to content

My Logic Must Be Wrong - Help Needed


KHouse
Go to solution Solved by apostolakisl,

Recommended Posts

Posted (edited)

Attached is a screenshot for what I would assume to be a very basic program that is not working for me.  Appreciate any help anyone can give on what I am doing wrong here.

If garage door sensor or motion sensor is activated, turn garage lights ON.  Wait X number of minutes, then turn garage lights OFF.

The door sensor and motion sensor are ELK, tied to the alarm, while the light switch is INSTEON.

The lights do turn on when triggered...but they do not turn off.

I must be missing something basic or not understanding how this work.  Appreciate any help!

Garage Lights Program.PNG

Edited by KHouse
  • Solution
Posted

It is because the program is terminating when the motion sensor goes back to normal.  Those are status conditions, they trigger whenever the status changes regardless of what it changes to.  So when "violated" occurs, the program triggers, turns the lights on, and starts the timer.  But the sensor will return to "normal" prior to one minute, the program will then stop and start over.  But it will now be false, which runs the "else" clause, which is blank.  

To make this work, you either need to use "control" commands in the if clause since "control" commands only trigger on the precise action. 

Alternatively, you use two programs, the conditions are in the first program and the actions are in the second program. 

If
  elk thing 1 is violated
or elk thing 2 is violated
Then
 run then program 2

Pgm2
If 
 (blank)
Then
 turn light on
 wait 1 minute
 turn light off.

 

  • Like 1
Posted

My preferred way of doing things like this, where the initial triggering condition will cease to be true, is to set a state variable, and then have a separate program look for the variable to become true, do the wait, turn off the light, and reset the variable.

 

- So your first program would be 

 

If garage door is violated

  Or other trigger...

Then Turn light on

   Then Variable garage_light = 1

 

- Second program

 

If Variable garage_light = 1

Then Wait 1 minute

Then Turn light off

Then Variable garage_light = 0 

 

 

  • Like 1
Posted

Thank you both so much.  I was racking my brain trying to think through the logic and figure out what I was missing.  Didn't realize it returns to "normal" before the time is up and that is the root cause of the problem.

Thank you again for the explanation and examples!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...