Jump to content

Override Motion Sensor Timed Shut-Off?


Kentinada

Recommended Posts

I have motion sensors on outdoor lights that turn the lights on for 5 minutes when motion is detected and then turn them off. I’d like to have a program I can run that would override the motion sensor program and leave the lights on until I run the program again. Ideas?

 

 

Sent from my iPad using Tapatalk

Link to comment

All my lights triggered by motion sensors are on switches.  I have programs that, when the switch is manually toggled ON, the motion program is disabled.  When the switch is manually toggled OFF, the program is enabled.

This is an example of where using a scene between the motion sensor and switch will not work.

Link to comment
OUTLIGHTS.SHED.OVERRIDE - [ID 0027][Parent 0020]

If
        Control 'Outdoors / Shed Lights' is switched On
    And Control 'Outdoors / Shed Lights' is not switched Off
 
Then
        Send Notification to 'Kent Txt' content 'Shed Switch On'
 
Else
        Send Notification to 'Kent Txt' content 'Shed Switch Off'

Is this the proper method to check if a switch was turned on or off?

Link to comment
2 hours ago, Kentinada said:

OUTLIGHTS.SHED.OVERRIDE - [ID 0027][Parent 0020]

If
        Control 'Outdoors / Shed Lights' is switched On
    And Control 'Outdoors / Shed Lights' is not switched Off
 
Then
        Send Notification to 'Kent Txt' content 'Shed Switch On'
 
Else
        Send Notification to 'Kent Txt' content 'Shed Switch Off'

Is this the proper method to check if a switch was turned on or off?

That would work (send notifications), but certainly not affect any motion sensors

Link to comment

Yes, sorry.  That was my test program to see if the IF test worked which it seemed to.  Here is the code I have for 3 shed motion senor related programs.  This first program checks for the sensor being on in the timeframe shown.  It will then run the action program. 

OUTLIGHTS.SHEDMOTION.COND - [ID 001C][Parent 0020]

If
        Status  'Outdoors / Shed Motion-Sensor' is On
    And From    Sunset 
        To      Sunrise + 10 minutes (next day)
 
Then
        Run Program 'OUTLIGHTS.SHEDMOTION.BODY' (Then Path)
 
Else
   - No Actions - (To add one, press 'Action')
 

Here is the action program. Before wanting to override with the switch, the IF condition was empty meaning the condition program above completely controlled when the lights would turn on.  Now the condition must be true in the program above AND the override must not be set.  See the last program below.

OUTLIGHTS.SHEDMOTION.BODY - [ID 001D][Parent 0020]

If
        Program 'OUTLIGHTS.SHEDMOTION.OVERRIDE' is False
    And Program 'OUTLIGHTS.SHEDMOTION.COND' is True
 
Then
        Set 'Outdoors / Shed Lights' Fast On
        Send Notification to 'Kent Txt' content 'Shed Motion Detected'
        Wait  5 minutes 
        Set 'Outdoors / Shed Lights' Fast Off
        Run Program 'OUTLIGHTS.SHEDMOTION.BODY' (Else Path)
 
Else
   - No Actions - (To add one, press 'Action')
 

Here is the override program.

OUTLIGHTS.SHEDMOTION.OVERRIDE - [ID 0027][Parent 0020]

If
        Control 'Outdoors / Shed Lights' is switched On
    And Control 'Outdoors / Shed Lights' is not switched Off
 
Then
        Set 'Outdoors / Shed Lights' Fast On
        Send Notification to 'Kent Txt' content 'Shed Switch On'
 
Else
        Set 'Outdoors / Shed Lights' Fast Off
        Send Notification to 'Kent Txt' content 'Shed Switch Off'
 

Tonight will be the first test.  Think it will work? 

 

Link to comment

A couple of things.  First, I would disable shedmotion.body.  You do not want that program self-triggering...only run when called from the .cond program.  Second, I would get rid of the second condition of the .body program.  Since it will be called by the .cond program, the second condition is redundant.  

Regarding the "shed lights" ...are they a dimmer?  If not, then the commands in the third program to turn the on/off are redundant (would they not already be on/off when the program is triggered?).  If they are a dimmer, why not simply make the default action 100%-on and zero ramp rate (effectively a "fast on")?

Link to comment

oberkc, a couple questions back for you.

  • When you say disable the shedmotion.body, you mean removing the IF conditions that would trigger it - correct?
  • The shed lights are on a simple on/off switch so yes the fast on/off was not right.  The point of setting them to on in the override program was because of throwing the switch but it just occurred to me (duh!) that I would have pressed the switch to turn them anyway.  Not smart. 
  • But the problem I think I still have is if the cond and body programs are enabled and waiting for the motion sensor to detect motion after sunset, the body program will turn them on for 5 minutes.  If I manually turn them on, and motion is detected, it will start a 5 minute timer and turn them off.  The override program was my attempt in preventing the body program from running.  How do I do that based on the changes you suggest?

Thanks.

Link to comment
3 hours ago, Kentinada said:

When you say disable the shedmotion.body, you mean removing the IF conditions that would trigger it - correct?

No.  Right-click on the program>>>disable.  This will keep the conditions, but the program conditions will only evaluate them when called by the other (.cond) program.

 

3 hours ago, Kentinada said:

But the problem I think I still have is if the cond and body programs are enabled and waiting for the motion sensor to detect motion after sunset, the body program will turn them on for 5 minutes.  If I manually turn them on, and motion is detected, it will start a 5 minute timer and turn them off.  The override program was my attempt in preventing the body program from running.  How do I do that based on the changes you suggest?

First, my thoughts were that the .body program would NOT be enabled (thus my suggestion).  I do not want it triggering itself by the conditions.  Second, once motion is detected and triggers the .cond program, it would call the .body program.  (But now that I re-look, I missed something: make sure you call the "IF" path of the .body program, not the "THEN" path. )  This will trigger the evaluation of the .body conditions, which will be false (because .override is TRUE) and, therefore, not start a countdown.

One other consideration...what if the motion has already triggered a countdown, THEN you turn the switch on?  Do you want to halt the countdown?

Link to comment
11 hours ago, oberkc said:

No.  Right-click on the program>>>disable.  This will keep the conditions, but the program conditions will only evaluate them when called by the other (.cond) program.

I thought if I disabled a program, it would not/could not run.  Can a disabled program still run if it's called by another program?

11 hours ago, oberkc said:

First, my thoughts were that the .body program would NOT be enabled (thus my suggestion).  I do not want it triggering itself by the conditions.  Second, once motion is detected and triggers the .cond program, it would call the .body program.  (But now that I re-look, I missed something: make sure you call the "IF" path of the .body program, not the "THEN" path. )  This will trigger the evaluation of the .body conditions, which will be false (because .override is TRUE) and, therefore, not start a countdown.

So under normal motion, the COND program would call the BODY program's IF test.  Most of the time, the OVERRIDE would be false and the COND would be true which would allow the body Then clause to run (assuming it can be called even if it's disabled).  If I turn on the light switch which makes the OVERRIDE program run the THEN clause, the IF test of the BODY program would fail because OVERRIDE would be true and the timer would never start.  Correct? 

Is there another way than the OVERRIDE program to accomplish this because essentially the OVERRIDE program becomes a mere state machine of being either true or false.  Maybe there's a way to do it without adding another program?

11 hours ago, oberkc said:

One other consideration...what if the motion has already triggered a countdown, THEN you turn the switch on?  Do you want to halt the countdown?

Yes, that would be my preference.  Ideas?

Link to comment

Something else I guess I discovered about my OVERRIDE program is that having the IF test and no Then or Else statements does not work.  i.e. I just wanted the IF test to run and set the status to True or False but without some statement to execute in the Then clause, the status does not change to True.  Back in my programming days we used to have a Null program statement.  If you simply want the program to change the status which is used in another program, what do you put there?  I really don't want to be texted every time the switch is turned on or off. 

Link to comment
8 hours ago, Kentinada said:

Can a disabled program still run if it's called by another program?

yes

 

8 hours ago, Kentinada said:

So under normal motion, the COND program would call the BODY program's IF test.  Most of the time, the OVERRIDE would be false and the COND would be true which would allow the body Then clause to run (assuming it can be called even if it's disabled).  If I turn on the light switch which makes the OVERRIDE program run the THEN clause, the IF test of the BODY program would fail because OVERRIDE would be true and the timer would never start.  Correct? 

correct

 

8 hours ago, Kentinada said:

Is there another way than the OVERRIDE program to accomplish this because essentially the OVERRIDE program becomes a mere state machine of being either true or false.  Maybe there's a way to do it without adding another program?

I suppose one could use variables, but this simply adds another layer of complexity.  Yes, the override program is a simple state machine.

 

8 hours ago, Kentinada said:

Yes, that would be my preference.  Ideas?

Of course.  When your override program runs TRUE, have it halt the body program.  If the body program is in a wait state, it will cease waiting.

 

7 hours ago, Kentinada said:

Something else I guess I discovered about my OVERRIDE program is that having the IF test and no Then or Else statements does not work.  i.e. I just wanted the IF test to run and set the status to True or False but without some statement to execute in the Then clause, the status does not change to True.  Back in my programming days we used to have a Null program statement.  If you simply want the program to change the status which is used in another program, what do you put there?  I really don't want to be texted every time the switch is turned on or off. 

I am not sure I knew that.  Interesting.  Perhaps having a variable change value for ON or OFF has value, after all.

Link to comment
9 hours ago, Kentinada said:

Something else I guess I discovered about my OVERRIDE program is that having the IF test and no Then or Else statements does not work.  i.e. I just wanted the IF test to run and set the status to True or False but without some statement to execute in the Then clause, the status does not change to True.  Back in my programming days we used to have a Null program statement.  If you simply want the program to change the status which is used in another program, what do you put there?  I really don't want to be texted every time the switch is turned on or off. 

This surprised me, so I checked my method and found that I remembered incorrectly.  In fact, I do set a variable...zero for normal operation and one for when the switch is manually turned on and I want the motion timer to be ignored.  I don't recall why I did it that way.  Perhaps I learned the same thing you did, but forgot?  

Link to comment

Oberkc, so I added a state variable for the switch on or off and added it to my Override program.  I also added a Stop command for the Body program.  It occurred to me that if I had the stop, I probably didn't need the state variable because I didn't use it anywhere and with the Stop command, the program would execute.  It all works so here is what I ended up with for anyone else who's interested in doing something similar.

CONDITION program

OUTLIGHTS.SHEDMOTION.COND - [ID 001C][Parent 0020]

If
        Status  'Outdoors / Shed Motion-Sensor' is On
    And From    Sunset 
        To      Sunrise + 10 minutes (next day)
 
Then
        Run Program 'OUTLIGHTS.SHEDMOTION.BODY' (If)
 
Else
   - No Actions - (To add one, press 'Action')
 

BODY program (which is disabled)

OUTLIGHTS.SHEDMOTION.BODY - [ID 001D][Parent 0020][Not Enabled]

If
        Program 'OUTLIGHTS.SHEDMOTION.OVERRIDE' is False
    And Program 'OUTLIGHTS.SHEDMOTION.COND' is True
 
Then
        Set 'Outdoors / Shed lights' On
        Send Notification to 'Kent Txt' content 'Shed Motion Detected'
        Wait  5 minutes 
        Set 'Outdoors / Shed lights' Off
        Run Program 'OUTLIGHTS.SHEDMOTION.BODY' (Else Path)
 
Else
   - No Actions - (To add one, press 'Action')
 

OVERRIDE program

OUTLIGHTS.SHEDMOTION.OVERRIDE - [ID 0027][Parent 0020]

If
        Control 'Outdoors / Shed lights' is switched On
    And Control 'Outdoors / Shed lights' is not switched Off
 
Then
        Stop program 'OUTLIGHTS.SHEDMOTION.BODY'
 
Else
   - No Actions - (To add one, press 'Action')
 

Thanks for all the help!

 

Link to comment

Archived

This topic is now archived and is closed to further replies.


×
×
  • Create New...