Jump to content

Motion sensor program to turn on lights


drinkwater

Recommended Posts

I have a motion sensor and created a program to turn on a light when motion is detected (see below).

This works fine, however when I turn off the switch manually, the program kicks in again (because motion is detected again) and turns the light back on.

Any way to get this to work?

If
        Status  'Motion1-Sensor' is On
    And Status  'Basement Office Light' is Off
    And From    Sunset 
        To      Sunrise +  1 hour  (next day)
 
Then
        Set 'Basement Office Light' On
 
Else
   - No Actions - (To add one, press 'Action')

Link to comment

I think by far the most used method is not to turn the switch off, but to turn the light on, wait until there is no motion for a period of time and turn it back off.  You can set it up so that repeated motion, resets the wait... when the wait finally expires... the light turns off.  There are many examples of that in other threads.

If you really want to be able to turn the switch off, then I would create a second program using 'Control' rather than 'Status':

If

   basement office light is switched off

then

  Disable Program 1

  wait 10 minutes

  Enable program 1

 

Of course you can make the wait be anything you want.

  

Edited by MrBill
Link to comment
7 hours ago, drinkwater said:

I have a motion sensor and created a program to turn on a light when motion is detected (see below).

This works fine, however when I turn off the switch manually, the program kicks in again (because motion is detected again) and turns the light back on.

Any way to get this to work?

If
        Control  'Motion1-Sensor' is On   <<<<<<<<change from "status" to "control"
    And Status  'Basement Office Light' is Off   <<<<<<<<<<< not needed, can cause complications, including when manual operation of switch
    And From    Sunset 
        To      Sunrise +  1 hour  (next day)
 
Then
        Set 'Basement Office Light' On
 
Else
   - No Actions - (To add one, press 'Action')

See above for suggestions.  I expect that this will turn on the light when motion is sensed.  Since none was specified, there is no automatic method here to turn the light off.  Manually turning off the light will NOT trigger the program again.

Link to comment

Based on the suggestions I created another program :

If
        Control 'Basement Office Light' is switched Off
 
Then
        Disable Program 'Turn on basement office light'
        Wait  1 minute 
        Enable Program 'Turn on basement office light'
 
Else
   - No Actions - (To add one, press 'Action')

 

This seems to work however I am wondering if it's just by chance since for this to work, the execution order of the programs become important.

This program has to run before the 'Turn on basement office light' program and it does, but I never specified any execution order of the programs.


 Can program exec order be specified or are they just run alphabetical order of the program name ?

Link to comment
25 minutes ago, drinkwater said:

Based on the suggestions I created another program :

If
        Control 'Basement Office Light' is switched Off
 
Then
        Disable Program 'Turn on basement office light'
        Wait  1 minute 
        Enable Program 'Turn on basement office light'
 
Else
   - No Actions - (To add one, press 'Action')

 

This seems to work however I am wondering if it's just by chance since for this to work, the execution order of the programs become important.

This program has to run before the 'Turn on basement office light' program and it does, but I never specified any execution order of the programs.


 Can program exec order be specified or are they just run alphabetical order of the program name ?

ISY is event based... Programs don't run in order they run because an event occurred.   You actually unknowingly blocked the teeter-tooter effect with the second program in your first program.  The first programs conditions are only met if the light is off: "And Status  'Basement Office Light' is Off". So motion won't activate that program again until the light is off.  Pressing the off switch is disabling the motion sensor and turn the light off.

Link to comment
2 hours ago, MrBill said:

ISY is event based... Programs don't run in order they run because an event occurred.   You actually unknowingly blocked the teeter-tooter effect with the second program in your first program.  The first programs conditions are only met if the light is off: "And Status  'Basement Office Light' is Off". So motion won't activate that program again until the light is off.  Pressing the off switch is disabling the motion sensor and turn the light off.

I understand that it's event based but I still think the order of the events has an impact.

To turn off the light manually at the switch I have to pass by the motion sensor so the motion sensor will become On and after I press the switch the status of the basement office light will be Off - so Program 1 will run again unless Program 2 runs first which disables the Program 1 for one minute (giving time to the motion sensor to become Off).

I don'r see how this would work without having that order.

Link to comment
3 minutes ago, drinkwater said:

I understand that it's event based but I still think the order of the events has an impact.

To turn off the light manually at the switch I have to pass by the motion sensor so the motion sensor will become On and after I press the switch the status of the basement office light will be Off - so Program 1 will run again unless Program 2 runs first which disables the Program 1 for one minute (giving time to the motion sensor to become Off).

I don'r see how this would work without having that order.

Because STATUS is being used, Program 1 doesn't know the motion detector is "on", Program 1 only knows what the motion detector last told the ISY, about its status.  This is a troubling point for most new users, but Status means "what the ISY thinks the status is".  The motion detector only sends it's status to the ISY when it turns on, or turns off.   There is not a continuous update of status occurring-- the motion detector turns on, sends ON to the ISY, the ISY changes the status flag to ON, nothing else happens until the motion detector turns off, then it sends OFF and the ISY changes the status flag to OFF.   In some cases (such as noisy power line) the status in the ISY can become confused because it missed one of the the communications.

How CONTROL differs from STATUS is that control is actually watching for those signals being transmitted from the devices.   So in the second program we are actually watching for the arriving signal to the ISY that says the switch has been turn off (which also updates the status flag in the ISY to off.

Status = what the ISY was last told about the status

Control = Actual incoming control signals regardless of current status.

  • Like 2
Link to comment
48 minutes ago, drinkwater said:

I understand that it's event based but I still think the order of the events has an impact.

To turn off the light manually at the switch I have to pass by the motion sensor so the motion sensor will become On and after I press the switch the status of the basement office light will be Off - so Program 1 will run again unless Program 2 runs first which disables the Program 1 for one minute (giving time to the motion sensor to become Off).

I don'r see how this would work without having that order.

In addition to what MrBill stated, I use a longer period between messages to lessen the chance of an "on" signal being sent. 

While the motion may trigger upon movement no message gets sent. This allows the motion sensor to see you but not cause any programs to respond to the motion

Link to comment
3 hours ago, drinkwater said:

Based on the suggestions I created another program :

If
        Control 'Basement Office Light' is switched Off
 
Then
        Disable Program 'Turn on basement office light'
        Wait  1 minute 
        Enable Program 'Turn on basement office light'
 
Else
   - No Actions - (To add one, press 'Action')

 

This seems to work however I am wondering if it's just by chance since for this to work, the execution order of the programs become important.

This program has to run before the 'Turn on basement office light' program and it does, but I never specified any execution order of the programs.


 Can program exec order be specified or are they just run alphabetical order of the program name ?

One caveat with that. If you disable a program in the middle of timing, it will stop running and may never turn the light off, leaving it on. Measures need to be taken to clean all possible combinations up when re-enabling the program.

 

In addition to the status/control methods, and the exemplify this, I have the original MS devices and despite their status showing on permanently, they also send a control On each time motion is detected. The differences between MS1 and MS II units is becoming quite large.

Edited by larryllix
Link to comment
1 hour ago, MrBill said:

Because STATUS is being used, Program 1 doesn't know the motion detector is "on", Program 1 only knows what the motion detector last told the ISY, about its status.  This is a troubling point for most new users, but Status means "what the ISY thinks the status is".  The motion detector only sends it's status to the ISY when it turns on, or turns off.   There is not a continuous update of status occurring-- the motion detector turns on, sends ON to the ISY, the ISY changes the status flag to ON, nothing else happens until the motion detector turns off, then it sends OFF and the ISY changes the status flag to OFF.   In some cases (such as noisy power line) the status in the ISY can become confused because it missed one of the the communications.

How CONTROL differs from STATUS is that control is actually watching for those signals being transmitted from the devices.   So in the second program we are actually watching for the arriving signal to the ISY that says the switch has been turn off (which also updates the status flag in the ISY to off.

Status = what the ISY was last told about the status

Control = Actual incoming control signals regardless of current status.

I agree and thx so much for the explanations.

But I still believe the order of the events matters - when turning off the light switch manually, if the second program is triggered after the first program it can't work IMO

When I turn off the light switch, the light status is now Off and I am also causing the motion sensor status to become On (since I am passing by it). So program 1 will trigger (because the motion sensor is now On and the basement light status is now Off) - so the light will turn on.

If Program 2 runs before any of that (because of the light Control is switched off), then program 1 is disabled for 1 minute (in which case the motion sensor status will become Off within that time range) so when reenabling Program 1 after one minute - the conditions of Program 1 are not met anymore so the light won't turn on. If Program 1 is triggered before Program 2 then it would be too late - the light will already have been turned back on.

I am starting to think Control events are handled before Status events which would confirm why it works.

Not trying to be difficult just trying to understand...

Edited by drinkwater
Link to comment
1 hour ago, drinkwater said:

I agree and thx so much for the explanations.

But I still believe the order of the events matters - when turning off the light switch manually, if the second program is triggered after the first program it can't work IMO

When I turn off the light switch, the light status is now Off and I am also causing the motion sensor status to become On (since I am passing by it). So program 1 will trigger (because the motion sensor is now On and the basement light status is now Off) - so the light will turn on.

If Program 2 runs before any of that (because of the light Control is switched off), then program 1 is disabled for 1 minute (in which case the motion sensor status will become Off within that time range) so when reenabling Program 1 after one minute - the conditions of Program 1 are not met anymore so the light won't turn on. If Program 1 is triggered before Program 2 then it would be too late - the light will already have been turned back on.

I am starting to think Control events are handled before Status events which would confirm why it works.

Not trying to be difficult just trying to understand...

You pass the motion detector and it does in fact trigger the first program, the next thing that happens tho is that you turn the switch off, at that moment in time the motion detector is likely still on, and program 1 becomes disabled, this ignoring anymore status changes.  Once you've turned the switch off you've also disabled the motion program.   And of course if you turn the switch off first, then motion is triggered nothing happens.

 

Edit to add:  Another point to remember is that Insteon communication is serial in nature.  It doesn't transmit/receive two signals at the same time, whichever insteon device started transmitting first wins the powerline until it's finished speaking, then the next device begins speaking.

Edited by MrBill
Link to comment
On 12/27/2020 at 12:07 PM, drinkwater said:

I am starting to think Control events are handled before Status events which would confirm why it works.

Based on my experience, for a particular device, you are correct - if a Control event occurs for a device, it will be handled by the ISY first before the linked Status event.  When you think about it, that makes sense.  A control event occurs when a signal comes from a device to the ISY telling it about that device.  A status event occurs when the ISY changes the status of a device based on information it has received from the device*.  So the ISY first learns about a Control event, and then uses that information to create a Status event.

* - The ISY will also change the status of a device based other information besides Control events.  For example, if the ISY sends a scene command that affects six devices, it will go ahead and change the status of those six devices based on what those devices should do when they receive the scene command.  Another example is when the ISY receives status messages directly from devices after they have reacted to a controller other than the ISY.  In both of these examples, no Control event would have occurred for the devices because they were not acted upon locally, but instead were acted upon by other controllers.

  • Like 2
Link to comment
On 12/27/2020 at 8:01 AM, drinkwater said:

Based on the suggestions I created another program :

If
        Control 'Basement Office Light' is switched Off
 
Then
        Disable Program 'Turn on basement office light'
        Wait  1 minute 
        Enable Program 'Turn on basement office light'
 

@drinkwater I have simliar programs in most of the rooms where I have sensors turning on lights. however I shorten the disable time to the minimum time it takes to leave the space, ie a small powder room is 5 seconds, another room I use 10 seconds etc. This way the motion detector can do its job again right away. This manually initiated disabling of the MS is needed for guests who dont know that the lights will turn off by themselves, so they always want to manually turn them off as they leave a room. 

Overall this combination of two programs has always worked well. 

Link to comment
Guest
This topic is now closed to further replies.

  • Recently Browsing

    • No registered users viewing this page.
  • Who's Online (See full list)

    • There are no registered users currently online
  • Forum Statistics

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