Jump to content

Motion to trigger outside lights


UD2)17rrh

Recommended Posts

Posted (edited)

I am using the program below to trigger an outside flood light at night.  Is this the best code in which to trigger this?  I get a bit confused if I need Control for motions or Status changes.  Many thanks.  I put in the variable so that if another motion is triggered (there are several at various locations outside) then it checks if the light is already on so not to interrupt the 15 min timer.  Rather than the immediate notification I might just change that to a morning email on how many times the motion was triggered last night (if any).  Open to better code suggestions.  Thanks again.

 

South Side Motion Active

If
        Control 'Outside / Rear Deck South Side-Senso' is switched On
    And From    Sunset
        To      Sunrise (next day)
    And $Sensor_Count is 0
 
Then
        Set Scene 'Flood Lights' On
        Send Notification to 'South Side Motion Activated'
        $Sensor_Count  = 1
        Wait  15 minutes
        $Sensor_Count  = 0
 
Else
        Set Scene 'Flood Lights' Off
 

 

Edited by UD2)17rrh
Text
Posted (edited)
22 minutes ago, UD2)17rrh said:

Is this the best code in which to trigger this?

"Best" is subjective.  On this one, I would be afraid that motion would trigger during the 15min wait, causing the program to re-evaluate and run false, leaving the lights on indefinitely.  Alternatively, if sunrise occurs during wait period, program will halt and leave lights on.  Is your objective to have the motion lights turn off after 15minutes, even if subsequent motion is detected?

22 minutes ago, UD2)17rrh said:

I get a bit confused if I need Control for motions or Status changes.

"Control ...on" will only trigger a program upon receipt of ON signals from the motion sensor.  OFF signals will NOT trigger the program.  It will be TRUE only at that point in time when so triggered.  At all other times that condition will be false.

"Status...on" will trigger programs only upon a CHANGE of status.  Repeated ON signals will NOT trigger the program.  It will be TRUE so long as status remains ON.

22 minutes ago, UD2)17rrh said:

I put in the variable so that if another motion is triggered (there are several at various locations outside) then it checks if the light is already on so not to interrupt the 15 min timer. 

Any time a program is triggered (during a wait or repeat) the program will be interrupted.  The only question is whether the program evaluates TRUE (runs THEN) or FALSE (runs ELSE).  Having the variable does not halt the interruptions.  Rather, having the variable changes the evaluated state (true/false) once interrupted.

As for me, I would actually prefer that a new motion sense would reset the timer back to 15min. 

My recommendation is to state your requirements, in detail.  Write them down.  What do you want to happen when a motion sensor is triggered?  What do you want to happen at sunrise (anything?  Turn off the light?)?  What do you want to happen if motion is sensed and the light is already on (reset the timer?  nothing?)  What do you want to happen when one sensor triggers and a second sensor triggers during the wait period?  After the wait period?

Edited by oberkc
  • Like 1
Posted

Thanks for the reply.  Thought through my needs and here they are....

  1. Between sunset and sunrise, any motion sensed by one of three motion detectors would send an "'ON" command to a set of flood lights all in a scene called "flood lights".
  2. After ~ 15 minutes of no motion (from any motion) the scene would turn OFF.
  3. Subsequent motion would again trigger the ON command.
  4. Additional motion sensed when the scene is on would set the timer back to 15 min.
  5. If the lights are on at sunrise they are then turned OFF.
  6. Daily txt summarizing the number of timers if any the scene was triggered (optional).

How about this programming for 1-5 for example?


Program 1: South Side Motion Active

If
        Control 'Outside / Rear Deck South Side-Senso' is switched On
    And From    Sunset
        To      Sunrise (next day)
 
Then
        Set Scene 'Flood Lights' On
        Wait  15 minutes

Else
        Set Scene 'Flood Lights' Off

Program 2: East Side Motion Active

If
        Control 'Outside / Rear Deck East Side-Senso' is switched On
    And From    Sunset
        To      Sunrise (next day)
 
Then
        Set Scene 'Flood Lights' On
        Wait  15 minutes

Else
        Set Scene 'Flood Lights' Off

Program 3:

If
        Time is Sunrise
 
Then
        Set Scene 'Flood Lights' Off
 
Else
   - No Actions - (To add one, press 'Action')
 

 

Posted

I did not see three motion sensors.

Program 3 is not needed.  The other programs, as now written (added ELSE statement) will take care of this.

Programs one and two should have an additional statement added to the end of each ELSE path: Set Scene 'Flood Lights' Off

I will throw out another option: a single program:

If
  (      

Control 'Outside / Rear Deck South Side-Senso' is switched On

or

Control 'Outside / Rear Deck East Side-Senso' is switched On

or

control third motion sensor is switched on

)
    And From    Sunset
        To      Sunrise (next day)
 
Then
        Set Scene 'Flood Lights' On
        Wait  15 minutes

Set Scene 'Flood Lights' Off

Else
        Set Scene 'Flood Lights' Off

 

For any program, ask yourself what will force an evaluation of the IF clause.  For the ISY, the evaluations are triggered based upon the conditions contained within.  In your (and my) specific cases, the programs would be triggered upon the following events:

- sunset

-sunrise

-receipt of ON commands from one of the two motion sensors.

Regardless of what triggered the evauation, the entire condition is evaluated. 

Any time the evaluation is triggered, WAIT and REPEAT would allow the on-going execution to halt and the program restarted, based on the results of the evaluation.  At sunset, the entire condition is false (no simultaneous receipt of any ON command) and the else path runs.  At sunrise, the entire condition is false, running the else path.  Upon receipt of an ON command, condition could be true (if between sunset and sunrise) or false (if after sunrise and before sunset).

  • Like 3
Posted (edited)
22 hours ago, oberkc said:

For any program, ask yourself what will force an evaluation of the IF clause.  For the ISY, the evaluations are triggered based upon the conditions contained within.  In your (and my) specific cases, the programs would be triggered upon the following events:

 

- sunset

-sunrise

-receipt of ON commands from one of the two motion sensors.

Regardless of what triggered the evauation, the entire condition is evaluated. 

Any time the evaluation is triggered, WAIT and REPEAT would allow the on-going execution to halt and the program restarted, based on the results of the evaluation.  At sunset, the entire condition is false (no simultaneous receipt of any ON command) and the else path runs.  At sunrise, the entire condition is false, running the else path.  Upon receipt of an ON command, condition could be true (if between sunset and sunrise) or false (if after sunrise and before sunset).

This was really, really helpful.  Thanks so much for taking the time to educate on this.  I have gone with your single program (using OR) and I am sure this will do the trick.  I'll later try adding some programming to notify me by txt how often the program was run overnight.  I think I saw something in the cookbook on that.  Thanks again.

Edited by UD2)17rrh
text
Guest
This topic is now closed to further replies.

  • Recently Browsing

    • No registered users viewing this page.
  • Forum Statistics

    • Total Topics
      37k
    • Total Posts
      371.4k
×
×
  • Create New...