Jump to content

Motion Sensor/Lights program


tome

Recommended Posts

Posted

I have a motion sensor in my entry area. The way I want it to work is:

 

1) If it is evening and no one has turned on the entry light, motion in the area should cause lights to come on. After a timeout period, they should go off on their own.

 

2) If someone turns on the lights manually (controlled by a SL), they should stay on unless turned off at the switch.

 

3) Additionally, if the motion sensor turned them on, but someone then turns the switch on as well (before the motion program turns them off), they should stay on until turned off at the switch. This is just a special case of #2 - using the SL to signal I want them left on.

 

The problem I have with what I currently have programmed is that if I turn them on at the switch and someone (or some dog :-) trips the motion sensor, the lights will go out after the timeout period.

 

My program(s) that control this now are as follows. What/where can I add something that will leave the lights on if turned on from the switch?

 

Folder "Entry Light Control"

EntryLightControlStatus

EntryLightsOff

EntryLightsOn

EntryMotion

EntryOccupied

 

Folder "Time Variables"

Evening

 

EntryLightControlStatus

If

From Sunrise

To Sunset (same day)

And (

Status 'EntryLightsEast' is On

Or Status 'EntryLightsWest' is On

)

Then

-No Actions - (To add one, press 'Action')

Else

-No Actions - (To add one, press 'Action')

 

EntryLightsOff

If

Program 'EntryOccupied' is False

AND Program 'Evening' is True

Then

Set Scene 'FrontPorchControl' Off

Else

-No Actions - (To add one, press 'Action')

 

EntryLightsOn

If

Program 'EntryOccupied' is True

AND Program 'Evening' is True

Then

Set Scene 'FrontPorchControl' On

Else

-No Actions - (To add one, press 'Action')

 

EntryMotion

If

Status 'EntryMotion-Sensor' is On

Then

-No Actions - (To add one, press 'Action')

Else

-No Actions - (To add one, press 'Action')

 

EntryOccupied

If

Program 'EntryMotion' is True

Or From Last Run Time for 'EntryMotion'

For 0 seconds

Then

-No Actions - (To add one, press 'Action')

Else

-No Actions - (To add one, press 'Action')

 

 

Evening

If

From Sunset

To Sunrise (next day)

Then

-No Actions - (To add one, press 'Action')

Else

-No Actions - (To add one, press 'Action')

Posted

Hello,

 

My suggestion would be:

 

If
  Control 'Entry Light Switch' is Switched On

Then
  Disable [all programs that automatically turn the lights off]

 

and then one to re-enable them again:

 

If
  Control 'Entry Light Switch' is Switched off

Then
  Enable [all the programs you disabled above]

 

This is what I use for my garage lights (same applications) and it works great.

 

- Brian

Posted
Hello,

 

My suggestion would be:

 

...code deleted....

 

This is what I use for my garage lights (same applications) and it works great.

 

- Brian

 

Thanks Brian,

That might have done it. I now have:

 

DisableAutomaticControl

If
   Control 'EntryLightsEast' is switched On
 OR Control ''EntryLightsWest' is switched On
Then
    Disable Program 'EntryLightsOff'
Else
 - No Actions - (To add one, press 'Action')

 

and

 

EnableAutomaticControl

If
    Control 'EntryLightsEast' is switched Off
 OR Control ''EntryLightsWest' is switched Off
Then
     Enable Program 'EntryLightsOff'
Else
  - No Actions - (To add one, press 'Action')

Posted

That is quite the complicated web of programs there. It seems overly so, to me. What is the EntryLightControlStatus used for? This is your folder condition? Which programs are in this folder?

 

1) If it is evening and no one has turned on the entry light, motion in the area should cause lights to come on.

You appear to have two entry lights (east and west). Do you want to disable the motion program if a SPECIFIC (east? west?) one is on, EITHER are on, or only if BOTH are on?

 

2) If someone turns on the lights manually (controlled by a SL), they should stay on unless turned off at the switch.

If one light is on manually, how do you want this to affect motion control of the other?

 

3) Additionally, if the motion sensor turned them on, but someone then turns the switch on as well (before the motion program turns them off), they should stay on until turned off at the switch.

If both lights are on as a result of motion, and you manually activate only one switch, how do you want this to affect the automatic off of the second switch? If both lights are to remain on, are you willing to manually turn off two switches or do you want a single switch control of both lights?

 

What devices are in your "frontporchcontrol" scene and which of these are controllers?

 

Writing without fully understanding your requirements, why not take advantage of the oft-maligned feature that stops programs from executing when there is a change in entry conditions:

 

Program 1

 

if
time from sunset to sunrise (next day)
And Status 'EntryLightsEast' is not On 
And Status 'EntryLightsWest' is not On
then 
Set Scene 'FrontPorchControl' On 
Wait timeout period
Set Scene 'frontPorchControl' off
else

 

This program would not execute if either a) during the day or B) if EITHER of the entry lights are on. Furthermore, if (after the scene is turned on and during the wait period) EITHER of the entry lights are turned on manually, the execution will stop and BOTH lights will remain on until both are turned off manually.

 

The problem I foresee with this is the potential that sunrise occurs during a wait period. If so, the lights will remain on. To counter this possibility, I would add a second program:

 

if 
time is sunrise
then
Set Scene 'frontPorchControl' off

 

What am I missing?

Posted
That is quite the complicated web of programs there. It seems overly so, to me. What is the EntryLightControlStatus used for? This is your folder condition? Which programs are in this folder?

 

The folder is called "Entry Light Control" and everything is in there except "Evening" which is in the Time Variables folder. I have them listed this way in my original message. EntryLightControlStatus appears to be doing nothing. Not sure why I had that. It has been a while since I have looked at this...

 

 

You appear to have two entry lights (east and west). Do you want to disable the motion program if a SPECIFIC (east? west?) one is on, EITHER are on, or only if BOTH are on?

 

East, West, and a Keypad are all in a Scene (FrontPorchControl) together as controllers. Turning on/off one, turns on/off the others. They are just multiple locations for turning on the same set of lights. I think this answers the next three questions.

 

So skipping ahead...

 

Writing without fully understanding your requirements, why not take advantage of the oft-maligned feature that stops programs from executing when there is a change in entry conditions:

 

Program 1

 

if
time from sunset to sunrise (next day)
And Status 'EntryLightsEast' is not On 
And Status 'EntryLightsWest' is not On
then 
Set Scene 'FrontPorchControl' On 
Wait timeout period
Set Scene 'frontPorchControl' off
else

 

This program would not execute if either a) during the day or B) if EITHER of the entry lights are on. Furthermore, if (after the scene is turned on and during the wait period) EITHER of the entry lights are turned on manually, the execution will stop and BOTH lights will remain on until both are turned off manually.

 

The problem I foresee with this is the potential that sunrise occurs during a wait period. If so, the lights will remain on. To counter this possibility, I would add a second program:

 

if 
time is sunrise
then
Set Scene 'frontPorchControl' off

 

What am I missing?

 

I think you are missing the motion sensor entirely. I am all for simplification, less is more! I will think about it some more. I recall trying to do it simply the first time and it didn't work well at all, and hence the various programs as variables approach.

 

Thanks,

-Tome

Posted

How 'bout Program1:

 

If
       Control 'EntryMotion-Sensor' is switched On
   And Status 'EntryLights' is Off
   And From Sunset
       To Sunrise (next day)
Then
       Run Program 'Program2' (Then Branch)
Else
       - Nothing -

and Program2:

 

If
       Control 'EntryLightsSwitch' is switched On
   And Control 'EntryLightsSwitch' is not switched On
Then
       Set Scene 'FrontPorchControl' On
       Wait 3 mintues
       Set Scene 'FrontPorchControl' Off
Else
       - Nothing -

Posted
I think you are missing the motion sensor entirely

 

Indeed! I would add this to my first program.

 

if 
time from sunset to sunrise (next day) 
And Status 'EntryLightsEast' is not On 
And Status 'EntryLightsWest' is not On 
And Control Motion Sensor switched on <<<<<<then 
Set Scene 'FrontPorchControl' On 
Wait timeout period 
Set Scene 'frontPorchControl' off 
else

 

But I like kingwr solution just as well.

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...