Jump to content

Using the Wait command.


Michaelco

Recommended Posts

I thought I understood the nuances of using the Wait command, but apparently I don't.  I noticed a couple weeks ago, something that had been working correctly for well over a month no longer did.

 
The program that no longer works correctly was to detect if a vehicle parked for more than 20 seconds in an area outside our gate.  If so, a counter (intTotStoppedAtGate) would be incremented.  Another program automatically opens the gate when my phone comes within range of my home, but only if the intTotStoppedAtGate is zero - The ISY will send a text notification to my phone letting me know of possible deliveries if intTotStoppedAtGate is greater than zero.  The reason I want to inhibit the gate from automatically opening is companies like Fedex and UPS will leave the packages on the inside of the gate where the potential for damage could occur when the gate opens.  
 
Not sure how they get packages over the gate, but I’m sure they are gently placed on the driveway :~}.
 
I’m using an Insteon I/O module (model 2450) to relay a signal to the ISY when the sensor (inductive loops) in the road detects a vehicle.
 
In order to try to understand what’s going on, I simplified the way I was detecting the parked vehicle -so this is not the code that had been working for months, however I can’t see why the intTotStoppedAtGate counter is incremented when I am only driving over the sensors for a period of 3 seconds.
 
My understanding, is the code following the Wait command won't execute if the condition ( Control 'Gate Outside Safety Loop Sens' is switched On) is no longer true when the Wait period is over.  This baffles me as the Loop Sens is only on for 3 seconds, and the Wait period is set for 20 seconds.
 
Any insights on this would be appreciated.
 
========= Here is the code I am using ===========
 
If
        Control 'Gate Outside Safety Loop Sens' is switched On
 
Then
        Wait  20 seconds
        $intTotStoppedAtGate += 1
        Send Notification to 'TextMichael' content 'Someone At the Gate'
        Run Program 'FlashLight' (If)
 
Else
   - No Actions - (To add one, press 'Action')
 
==========================================
 
Here is the section of the log which shows the sensor detecting the car as  I drove down the driveway.  Yet, the intTotStoppedAtGate counter was incremented.
Gate Outside Safety Loop Sens   Status   100%    Sat 2015/03/07 04:33:18 PM   System  Log
Gate Outside Safety Loop Sens   Status    0%       Sat 2015/03/07 04:33:21 PM   System  Log
 

 

Link to comment

If the sensor switch is turned On, however briefly, then the program will wait 20 seconds and increment the counter. A solution is to wait 20 seconds, then run a second program that tests for the status of the sensor and increments the variable counter.

Link to comment

If the sensor switch is turned On, however briefly, then the program will wait 20 seconds and increment the counter. A solution is to wait 20 seconds, then run a second program that tests for the status of the sensor and increments the variable counter.

Are you sure?  

==== LeeG posted the following when I posted having problems with code not executing after the Wait command (back in early December) =====

When a Wait or Repeat statement is executed the If clause can run again when any of the trigger conditions change.   For the statements after the Wait not to execute it means a trigger condition changed while inthe Wait causing the If to execute again with a False result causing the Else clause to execute. 

=======================================

 

 

I also got confirmation from UDI support that the ISY re-evaluates the conditional (the “IF”) of the program, and if it has changed during the Wait period, the “Then” code won’t continue executing from the line of code following the Wait.

 

This seemed to be the case prior to a couple of weeks ago - not sure what changed, but the behavior is different.

Link to comment

Michaelco

 

What was not mentioned in this situation is that the If condition has not changed.  An "If Control ..... is switched On" has no negative/False side.  The Sensor turning Off does not affect the "If Control is switched On".  You mentioned the posted example is not what was the running code but a simplified version.  I suspect that was running version has more in the If than what has been posted.

 

Suggest posting the real If as i think you have created an If with different conditions.

 

EDIT:  the only way to stop the posted Wait from completing with the if Control is to have it turn On again before the Wait completes. 

Link to comment

Michaelco

 

What was not mentioned in this situation is that the If condition has not changed.  An "If Control ..... is switched On" has no negative/False side.  The Sensor turning Off does not affect the "If Control is switched On".  You mentioned the posted example is not what was the running code but a simplified version.  I suspect that was running version has more in the If than what has been posted.

 

Suggest posting the real If as i think you have created an If with different conditions.

 

EDIT:  the only way to stop the posted Wait from completing with the if Control is to have it turn On again before the Wait completes. 

 

So, if I had used "Status  'Gate Outside Safety Loop Sens' is On" instead, it would create a change of state on both the "driving over the sensor" and "driving off the sensor"?

Would it be accurate to say the code after the Wait command would not execute, if the "driving off the sensor" occurred prior to the Wait period completing?

 

 

Thanks for all of the responses - the subtleties are not always in the forefront of my mind...

Link to comment

Archived

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


×
×
  • Create New...