Jump to content

Why does this code not work?


UD2)17rrh
Go to solution Solved by Goose66,

Recommended Posts

Posted

I think I have it correct.  The Wireless Tag motion senses motion and the light turns on.  All good to this point.  But the light does not turn off.  Why is the code wrong?   Thanks for the advice.

 

Utility Room Motion 

If
        'Wireless Tags / Utility Room Sensor' Event State is Detected Movement
 
Then
        Set 'Basement / Utility Room' On
        Wait  15 minutes 
        Set 'Basement / Utility Room' Off
 
Else
   - No Actions - (To add one, press 'Action')
 

 

Posted

If the tag turns off before 15 minutes, the program stops running.. is likely the cause.

Try putting the actions in a separate program, and change the 'then' of the current program to run the new program. The new program should have no 'if' statement

  • Like 1
Posted

Here's a more elegant one program version that came up on my drive back home from family Christmas

If
  'Wireless Tags / Utility Room Sensor' Event State is Detected Movement
Then
  Set 'Basement / Utility Room' On
Else
 Wait 15 minutes
 Set 'Basement / Utility Room' Off

Posted (edited)
On 12/26/2023 at 4:17 PM, paulbates said:

Here's a more elegant one program version that came up on my drive back home from family Christmas

If
  'Wireless Tags / Utility Room Sensor' Event State is Detected Movement
Then
  Set 'Basement / Utility Room' On
Else
 Wait 15 minutes
 Set 'Basement / Utility Room' Off

Thanks for the thoughts.  I will give the latter idea a try.  Does it matter at all if the tag continually senses motion and keeps sending an on signal to the switch?  Would use of a variable program help here?

Edited by UD2)17rrh
  • Solution
Posted (edited)

Cleanest solution here (and just about all other instances with motion/presence triggering events and timed activities) is the two program solution:

First program: Utility Room Motion (Enabled) 

If
        'Wireless Tags / Utility Room Sensor' Event State is Detected Movement
Then
        Run Program 'Utility Room Lights on Motion' (Then Path)
Else
   - No Actions - (To add one, press 'Action')

Second program: Utility Room Lights on Motion (Disabled)

If
   - No Conditions - 
Then
        Set 'Basement / Utility Room' On
        Wait  15 minutes 
        Set 'Basement / Utility Room' Off
Else
   - No Actions - (To add one, press 'Action')

When the Wireless tag sends movement, the first program starts the second program, and the second program turns on the lights, starts the timer, and turns off the lights when the timer expires. Subsequent motion from the Wireless tag turns the lights on again and resets the timer. 15 minutes after the last motion detected, the lights turn off.

An advantage to this structure is that it works whether or not your Wireless Tag (or other motion detector) sends a DOF (No Motion) command after some delay.

Edited by Goose66
  • Like 3
Posted (edited)
On 12/26/2023 at 1:07 PM, paulbates said:

If the tag turns off before 15 minutes, the program stops running.. is likely the cause.

To further explain this, read this wiki. https://wiki.universal-devices.com/ISY-99i/ISY-26_INSTEON:Scope,_Precedence_and_Execution_Order#Statement_Execution_Order

Whenever a WAIT is encountered, the IF is re-evaluated. In your program case, the if then becomes false so the program runs the else and never gets to the last command. 

@Goose66 is indeed the cleanest and most strait-forward approach and one I use all the time. 

Edited by dbwarner5
fixed error.. "encountered replaced completed
  • Like 1
Posted
8 hours ago, Goose66 said:

Cleanest solution here (and just about all other instances with motion/presence triggering events and timed activities) is the two program solution

Thank-you!

Posted
8 hours ago, dbwarner5 said:

To further explain this, read this wiki. https://wiki.universal-devices.com/ISY-99i/ISY-26_INSTEON:Scope,_Precedence_and_Execution_Order#Statement_Execution_Order

Whenever a WAIT is encountered, the IF is re-evaluated. In your program case, the if then becomes false so the program runs the else and never gets to the last command. 

@Goose66 is indeed the cleanest and most strait-forward approach and one I use all the time. 

Thank-you and bookmarked the how-to guide.  Thanks for sending.  

Guest
This topic is now closed to further replies.

×
×
  • Create New...