Mabye I am just missing something, but is it possible to invert an IF statement within rule machine?
Yes. After you enter the condition, you then go into define the rule. Before picking the condition the parens and NOT are there to select.
Sorry I should have been more specific, I do see it within the "rule area" of various rule types, but not within the action section. Once your are adding a conditional action, the only choices are the conditions themselves, no more logic to choose.
That's correct. The not is not available for Conditional Actions. Why not just pick the other condition? For example, rather than picking door is not open pick door is closed. What condition are you trying to enter for a conditional action?
Because I would rather do
If (!disarmed)
{
Do the thing
}
Instead of
If (Armed home || armed away || armed stay || armed night)
{
end the rule execution
}
Else
{
do the thing
}
And actually we can't even do ||OR, it ends up being a bunch of else-if ->end
In your second case why wouldn't you just do if disarmed?
Doing if disarmed is the exact same as doing not disarmed, you just move the actions to the ELSE... You shouldn't need all those or statements.
You do realize that Conditional Actions do not cause the rule to be re-evaluated, correct? So, this will only be evaluated on overall rule truth change. An you cannot do multiple conditions in a conditional action either. There is no OR or AND available in the conditional action either.
Sure that would work, but it doesn't seem like a scalable way to make more complex conditional actions work in the long run. And it makes the code smell bad.
Yes, I realize it doesn't reevaluate, my example was mistyped for brevity, it would have ended up being
If (armed home)
Do nothing
Else if (armed stay)
Do nothing
Else if (armed away)
Do nothing
Else if (armed night)
Do nothing
Else
Do the thing
Two things: First, this feature will be added for the next release. NOT a condition as a primitive for any condition (not for Trigger Events).
Second, you can get NOT Condition as simply as this:
IF (condition) THEN
--do nothing--
ELSE
--do what you want for NOT Condition
ENDIF
That's pretty much the definition of NOT Condition.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.