Jump to content

Some more programming not working: motion sensor


UD2)17rrh

Recommended Posts

First, I have the newer Insteon Motion Sensor and my ISY is on 4.7.3.  Trying to get the code below to run.  I see a green LED light up on the motion when I approach it but no event triggered.  Is there something obvious here I am missing?  Thank-you.

Driveway Motion

If
        Control 'Motion Sensors / Driveway Motion Sensor-Sensor' is switched On
    And Status  'Outside / House Front (load)' is not On
    And From    Sunset
        To      Sunrise (next day)
 
Then
        Set Scene 'Front House Lights' On
        Set 'Main Floor / Foyer Lamp' On
        Wait  15 minutes
        Set Scene 'Front House Lights' Off
        Set 'Main Floor / Foyer Lamp' Off
 
Else
        Set Scene 'Front House Lights' Off
        Set 'Main Floor / Foyer Lamp' Off
 

 

Link to comment
50 minutes ago, lilyoyo1 said:

I would remove the if front lights are on from your if statement

That worked.  I would like to know why though as I thought my initial programming was saying "if the light is on don't turn it on". 

How could I expand this programming  if I need the light to stay on for a few more hours until my 11 pm script turns all outside lights off?  Or.....would it be better  to run this motion activated script only after 11 pm (or after my outside light scene = not on)?  Hope that makes sense.  Thanks for any help you can offer.

Link to comment
Just now, Techman said:

Also, try removing the lines Sunset to Sunrise for testing purposes.

If the lights then turn  put the Sunset - Sunrise as the first line of code in your IF statement

Thanks for looking and replying.  Is it better to always have the time check first in code?

Link to comment
1 hour ago, UD2)17rrh said:

First, I have the newer Insteon Motion Sensor and my ISY is on 4.7.3.  Trying to get the code below to run.  I see a green LED light up on the motion when I approach it but no event triggered.  Is there something obvious here I am missing?  Thank-you.

Driveway Motion

If
        Control 'Motion Sensors / Driveway Motion Sensor-Sensor' is switched On
    And Status  'Outside / House Front (load)' is not On
    And From    Sunset
        To      Sunrise (next day)
 
Then
        Set Scene 'Front House Lights' On
        Set 'Main Floor / Foyer Lamp' On
        Wait  15 minutes
        Set Scene 'Front House Lights' Off
        Set 'Main Floor / Foyer Lamp' Off
 
Else
        Set Scene 'Front House Lights' Off
        Set 'Main Floor / Foyer Lamp' Off
 

 

Take a look at this link. It's a primer on ISY programming

https://wiki.universal-devices.com/index.php?title=ISY-99i/ISY-26_INSTEON:Scope,_Precedence_and_Execution_Order

 

 

 

Link to comment

I wouldn't worry about stating if the lights are off. If they are already on it wouldn't matter if you turned them on.

If you turn on the lights manually and don't want the auto off to take place, I would simply write a program that temporarily disables the motion program for the time period you choose

Link to comment
8 hours ago, UD2)17rrh said:

Thanks for looking and replying.  Is it better to always have the time check first in code?

All lines are evaluated every time, then the whole logic is assessed. Trigger lIne order doesn't matter in ISY.

As suggested by lilyoyo1, get rid of the status. It may cause oscillations and doesn't make any difference.

Link to comment
21 hours ago, UD2)17rrh said:

Is it better to always have the time check first in code?

Personally, I don't think the order matters in this case.  Your conditions were joined by "and", so all must be true.  Order should not matter.

I can see some cases, where one is not careful with "or" and parentheses, where order of commands could matter, but not here.

Link to comment
On 8/12/2019 at 11:09 PM, Techman said:

We are confusing order of operations with evaluation order. A quote from that ISY section.

Quote

Evaluation Order

Within the If clause of a program, expressions are evaluated from left-to-right, meaning the individual expressions are evaluated from top to bottom as viewed on the screen. Evaluation does not stop as soon as the outcome is known; rather all expressions within the clause are evaluated each time the If is invoked.

 

Link to comment

Thanks for all the thoughts.  With the sensors I have should I be using the jumpers the control the sensor settings or the software or does it not matter?

So now I have this code and the lights are coming on during the daytime (and only one sensor is triggering them).  What is going wrong?

 

Rear Motions Active

If
        From    Sunset
        To      Sunrise (next day)
    And Control 'Motion Sensors / Rear Deck South Side-Senso' is switched On
     Or Control 'Motion Sensors / Patio-Sensor' is switched On
 
Then
        Set Scene 'Rear Motion Activity' On
        Send Notification to 'Rear Motion Activated'
        Wait  7 minutes
        Set Scene 'Rear Motion Activity' Off
 
Else
        Set Scene 'Rear Motion Activity' Off
 

 

Link to comment
19 minutes ago, UD2)17rrh said:

Thanks for all the thoughts.  With the sensors I have should I be using the jumpers the control the sensor settings or the software or does it not matter?

So now I have this code and the lights are coming on during the daytime (and only one sensor is triggering them).  What is going wrong?

 

Rear Motions Active

If
        From    Sunset
        To      Sunrise (next day)
    And Control 'Motion Sensors / Rear Deck South Side-Senso' is switched On
     Or Control 'Motion Sensors / Patio-Sensor' is switched On
 
Then
        Set Scene 'Rear Motion Activity' On
        Send Notification to 'Rear Motion Activated'
        Wait  7 minutes
        Set Scene 'Rear Motion Activity' Off
 
Else
        Set Scene 'Rear Motion Activity' Off
 

 

How is your scene configured? Is the motion sensor part of the scene? If it is, you should remove it

Link to comment

With the ISY 4.7.3 firmware the ISY does not support any of the sensor configuration settings, You should set the jumpers on the motion sensor accordingly.

The motion sensor II is fully supported in the 5.0.15A ISY firmware and can be configured via the ISY

 

 

Link to comment

No it is not part of the scene.  I read through some documents on ISY and amended my code to that below.  Is this cleaner?

 

Rear Motions Active - [ID 000A][Parent 0001]

If
        From    Sunset
        To      Sunrise (next day)
    And (
             Control 'Motion Sensors / Rear Deck South Side-Senso' is switched On
          Or Control 'Motion Sensors / Patio-Sensor' is switched On
        )
 
Then
        Set Scene 'Rear Motion Activity' On
        Send Notification to 'Rear Motion Activated'
        Wait  7 minutes
        Set Scene 'Rear Motion Activity' Off
 
Else
        Set Scene 'Rear Motion Activity' Off
 

 

Link to comment
1 hour ago, UD2)17rrh said:

No it is not part of the scene.  I read through some documents on ISY and amended my code to that below.  Is this cleaner?

 

Rear Motions Active - [ID 000A][Parent 0001]

If
        From    Sunset
        To      Sunrise (next day)
    And (
             Control 'Motion Sensors / Rear Deck South Side-Senso' is switched On
          Or Control 'Motion Sensors / Patio-Sensor' is switched On
        )
 
Then
        Set Scene 'Rear Motion Activity' On
        Send Notification to 'Rear Motion Activated'
        Wait  7 minutes
        Set Scene 'Rear Motion Activity' Off
 
Else
        Set Scene 'Rear Motion Activity' Off
 

 

much better.

One thing that I do (doesn't have to be done) is separate my off from my motion programs. This allows me to have different programs for different situations without walking all over other programs that involve the same devices.

 

Link to comment

So now I am confused.  Why does this program turn off my outdoor lights at 8:50 pm?  By the way, at this time $Int_1 is 0 and the garage light is already on.

Run Program 'Garage Lights On' (Then Path) should not run but I think it must be.  Thanks.

 

Driveway Motion Active

If
        (
             $Int_1 is 1
         And From    Sunset
             To      Sunrise (next day)
         And Control 'Motion Sensors / Driveway Motion Sensor-Sensor' is switched On
        )
 
Then
        Run Program 'Garage Lights On' (Then Path)
 
Else
   - No Actions - (To add one, press 'Action')
 

Garage Lights On

If
   - No Conditions - (To add one, press 'Schedule' or 'Condition')
 
Then
        Set 'Outside / House Front (load)' On
        Wait  20 minutes
        Set 'Outside / House Front (load)' Off
 
Else
   - No Actions - (To add one, press 'Action')
 
Program to be used for various reasons.

 

Link to comment

....also this program is also running during the day time: actually, only one of these motions though calls the program "Rear Lights On".  Again at this time $Int_1 is 0 and it is daylight.  Thanks.

Rear Motions Active

If
        (
             $Int_1 is 1
         And From    Sunset
             To      Sunrise (next day)
         And Control 'Motion Sensors / Rear Deck South Side-Senso' is switched On
          Or Control 'Motion Sensors / Patio-Sensor' is switched On
          Or Control 'Motion Sensors / West Gate Motion Sensor-Senso' is switched On
        )
 
Then
        Run Program 'Rear Lights On' (Then Path)
 
Else
   - No Actions - (To add one, press 'Action')
 

 

Link to comment
1 hour ago, UD2)17rrh said:

Why does this program turn off my outdoor lights at 8:50 pm? 

Well, I would have to assume that something triggered your program "garage lights on" (then path) at 8:30.  Twenty minutes later, the lights would turn off, as programmed.  Given your first program, the only way (from the programs you have shown) that this could happen is that , at 8:30pm, $int_1=1, sunset has already occurred, and someone must have triggered the driveway sensor.  The value of $int_1 at 8:50 is irrelevant.  

 

1 hour ago, UD2)17rrh said:

also this program is also running during the day time: actually, only one of these motions though calls the program "Rear Lights On"

You likely have a misplaced parentheses.  Why do you bracket the entire condition in parentheses?  Given the way it is currently written, "rear motions active" will be true any time that "patio" or "west gate" sensors are triggered, regardless of the state of the variable, sunset or sunrise, or how much daylight there is.

Link to comment
29 minutes ago, oberkc said:

You likely have a misplaced parentheses.  Why do you bracket the entire condition in parentheses?  Given the way it is currently written, "rear motions active" will be true any time that "patio" or "west gate" sensors are triggered, regardless of the state of the variable, sunset or sunrise, or how much daylight there is.

I don't think I get this then.  The way I structured both of these codes around the use of  parentheses, in the second code for example, for the lights to come on shouldn't $Int_1 have to equal 1 AND also be after sunset AND a sensor to trigger?  ie all three conditions must be met before the light comes on?

Link to comment

If
        (                                     <----------- doesn't serve any function to bracket all lines
             $Int_1 is 1
         And From    Sunset      <--------can only be true during the timeframe From/To
             To      Sunrise (next day)
         And Control 'Motion Sensors / Rear Deck South Side-Senso' is switched On       <------ top three logic conditions all have to True due to the ANDs
          Or Control 'Motion Sensors / Patio-Sensor' is switched On                                    <-------Or has a lower precedence and this line is only ORed with te line above and below
          Or Control 'Motion Sensors / West Gate Motion Sensor-Senso' is switched On  <-------Or has lower precedence and this line is included n the OR only
        )
 
Then
        Run Program 'Rear Lights On' (Then Path)
 
Else
   - No Actions - (To add one, press 'Action')

 

I assume you wanted this

If
                 $Int_1 is 1                                    <--------------------master control will enable/disable all triggers. Integer variables cannot initiate programs though.
         And From    Sunset   
                     To      Sunrise (next day)       <---------------------watch out for this one. It will cancel Then running, and run Else
         And (
                   
Control 'Motion Sensors / Rear Deck South Side-Senso' is switched On
     
         Or Control 'Motion Sensors / Patio-Sensor' is switched On 
              
Or Control 'Motion Sensors / West Gate Motion Sensor-Senso' is switched On 

                  )
 

Link to comment
7 hours ago, UD2)17rrh said:

The way I structured both of these codes around the use of  parentheses,

Yes, you used parentheses around BOTH.  The difference is that the first program has no "or" conditions.

7 hours ago, UD2)17rrh said:

I don't think I get this then. 

Consider the following logical statement:

"I will go to bed when I get home and lock the doors or when I get to a hotel".  What conditions must be met in order for this to be true (to go to bed)?  Either: 1) go home and lock the doors, or 2) get to a hotel.  If "go home" is condition A, "locking the doors" is condition B, and "finding a hotel" is condition C, this would be written as:

A and B or C.

Do you remember math from elementary school?  The results of 3x2+4 are different than 3x(2+4), right?  The same is true in logic...A and B or C has different results than A and (B or C). 

8 hours ago, UD2)17rrh said:

in the second code for example, for the lights to come on shouldn't $Int_1 have to equal 1 AND also be after sunset AND a sensor to trigger?

This is mostly true.  For the second code to be true, either 1) $Int_1 must equal 1 and it must be between sunset and sunrise and side sensor is switched on or 2) patio sensor is switched on or 3) west gate sensor is switched on

I have little doubt that Larryllix has found your solution

Link to comment

Why are you adding extra complexity to this unnecessarily? Prior to starting, you really should think through the hows and whys of your actions. Look at HOW your family interacts with your lights.

This will help you figure out your next steps. For example. Why does the status of the light being on matter in the grand scheme of things. If it matters, how is it turned on ? IE: does someone manually turn it on or is it turned on/off based on a timer?

Personally I would break this down into multiple programs. Separate the on and off programs. With you trying to status the light and 2 separate sensors that do not talk to each other, you're wasting your time with a single program. 

My off program would look something like

If:

status of Light is on

And status motion 1 is off

And status motion 2 is off

And

(Control motion 1 is not switched on

Or control motion 2 is not switched on)

Then:

Wait 15 minutes set light off.

This doesn't need a time frame since it simply turns off the light (which you don't want on during the day anyway). Both sensors have to be showing off and not turned on via movement in order for the lights to turn off. Someone activates the sensors the program restarts. You can configure your sensors the way you want in regards to when the off is issued. I generally will do a few minutes just so it doesn't immediately flip to off but that's personal preference. 

If you're manually turning on your lights, you can then override the motion sensor off program. Generally when I do this, I automatically re-enable my programs. This would look something like:

If control switch A is turned on and control switch A is not turned off

Stop motion program

Deactivate motion off program

Wait 3 hrs

Enable motion off program

Or else:

Enable motion off

This will stop your motion off program for 3 hrs if it's already running and automatically re-enable it later. If you manually turn off the light, it will enable the program immediately. 

With both of those out the way, turning on your lights is simply a matter of your lifestyle. The hows and whys that you want the lights on

 

Link to comment

Archived

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


×
×
  • Create New...