Hello everyone,
I have been doing some tests on my own, regarding these three possible results of a Rule execution and I arrived to some conclussions I will be listing below.
One action
Ignored
:
The action is ignored because none of the conditions are satisfied. This means there is no code to be executed. Take into account that the code inside an else
clause is always executed when all the conditions avobe are evaluated false
. So, an action with a non-empty else
clause will never result Ignored
. To illustrate this with an example (pseudo-code):
Ignored
if (false) then
...
...
Success
if (false) then
...
...
else
...
...
Success
:
At least one of the condition is satisfied.To illustrate this with an example (pseudo-code):
Ignored
if (true) then
...
...
else
...
...
Success
if (false) then
...
...
else
...
...
Failure
:
The execution of the Rule failed. This could be for several reasons. Maybe a timeout, maybe one of the devices is offline or has been deleted*.
Several actions
Remember that, in Rules, actions
is defined as an array, so many actions may be listed. So in more than one action is listed, the conclussions were the following:
Success
:
At least one of the actions result in Success
.
Ignored
:
None of its actions results in Success
. At least one of its actions results in Ignored
.
Failure
:
None of its actions results in Success
. None of its actions results in Ignored
.
has been deleted*:
Important distinction to be made here. If a device has been deleted in the command
section (this means is a device that is going to be applied a command) then the result of the execution is Failure
. Whereas, if a device has been deleted and it is one of the devices evaluated in the condition, the the execution runs into an HTTP 500
error. To illustrate this with an example lets say that we have this rule:
{
"name": "example",
"actions": [
{
"if": {
"equals": {
"left": {
"device": {
"devices": [
"{{ switch 1 }}"
],
"component": "main",
"capability": "switch",
"attribute": "switch"
}
},
"right": {
"string": "on"
}
},
"then": [
{
"command": {
"devices": [
"{{ switch 2 }}"
],
"commands": [
{
"component": "main",
"capability": "switch",
"command": "on",
"arguments": []
}
]
}
}
],
"else": []
}
}
]
}
Deleting {{ switch 1 }}
would make the execution of the rule run into a HTTP 500
Internal Server Error. Deleting {{ switch 2 }}
would make the result of the execution a Failure
.
Hope this was usefull, regards
Andres