If statement evaluating to False even though logically it should be True

My rule machine If statement is evaluated as FALSE even though it logically is (T AND (T OR T)). My mode currently is EVENING. Am I doing something wrong?

I think the issue is the "NOT" in your IF statement.

I created a quick little rule to check, and the NOT is inverting the logic correctly.

Thus, I believe your If statement may really be IF (NOT T and (T OR T)) which would yield a FALSE. I could be wrong... try removing the NOT as a test to see what happens.


I may be way off but is this the same issue as:

Plus one for the NOT and missing parenthesis.... At least it looks that way on the surface....

1 Like

Yeah why I even replied after Dan offered a solution is beyond me, listen to them. :wink:


My only get-out clause is how the inclusion of a NOT is displayed on screen, and how it is applied, not sure if it automatically puts the parenthesis around the thing you want to reverse or whether you are expected to do that yourself.... I suspect it is the latter....


No parentheses are inserted around anything automatically; it just applies to the condition or sub-expression directly to its right.

Playing around with this a little more, it does seem there are two ways you can get a NOT into things, either directly as part of a condition (where it is shown in bold and evaluated T or F, with the result from NOT included as part of that evaluation) or by adding a NOT operator to the expression before a condition (in which case it is not shown in bold--and its effect is not considered in the T or F display of the condition to its right, as it is not technically a part of that condition), as demonstrated with this contrived example that shows both possibilities:



(The sensor is open, BTW, and I non-sensically tested this attribute everywhere since the "contact open" is true, and it's easy to see how that affects the outcome.)

I had never played around with the expression editor so much before and never really knew how NOT affected the display (nor could I have told you if there were two ways to get one or if my brain just didn't remember right...), so this discussion prompted me to try some things. :smiley:

1 Like

Yeah. The Ui is misleading. It states “NOT this condition”, but it instead applies NOT to a larger part of the logical expression. NOT this condition should apply parentheses automatically so that the not only applies to the condition being edited. @bravenel

This isn't true (NOT True). NOT this condition applies only to that condition, is evaluated at the time the condition is evaluated. NOT can also be a logical operator in an expression, and this is different. It applies to the following term, which might be a condition or a parenthesized sub-expression.

In the first case, the NOT is in bold text and the parenthetical (T) or (F) reflects the truth of the negated condition. Like this:

It is Day mode, so the condition of NOT Mode is Day is false, as shown by (F) following it,.

In the second case, the NOT is not bold, and applies to the next term in the expression:

Here the condition Mode is Day is true, as shown the the (T) after the condition, while in both cases the overall expression is false.

It certainly helps to see the Conditions themselves, which you didn't show on your original post:

This is never true. NOT applies either to just the condition, or to just the next term in the expression (which might be a condition or a parenthesized sub-expression). When NOT (as operator in the expression) is encountered, the following term is evaluated, and then its truth is negated. After that, the evaluation moves on.


Well, I've deleted and recreated the rule, as I suspect something was corrupted. It's working fine now, and you're right, the parentheses are not needed.

1 Like

Download the Hubitat app