Jump to content

Testing both "on" and "not off"


Smile4yourself

Recommended Posts

Posted

Ref

 

If

Control 'Main Bath Motion.1-Sensor' is switched On

And Control 'Main Bath Motion.1-Sensor' is not switched Off

 

Then

Set 'Main Bath Lights' On

 

Else

Set 'Main Bath Lights' Off

 

 

http://wiki.universal-devices.com/index ... _Bathrooms

 

In the example program, is there a benefit for testing for each of these?

 

I understand that if we use an If statement in the ISY, we are asking it to watch for a certain command from the Insteon PLM.

 

If we watch the event viewer, we can see what commands are being received from the PLM from the motion sensor.

 

In my case, I get a "DOn 1" (device on) followed by a "st 255" (status).

 

I think that if the if statement begins "if control" the Isy looks for the "DON" command. If the if statment begins "if status" the ISY looks for the status command.

 

Maybe someone close to the design of the ISY could comment and clarify my understanding, and if the test for opposites in the example is in fact redundant.

 

Thanks for all your help.

Posted

The reason for testing both is so that you can drive both the Then and Else sections following the if. If you test for Control is Switched On only, then the program is triggered only when the control is switched on, evaluated as true and the then runs. When the control is switched off, the program is NOT triggered because there is nothing looking for control Off in the if section.

 

In short, the posted program has 2 triggers, Control On and Control Off. The evaluation of false for the control Off is handled by the NOT. When the Off control event is received, the program triggers and the Control is NOT switched Off evaluates to False since it WAS switched Off driving the Else section.

 

Clear as mud ?

 

-Xathros

Posted

"If the if statment begins "if status" the ISY looks for the status command."

 

The explanation by Xathros is spot on as usual for the If Control.

 

If Status is not looking for a Status command. If Status is checking the value that is displayed in the Current State column which is the Status of the device as the ISY knows it. If Status triggers the Program each time the Current State value changes (unlike If Control which triggers only on the specific command) which means an If Status will run the Then clause when the IF is True and the Else clause when the IF is False. Again, the Current State value must change for If Status to trigger the Program.

Posted

To the previous explanations, allow me to offer an additional, if subtle, difference.

 

A CONTROL statement will only be recieved when the device is activated locally. For example:

 

if control switchlinc is switched on

 

This will trigger only when someone walks up to the switchlinc and presses the button.

 

Another difference in a CONTROL ON statement is that it will trigger upon each reciept of an ON statement, regardless of whether it is, currently, on or off.

 

Compare this to a STATUS. A status will trigger upon a change in status, regardless of what caused the change. So if a switchlinc is changed not by direct action, but in response to a scene command from another device, it will trigger (unlike a CONTROL). Furthermore, if a device is already on, and someone presses the on button, a STATUS will not trigger (unlike a CONTROL).

Posted
The reason for testing both is so that you can drive both the Then and Else sections following the if. If you test for Control is Switched On only, then the program is triggered only when the control is switched on, evaluated as true and the then runs. When the control is switched off, the program is NOT triggered because there is nothing looking for control Off in the if section.

 

In short, the posted program has 2 triggers, Control On and Control Off. The evaluation of false for the control Off is handled by the NOT. When the Off control event is received, the program triggers and the Control is NOT switched Off evaluates to False since it WAS switched Off driving the Else section.

 

Clear as mud ?

 

-Xathros

 

Thanks for your thought provoking response. In the example, the test uses an AND rather than an OR.

 

Doesn't the ISY use "logical AND" ie BOTH tests must be true for the THEN to run?

If both statements are tested at the same time, when the first one is TRUE the second one will also be true, as it is a double negative.

 

Thanks for your help

Posted
Doesn't the ISY use "logical AND" ie BOTH tests must be true for the THEN to run?

If both statements are tested at the same time, when the first one is TRUE the second one will also be true, as it is a double negative.

 

Yes, both must be true. Yes, if first one is true, second one will be true. However, purpose of the second condition is to look for OFF commands (not ON). This is the condition that drives the ELSE path. Without the second condition, this program would never trigger FALSE.

Posted

When checking for multiple commands using If Control the logical definition is to Or them together since it is impossible to have more than one command flowing from a device at a time.

 

If Control 'xxxxx' is switched On

Or Control 'xxxxx' is switched Fast On

Then

 

The following can never be True.

 

If Control 'xxxxx' is switched On

And Control 'xxxxx' is switched Fast On

Then

Posted
When checking for multiple commands using If Control the logical definition is to Or them together since it is impossible to have more than one command flowing from a device at a time.

 

I did not know this. I assumed, in this case, they BOTH had to be true, looking simultaneously for receipt of an ON command while simultaneously confirming a failure to receive an OFF command (not OFF). While I understood the second statement is triggered only by an OFF command (evaluating false when triggered), I thought it would evaluate as true at all other times.

 

Furthermore, a program such as:

 

if control device1 is switched on

and control device2 is switched on

 

would ALWAYS evaluate as false (I thought) because it is not possible to simultaneously receive two commands. This would not happen if the ISY treated this as a logical OR.

 

If I get ambitious (50/50 chance) I will run some experiments for my own gratification.

Posted

Well, I did get ambitious. I created a simple program, consisting of two control ON statements, joined by a logical AND.

 

If

control device1 is switched on

and control device2 is switched on

 

This program evaluated FALSE every time, suggesting that with a logical AND (even with both are control statements) both conditions must be true.

 

From this, I tend to conclude that a program such as:

 

if

control device1 is switched on

and control device1 is not switched off

 

both conditions must be true. Furthermore, I tend to continue to believe that "control xx not switched off" will always evaluate TRUE except at that point in time when an OFF command is received.

Posted

In this situation, And vs Or makes no difference. The result will be the same. An "on" command will drive the "then", an "off" command will drive the "else"

 


If
       Control 'device' is switched On
   And Control 'device' is not switched Off

Then

 

If
       Control 'device' is switched On
   Or Control 'device' is not switched Off

Then

 

The logic is as follows.

 

This stand alone program has only 2 possible triggers,

1) pushing the "on" paddle

2) pushing the "off" paddle

 

If the "on" paddles is pushed, both clauses will be true. So it doesn't matter if they are connected by "and" or "or"

If the "off" paddle is pushed, both clauses will be false. So, again, it doesn't matter if they are connected by "and" or "or"

 

The purpose of the "is not" clause is to have a trigger for the "else" statement. Without the "control is not switched off" line, there would be nothing to trigger the program to run "else". So if you want one thing to happen when the "on" paddle is pushed, and a different thing to happen when the "off" paddle is pushed, you write it this way. The other choice of course is to have two separate programs.

Posted

oberkc

 

You are absolutey right, i was wrong. Anding two different devices or two different commands for the same device where NOT is not used results in a False evaluation. Thank you for correcting a long held and wrong conclusion.

Posted
"If the if statement begins "if status" the ISY looks for the status command."

 

 

If Status is not looking for a Status command. If Status is checking the value that is displayed in the Current State column which is the Status of the device as the ISY knows it. If Status triggers the Program each time the Current State value changes (unlike If Control which triggers only on the specific command) which means an If Status will run the Then clause when the IF is True and the Else clause when the IF is False. Again, the Current State value must change for If Status to trigger the Program.

 

Where does one see the "Status of the Device"? Under the MAIN tab, there is a column called "Current State" which shows the device is either ON or OFF. Under the PROGRAM tab, there is a status column which shows True or False for the program. If the "then" section ran last, it will show TRUE. If the "else" section ran last it will show FALSE. ??

 

regards

Posted

If Status 'node name' is checking "Current State" of the node.

 

If Program 'program name' is checking True/False "Status" of the named Program.

 

When the If evaluates as True the Then clause runs and the Program "Status" is True

 

When the If evaluates as False the Else clause runs and the Program "Status" is False

Guest
This topic is now closed to further replies.

×
×
  • Create New...