Jump to content

Parentheses and line placement trouble


TJF1960

Recommended Posts

I have this one program which has been working fine for months. I added a sensor which then required the program to change slightly. The change included adding the additional sensor and another set of parentheses.

 

These 3 programs are all the same the only difference is the placement of “And $sAlarmSys_Z31_LaudryRm_Door is 0†in the program. Also, all of the status of all the sensors and devices were such that the program should have been FALSE. But depending on the placement of the above referenced And statement some of these programs turned true!

 

This is the original program which worked fine and its current state is False per admin console:

 

If
       Program 'WH Fan Sw Status' is False
   And-(
      |     Status  'Devices / WH Fan LR' is On
      |  Or Status  'Devices / WH Fan LR Hi/Low' is On
      -)
   And-(
      |     $sAlarmSys_Z05_SlidingDoor is 1
      |  Or $sAlarmSys_Z08_KitchenWindow is 1
      |  Or $sAlarmSys_Z06_MasterWindow is 1
      -)
   And $sAlarmSys_Z31_LaudryRm_Door is 0
   And-(
      |     $sAlarmSys_Z09_LRtoWR_Door is 0
      |  Or $sAlarmSys_Z11_WRtoBack_Door is 0
      -)

Then
       Set Scene 'Scenes / Whole House Fan's / WH Fan LR' Off

Else
  - No Actions - (To add one, press 'Action')

 

This is the same program after the minor changes. It should still be False but the admin console reports it as True:

 

If
       Program 'WH Fan Sw Status' is False
   And-(
      |     Status  'Devices / WH Fan LR' is On
      |  Or Status  'Devices / WH Fan LR Hi/Low' is On
      -)
   And-(
      |     $sAlarmSys_Z05_SlidingDoor is 1
      |  Or $sAlarmSys_Z08_KitchenWindow is 1
      |  Or-(
      |    |     $sAlarmSys_Z06_MasterWindow is 1
      |    | And $sAlarmSys_Z26_MasterBed_Door is 1
      |    -)
      -)
   And $sAlarmSys_Z31_LaudryRm_Door is 0
   And-(
      |     $sAlarmSys_Z09_LRtoWR_Door is 0
      |  Or $sAlarmSys_Z11_WRtoBack_Door is 0
      -)

Then
       Set Scene 'Scenes / Whole House Fan's / WH Fan LR' Off

Else
  - No Actions - (To add one, press 'Action')

 

After quite a bit of time I finally found that if I moved the above referenced line up in the program that the program would finally evaluate False as it should:

 

If
       Program 'WH Fan Sw Status' is False
   And-(
      |     Status  'Devices / WH Fan LR' is On
      |  Or Status  'Devices / WH Fan LR Hi/Low' is On
      -)
   And $sAlarmSys_Z31_LaudryRm_Door is 0
   And-(
      |     $sAlarmSys_Z05_SlidingDoor is 1
      |  Or $sAlarmSys_Z08_KitchenWindow is 1
      |  Or-(
      |    |     $sAlarmSys_Z06_MasterWindow is 1
      |    | And $sAlarmSys_Z26_MasterBed_Door is 1
      |    -)
      -)
   And-(
      |     $sAlarmSys_Z09_LRtoWR_Door is 0
      |  Or $sAlarmSys_Z11_WRtoBack_Door is 0
      -)

Then
       Set Scene 'Scenes / Whole House Fan's / WH Fan LR' Off

Else
  - No Actions - (To add one, press 'Action')

 

In a nutshell, on my system anyway, it seems that the single And statement placed right after a double set of parentheses gets ignored allowing the program to evaluate true. I even created a new program adding all of the same components in the same order and produced the same results (I was thinking maybe some sort of glitch in the original program).

 

Anyway, this last program works as it should now but I was just curious as to why placement of this one line changes the evaluation like it does?

 

Thanks,

Tim

Link to comment
These 3 programs are all the same the only difference is the placement of “And $sAlarmSys_Z31_LaudryRm_Door is 0†in the program.

 

I am not following this statement. It appears that there are also differences regarding the placement and inclusion of "$sAlarmSys_Z26_MasterBed_Door" (first program does not include). I think you have more things going on here than just the placement of "$sAlarmSys_Z31_LaudryRm_Door".

 

Which was the newly added sensor?

 

Also, all of the status of all the sensors and devices were such that the program should have been FALSE.

I am curious as to what combinations of device true/false that are yielding program results different than what you are expecting?

 

I tend to agree, however, that the second an third programs should behave equally.

Link to comment

The first program was the original, before the addition of a sensor. I included this program in the post to show its placement of "And $sAlarmSys_Z31_LaudryRm_Door is 0†(which is the line having trouble with) in reference to the other sensors.

 

The 2nd program was modified from the first to include "$sAlarmSys_Z26_MasterBed_Door is 1" which is the new sensor. Because of the application both "$sAlarmSys_Z26_MasterBed_Door" and "$sAlarmSys_Z06_MasterWindow" were required to be "And" then "Or" as a pair with the other sensors. Hence the inclusion of the OR Parentheses around the two. The parentheses addition and the sensor addition are the only two differences between program 1 and 2.

 

Basically this program is one of a number of programs used to control our whole house fans based on different conditions including temp and door/windows open/closed. Door and window sensors control variables. Variables which = 1 are open, 0 = closed.

 

This particular program is looking for at least one of the first two variables to be closed or the combination of variable 3 and 4 to be closed then it is looking for the 5th variable to be open then finally either the 6th or 7th variable to be open. Once those conditions are met the program evaluates true.

 

The problem I was having and am trying to understand why is the placement of "And $sAlarmSys_Z31_LaudryRm_Door is 0" in programs 2 and 3 is making a difference.

 

Program 2 evaluates true in the admin. console, when it shouldn't based on the current conditions. Then simply moving "And $sAlarmSys_Z31_LaudryRm_Door is 0" up in order as depicted in program three, then saving the program, the admin console shows the program as False, which is, as it should based on the conditions.

 

Thanks,

Tim

Link to comment
Program 2 evaluates true in the admin. console, when it shouldn't based on the current conditions.

 

I will have to take your word on that, since I dont know the current conditions.

 

The problem I was having and am trying to understand why is the placement of "And $sAlarmSys_Z31_LaudryRm_Door is 0" in programs 2 and 3 is making a difference.

 

But I agree with you...I don't believe placement of this condition should make any difference to the total condition status results. It sounds as if your understanding and mine are the same.

 

I wonder, however, if the problem is not the evaluation results, but whether or not the program condition is evaluated. Have you always forced an evaluation, by manually choosing "run if"? Is it possible that the condition would evaluate as you and I both expect, but that there is, simply, nothing triggering an evaluation?

 

Another thing that I notice is that your "then" or "else" statement change one or more of your input conditions. Is it possible that running the program causes a change in the conditions which change the status? As an experiment to test this hypothosis, you could temporarily remove the "then" and "else" statements and see if this changes anything.

Link to comment
Program 2 evaluates true in the admin. console, when it shouldn't based on the current conditions.

 

I will have to take your word on that, since I dont know the current conditions.

Well, this is what happened. I made the changes listed above to this program yesterday. This morning when I turned the whole house fan on it turned back off. I went thru the code line by line and got to the line in question (And $sAlarmSys_Z31_LaudryRm_Door is 0). I checked the door that variable is controlled by and it was open, the admin console reported the variable as “1†which is correct. But in order for this program to be true this line needs to be 0!

So I did some fooling around with the program, even re-creating a new program. No matter what I did the program continued to evaluate as true. Until I moved that line in question to above the other variables in parentheses, then the program worked as intended.

 

I wonder, however, if the problem is not the evaluation results, but whether or not the program condition is evaluated. Have you always forced an evaluation, by manually choosing "run if"? Is it possible that the condition would evaluate as you and I both expect, but that there is, simply, nothing triggering an evaluation?

Very good points. Although no, I haven’t had to force the evaluation. In fact once I moved the line in question up and saved the program the console reported the program as false. I then moved the line back into its original place (as in program 2), saved the program and the console reported the program as true again. I did this a couple of times just to make sure I wasn’t crazy. Each time I moved the line and saved the program the console reported the opposite state. And, just to be clear that line movement was the only change to the program made between saving and checking program status. And the conditions all stayed the exact same between tests.

 

Another thing that I notice is that your "then" or "else" statement change one or more of your input conditions. Is it possible that running the program causes a change in the conditions which change the status? As an experiment to test this hypothosis, you could temporarily remove the "then" and "else" statements and see if this changes anything.

Another good point. As you suggested I removed the action part of the program, then moved the problem line in question down to where it was in program 2, saved and checked the status which had changed from false to true. So the action doesn’t seem to affect this problem.

 

I am bewildered! There has got to be a simple explanation but I don’t know what it is.

 

Thanks,

Tim

Link to comment

Thanks Tim,

 

I managed to recreate the problem and it looks like you actually discovered a bug that has been hidden in the code for quite awhile. The problem occurs if you have more than one close parentheses in a row with no condition between them. I have a tentative fix that will likely be in the next build.

 

Until then, the temporary work-around is to ensure you have a condition between any two closing parentheses.

 

For example, you could change your program from this:

...
   And-(
      |     $sAlarmSys_Z05_SlidingDoor is 1
      |  Or $sAlarmSys_Z08_KitchenWindow is 1
      |  Or-(
      |    |     $sAlarmSys_Z06_MasterWindow is 1
      |    | And $sAlarmSys_Z26_MasterBed_Door is 1
      |    -)
      -)
...

To this:

...
   And-(
      |     $sAlarmSys_Z05_SlidingDoor is 1
      |  Or-(
      |    |     $sAlarmSys_Z06_MasterWindow is 1
      |    | And $sAlarmSys_Z26_MasterBed_Door is 1
      |    -)
      |  Or $sAlarmSys_Z08_KitchenWindow is 1
      -)
...

Link to comment

Archived

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


×
×
  • Create New...