Jump to content

Help programming motion from alarm to control light


danbutter

Recommended Posts

I have DSCLink running and it is working ok.

I have a motion hooked to the panel change a state variable in the ISY.

I then have a program to turn on light when variable state is seen.

It does. I then have a wait 5 mins and turn light off.

However it doesn't wait.

The second the motion sensor sees no motion the light goes off again.

 

What am I missing?

Link to comment

I tried this one and the light comes on as desired, but never turns off.

Laundry Motion - [ID 0009][Parent 0001]

If
        $Laundry_Light is 1
 
Then
        Set 'Basement / Laundry Light' On
        Wait  5 minutes 
        Set 'Basement / Laundry Light' Off
 
Else
   - No Actions - (To add one, press 'Action')
 


and then I tried this one and the light is only on for as long as motion is seen.

Laundry Motion - [ID 0009][Parent 0001]

If
        $Laundry_Light is 1
 
Then
        Set 'Basement / Laundry Light' On
        Wait  5 minutes 
 
Else
        Set 'Basement / Laundry Light' Off
 


I'm pretty new at all this so it is probably something simple, but usually I can stumble through and figure things out.  Not yet on this one though.

I'm open to ideas!

Link to comment

danbutter

 

Between the two examples it sounds like the Variable is changing value when motion stops.  If the problem is not clear post the Program setting the Variable.

 

In the first example the Wait is terminated when Variable $Laundry_Light no longer equals 1.   The Wait terminating is normal Wait operation when the Program If Condition causes the Program to Trigger while in the Wait.  This leaves the Laundry Light On as there is nothing in Else clause. 

 

In the second example the Wait has no statements after the Wait so it has no affect (does not actually Wait).  When the Variable changes state after motion stops the Program is Triggered, the If is now False so the Else executes.

Link to comment

danbutter

 

Between the two examples it sounds like the Variable is changing value when motion stops.  If the problem is not clear post the Program setting the Variable.

 

In the first example the Wait is terminated when Variable $Laundry_Light no longer equals 1.   The Wait terminating is normal Wait operation when the Program If Condition causes the Program to Trigger while in the Wait.  This leaves the Laundry Light On as there is nothing in Else clause. 

 

In the second example the Wait has no statements after the Wait so it has no affect (does not actually Wait).  When the Variable changes state after motion stops the Program is Triggered, the If is now False so the Else executes.

 

This concept of the IF being evaluated again during the processing of the THEN seems so weird to me.  I don't think I've run into a programming language that does that because often in the THEN statement you modify variables that make the IF no longer true (like a counter).

Link to comment

kohai

 

The Wait and Repeat statements have the same characteristics.  For some functions it makes more sense.

 

If Control 'motionsensor-sensor' is switched On

Then

    Set 'something' On

    Wait 5 minutes

    Set 'something' Off

Else

 

As long as the motion sensor senses motion the Wait is refreshed with a full 5 minutes.  Only when no motion is sensed for 5 minutes does 'something' turn Off.

Link to comment

kohai

 

The Wait and Repeat statements have the same characteristics.  For some functions it makes more sense.

 

If Control 'motionsensor-sensor' is switched On

Then

    Set 'something' On

    Wait 5 minutes

    Set 'something' Off

Else

 

As long as the motion sensor senses motion the Wait is refreshed with a full 5 minutes.  Only when no motion is sensed for 5 minutes does 'something' turn Off.

 

Interesting, I guess that makes sense... kind of like a WHILE but different.

Link to comment

Thanks a lot for all the help.  I ended up doing this:

Laundry Motion - [ID 0009][Parent 0001]

If
        $Laundry_Light is 1
 
Then
        Set 'Basement / Laundry Light' On
 
Else
        Wait  1 minute 
        Set 'Basement / Laundry Light' Off
 


...and it works great.  When it was going on and off I realized I don't need to have it wait so long since the motion seems to see you breathe down there.

Thanks again!

Link to comment

If the variable isn't needed for other programs, there are a few ways to do this without the variable. Which either makes it more or less complex :) ...  but it is always good to know multiple ways of solving these problems....

Here is one way, using the motion sensor commands to directly control the program:

Laundry Motion - [ID 0009][Parent 0001]

If
        Control 'Motion Sensor-Sensor' is switch On
     Or Control 'Motion Sensor-Sensor' is not switched Off

Then
        Set 'Basement / Laundry Light' On

Else
        Wait 1 minute
        Set 'Basement / Laundry Light' Off

With the above If construct, the "Then" clause will run when the sensor sends the On command, and the "Else" clause will run when the sensor sends the Off command.  The "is not" is used to specify to run the Else clause when the statement is true.

 

Here is another way, and is the way I use, as it results in slightly faster response.  Whether the faster response is noticeable or not I don't know, but I set this up right after I had set up an open/close sensor which responds slowly (I'm not sure if the slow response is due to the sensor itself, the ISY or the target device).

 

1) Change the motion sensor to only send On commands (assuming the one you are using can do this).

2) Link the motion sensor directly with the target device (Basement / Laundry Light).  That is, make the motion sensor a controller for the light, and the light a responder to the sensor.  Mine are linked via a scene, but I honestly don't remember if a scene is required or not.

 

Doing these 2 steps removes the ISY from the "turn on" command.  The sensor directly turns on the lights.

 

Then you only need the program to turn the lights off, which could look like this:

Laundry Motion - [ID 0009][Parent 0001]

If
        Control 'Motion Sensor-Sensor' is switched On
 
Then
        Wait 1 minute
        Set 'Basement / Laundry Light' Off
 
Else
   - No Actions
 

This program essentially just starts a timer when the sensor sends the On command, and will turn off the light after 1 minute without seeing another On command.

 

Note that to get the exact same behavior as the your program, you'd need to make the wait time 1 minute + the Off time of your sensor.  This timer starts with the On, while yours starts with the Off.

 

-Kyle

Link to comment

danbutter, thanks for this thread.  I had the same issue (although with an Insteon motion sensor) and trying to fix it, I came up with basically the two programs you did in post #3.  Great minds and all that.   :)

 

Thanks to everyone for the help.  I think I understand the THEN and WAIT better now.

Link to comment

Kman,

 

I don't believe that this was an insteon motion sensor (at least it was not stated as such).  It sounded like a motion sensor wired to some security panel which, in turn, triggered the variable.

 

Ah ... missed that in the first post.  Makes sense that he needs the variable then.

Link to comment

Not to hijack this thread, but I've got a similar if/then/else question.

 

My scenario:

 

1. IF the front door is opened, turn on the chandelier.

2. Only turn OFF the light if the front door is closed AND there isn't any motion inside for 2 minutes. (e.g. if I invite someone in and close the door because it is cold I don't want the light to turn off on me)

 

I created the following:

 

 

Front Door - Chandelier - [iD 000C][Parent 0001]

 
If
        $sAlarmZ01_FrontDoor is 1
    And $sAlarmZ17_FrontEntryMotion is 1
 
Then
        Resource 'Centralite-EntryChandelierOn'
 
Else
        Wait  2 minutes 
        Resource 'Centralite-EntryChandelierOff'

 

The problem this has is that the ELSE is always being queued when the inside motion sensor triggers.  If I'm inside the house and I have the chandelier ON, then it will turn it OFF 2 minutes after sensing motion (because the door isn't open too).  I don't see a way to do an embedded IF inside the ELSE.  

 

Programmatically, I don't know the state of the chandelier -- I don't know if it is On or Off.  Maybe in the future I'll create a really awesome Centralite interface to ISY.  I can only tell it to go on or off.

Link to comment

My initial reaction would be to break this into two programs (I will let you figure out the variables and alarm system resources).

 

If

door is open

and door is not closed

then

turn on light

else

enable second program

run second program (then path)

 

second program (normally disabled):

 

if

motion sensor is triggered

then

wait 2 minutes

turn off light

disable second (this) program

else

nothing

 

Are there going to be cases here where you may have manually turned on the lights and want them to stay on regardless of whether the door subsequently opens or closes?

 

Perhaps what you should consider is to put these into a program folder with a condition such as:

 

If third program is true

then run the programs in this folder

 

third program

if

control light is turned on

and control light is not turned off

then

nothing

else

nothing

 

Hopefully, these give you some ideas how to proceed.

Link to comment

Archived

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


×
×
  • Create New...