Jump to content

ISY programming challenge


Michaelco

Recommended Posts

Posted

I have a program that turns on path lighting, for a little over 10 minutes, if it is nighttime and a vehicle has driven onto the driveway.  I am not currently using scenes, but will in the final.  This is the first ISY program I've written which makes use of a Wait command, so I may be missing understanding on how it works.  

 

In general, what I'm trying to do is straight forward, but the programs for managing the path lighting are a bit more complex than the other programs I've written.  I am using variable called int_PrcsdSafetyLoops which is to limit execution of the code that turns the lights on to one time - even if there are multiple triggers each time a vehicle drives down the driveway.  I also have some sidewalk lights which are scheduled to come on each night for 4 hours (after sunset), which should ignore the command to turn off when someone drives down the driveway and it's still within the 4 hour scheduled time period. 

 

Reason for int_PrcsdSafetyLoops var:

There actually are two safety loops, and right now I have taken both their contact outputs and wired them to the I/O Linc module.  So, if I drive the car out of the driveway and back during my testing, I will get 4 closures of the I/O Linc.  The goal is to trigger off the first contact closure and ignore the remaining 3.  At some point, I may add direction info, so the lights only come on when we arrive at the property, but I may not worry about that issue.  The wiring will be changed so it only takes input from the Outside Safety loop, but this will involve more time than I had between rain storms. Plus, I should be able to write code that only looks at the first occurrence - I'm guessing it's something simple, but for the life of me, I can't see why it won't ignore.

 

The lights turn on fine, but the lights fail to turn off, and the flag int_PrcsdSafetyLoops never changes from the value 0.  int_TestVar3 increments by a count of 4 each time I drive over the two loops going out the driveway, and back over the loops coming back on the property.

int_TestVar also increments by a count of 4, which I believe happens when I drive past the loops - going from a contact closure state to an open state.

 

Int_TestVar2, Int_TestVar4 and Int_TempPathLightsOn never changes, which could be confirmation the code after the WAIT command never executes.

 

Any ideas on where I'm going astray?  Is there a log that displays not only the events, but also lists variable change of state?

 

Michale

================== main code pieces ==============

Program TempPathLightsOn

If
        $sIsDark is 1
    And Status  'Gate Outside Safety Loop Sens' is On
    And $int_PrcsdSafetyLoops is 0
 
Then
        $int_PrcsdSafetyLoops  = 1
        Set 'Garage Outside West' On
        Set 'Garage Outside North' On
        Set 'Out Mod A' On
        $Int_TestVar3 += 1
        Wait  10 minutes and 15 seconds
        $Int_TempPathLightsOn  = 1
        Run Program 'Temp Path Lights Off' (If)
        $Int_TestVar2 += 1
 
Else
        $int_TestVar += 1
 
Comments: 
Mod A controls the sidewalk lights.  They can be turned on anytme (while dark), but they won't be turned off if the time is during their normal "On" time period (as controlled by sLightPathOnVar.
Var int_PrcsdSafetyLoops is to protect against multiple triggers from the two safety loops.  The "Then" section should only execute once when a vehicle drives accross the safety loops, turn on the desired lights,
and turn the lights back off after the wait period has timed out.  Then reset the vars.
 
 
Program TempPathLightsOff
 
If
        $Int_TempPathLightsOn is 1
 
Then
        Set 'Garage Outside West' Off
        Set 'Garage Outside North' Off
        Run Program 'Sidewalk Lights Temp Off' (If)
        $int_PrcsdSafetyLoops  = 0
        $Int_TempPathLightsOn  = 0
        $Int_TestVar4 += 1
 
Else
   - No Actions - (To add one, press 'Action')
 
Comments:
Mod A controls the sidewalk lights.  They can be turned on anytme (while dark), but they won't be turned off if the time is during their normal "On" time period (as controlled by sLightPathOnVar)
 
Posted (edited)

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. 

Edited by LeeG
Posted

I have not taken the time to fully understand you different variables and devices. One thing, however, jumps out at me. The program condition:

 

" Status  'Gate Outside Safety Loop Sens' is On"

 

Why are you using STATUS rather than CONTROL?

Posted

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. 

That's consistent with what I would have thought.  
In further checking, I see the PrcsdSafetyLoops flag does change to 1, but is reset very quickly.
In one test it reset 1 minute after it had been set, and in a second test it reset after 37 seconds.  Needed to have my laptop with me in the car to see it, as the "action” was over by the time I got into the house, so missed seeing the var change state.  Glad the wifi reached the end of the driveway.
 
The interesting thing, to me, is int_PrcsdSafetyLoops is only set two places - it’s set to a 1 in the “Then” section of TempPathLightsOn and is reset to 0 in TempPathLightsOff.  Running of TempPathLightsOff should have been delayed 10 minutes and 15 seconds by the " Wait  10 minutes and 15 seconds” line of code. 
Another interesting thing, is if TempPathLightsOff is executed (resetting the int_PrcsdSafetyLoops, why weren’t the other lines of code executed - like turning off the lights, and Int_TestVar4, etc.
Posted

I have not taken the time to fully understand you different variables and devices. One thing, however, jumps out at me. The program condition:

 

" Status  'Gate Outside Safety Loop Sens' is On"

 

Why are you using STATUS rather than CONTROL?

 

I'm looking for a relay contact closure  (which is connected to the  I/O Linc sensor input).  I'm new to ISY and Insteon, but thought if I'm monitoring the sensor side of the I/O Linc module, I should look at the Status.  Is this not the case? 

 

When I view the logs, I can see the Status does change when I drive over the safety loops, and the "Then" section of code in TempPathLightsOn executes.  However, It appears the code after the "Wait 10 minutes and 15 seconds" fails to execute.  

 

The line of code ($Int_TestVar3 += 1) which precedes the Wait command executes, but a similar line of code ($Int_TestVar2 += 1) which is after the Wait command fails to change.

When I look at the variables when I select the program tab in Admin I see the "last change" to $Int_TestVar2 was Nov 30th, which was the date when I created the var - the value hasn't been altered in the dozen times I've run my tests.

 

I would have thought the code prior to the wait command would have executed, and after 10 minutes and 15 seconds specified by the Wait command, the ISY would continue with the next line of code - e.g., $Int_TempPathLightsOn  = 1

 

I have little doubt I'm doing something that the ISY doesn't like, but have no idea what it is.  I will play around with a new program that does little more than increment a var before a wait command and increments a second var after the wait command.   And, view the "last changed" column to see if both increments occur.

 

 

Posted

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 wrote the following, and it worked as I would have expected:

============= Test code ==============

If

        Control 'Living Room Lamplink' is switched On

Then
        $Int_TestVar7 += 1
        Wait  15 seconds
        $Int_TestVar8 += 1
Else
   - No Actions - (To add one, press 'Action')
===================================

I went back to my TempPathLightsOn program and changed the line of code (Wait command) - changed both the minute and second spinner values it to 0 minutes and 16 seconds respectively.

Looks like the problem with the wait command was some sort of corruption, as executing the "Then" worked as I would have expected.  I then changed back to 10 minutes and 15 seconds, and reran the "Then" section - worked fine.

 

A bit frustrating to have this happen the first time using the Wait command, as I would not have expected a problem with a line of code created by selecting drop downs and spinners.

 

Thanks for your confirmation on how the Wait should work - I should have created the little test program, when I first hit the problem

 
Posted

Hi Michaelco,

 

Please note that you can always contact our tech support team with your questions (links below).

 

With kind regards,

Michel

Thanks for the reminder - thought this was a newbie related issue well suited for the forums. I think I know how the issue was created. The Admin console doesn't appear to work well when saving without first exiting a field which has been modified. It has been slowly "training" me to exit the fields I have been editing prior to saving, but I'm slow to train
Posted

I'm looking for a relay contact closure  (which is connected to the  I/O Linc sensor input).  I'm new to ISY and Insteon, but thought if I'm monitoring the sensor side of the I/O Linc module, I should look at the Status.  Is this not the case? 

Not necessarily. I would try control. Hopefully, the fix is this simple.

 

(I note your test program uses control.)

Posted

Michaelco

 

Would you provide the exact interaction that Save did not pick up.

There were a couple areas where I have needed to quit ISY to continue working.  One area is when saving a newly created program, which is fairly repeatable.  I'm not as clear on the sequence which requires a "Admin restart" for the second area - which is, creating a new variable.  In both cases, I don't believe it's limited to creating a new program or variable, and most likely applies to editing an existing program or var.

 

Sequence for first issue:

  • Create "New Program", add Condition code (IF), and Action (THEN), edit New Program name, and Save without leaving the New Program text box.  Get the Save Programs dialog, but the dialog doesn't release and stays visible (and empty - without thermometer).  Have to quit the ISY to continue - there may be some kinder way to recover, but I haven't found it.
  • Add "New variable", set Init, and Value, and edit the variable name.  Save without leaving the variable Name text box.  This will, at a minimum, fail to allow me to switch to Details tab without first changing focus to another field on the variable window.  Sometimes, need to quit ISY Admin to continue.
Posted

What Browser is being used when incomplete activity is being Saved?

Not accessing the admin console via a browser - I'm using the ISY994 Administrative Console java app

Posted

Perhaps accessing the admin console from a browser would avoid the problems. My use of the dashboard has been limited to device and scene control. I have never experienced your problems using the browser method.

Guest
This topic is now closed to further replies.

  • Recently Browsing

    • No registered users viewing this page.
  • Forum Statistics

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