Hi
I have a question on the use of AND and OR together, in the following code:-
EVERY 5 SECONDS
AND IF A/C SYS HEAT ON
AND IF BED 1 SYSTEM MODE IS COOL
OR
AND IF BED 4/5 SYSTEM MODE IS COOL
OR
AND IF BED 6/7 SYSTEM MODE IS COOL
OR
AND IF KITCHEN MODE IS COOL
THEN A/C SYS HEAT OFF
THEN BED 1 MODE COOL
THEN BED 4/5 MODE COOL
THEN BED 6/7 MODE COOL
THEN KITCHEN MODE COOL
Will the following happen
Every 5 seconds AND if sys heat on AND (bed 1 is cool OR bed4/5 is cool OR bed 6/7 is cool OR kitchen is cool) then run the above commands.
It would be easier if I could trigger on a AC mode change, but I can't do this.
Paul
Paul,
The logic is evaluated as follows. First, any one of the triggers must occur. Then the first block of "and if" statements is evaluated. If all the "and if" statements in the block are true, the actions will be executed. If any of the "and if" statements in the block are not true, the controller will look for another block of "and if" statements separated from the previous block by an "or" statement. If all the "and if" statements are true in this block, then the actions will be executed. If not, the next "and if" block will be checked and so on. Logically speaker, the order of precedence is "and" then "or".
For example:
WHEN something happens
AND IF condition 1
AND IF condition 2
OR
AND IF condition 3
AND IF condition 4
OR
AND IF condition 5
THEN do something
is evaluated as:
WHEN something happens and [(condition 1 and condition 2) or (condition 3 and condition 4) or (condition 5)] then do something.
In your example, you would need to add the "AND IF A/C HEAT ON" to each "AND IF" block. Another way of doing this would be to use a couple of buttons to evaluate a set of conditions based upon the state of an item.
For example:
EVERY 5 SECONDS
AND IF A/C HEAT ON
THEN RUN CHECK HEAT
EVERY 5 SECONDS
AND IF A/C HEAT OFF
THEN RUN CHECK COOL
WHEN CHECK HEAT
AND IF A/C 1 SYSTEM MODE IS COOL
OR
AND IF A/C 2 SYSTEM MODE IS COOL
OR
AND IF A/C 3 SYSTEM MODE IS COOL
THEN A/C HEAT OFF
THEN A/C 1 MODE COOL
THEN A/C 2 MODE COOL
THEN A/C 3 MODE COOL
WHEN CHECK COOL
AND IF A/C 1 SYSTEM MODE IS HEAT
OR
AND IF A/C 2 SYSTEM MODE IS HEAT
OR
AND IF A/C 3 SYSTEM MODE IS HEAT
THEN A/C HEAT ON
THEN A/C 1 MODE HEAT
THEN A/C 2 MODE HEAT
THEN A/C 3 MODE HEAT
It all depends on exactly what you're trying to accomplish. There may be other ways of doing this, too.