[Rules API] Issue executing a Rule

Hello everyone,

This sounds basic but I haven’t found the way to find any Rules API’s Log… so now I am wondering, is there any way to check the Rule API’s logs?

I have created a Rule and when I Execute it I get this error:

{
    "executionId": "26C8F13E-9AC1-44E9-92A2-58FF98340FA6.0f0796",
    "id": "3299b44f-b850-4a2d-9167-9999f74d433a",
    "executionLocation": "Cloud",
    "result": "Ignored",
    "actions": [
        {
            "actionId": "680cfd16-3157-4480-a2d2-5c662352fb1e",
            "if": {
                "result": "False"
            }
        }
    ]
}

So, how I can track this down to the command that is actually failing?

Thanks!
Diego

Hi, @DiegoAntonino!

No, you cannot check logs about the Rule execution.
However, you can share the Rule so we can review it. If everything seems ok, I can check with the engineering team if they can provide more feedback about the execution failure.

It is pretty hard to work out what the execution output is trying to say even when you know what the rule actually says. As things stand I can’t see any evidence of anything that I would call an error or a failure.

Hi @nayelyz,

This is one of the rules that I am having a problem with:

{
    "name": "I am Back Home!",
    "timeZoneId": "America/New_York",
    "actions": [
        {
            "if": {
                "or": [
                    {
                        "equals": {
                            "left": {
                                "device": {
                                    "devices": [
                                        "{{I'm Back Routine Virtual Switch}}"
                                    ],
                                    "component": "main",
                                    "capability": "switch",
                                    "attribute": "switch"
                                }
                            },
                            "right": {
                                "string": "on"
                            }
                        }
                    },
                    {
                        "and": [
                            {
                                "equals": {
                                    "left": {
                                        "device": {
                                            "devices": [
                                                "{{Phone 1}}",
                                                "{{Phone 2}}"
                                            ],
                                            "component": "main",
                                            "capability": "presenceSensor",
                                            "attribute": "presence"
                                        }
                                    },
                                    "right": {
                                        "string": "present"
                                    }
                                }
                            },
                            {
                                "equals": {
                                    "left": {
                                        "location": {
                                            "attribute": "Mode"
                                        }
                                    },
                                    "right": {
                                        "string": "{{locationMode_Away}}"
                                    }
                                }
                            }
                        ]
                    }
                ],
                "then": [
                    {
                        "command": {
                            "devices": [
                                "{{away_virtual_switch}}",
                                "{{I'm Back Routine Virtual Switch}}"
                            ],
                            "commands": [
                                {
                                    "component": "main",
                                    "capability": "switch",
                                    "command": "off"
                                }
                            ]
                        }
                    },
                    {
                        "command": {
                            "devices": [
                                "{{Bathroom Lights and Motion}}",
                                "{{Kids Lights and Motion}}",
                                "{{Washroom Lights and Motion}}",
                                "{{Dining Table Lights and Motion}}"
                            ],
                            "commands": [
                                {
                                    "component": "main",
                                    "capability": "platinummassive43262.jascoOperationMode",
                                    "command": "setOperationMode",
                                    "arguments": [
                                        {
                                            "string": "occupancy"
                                        }
                                    ]
                                }
                            ]
                        }
                    },
                    {
                        "location": {
                            "mode": "{{locationMode_Home}}"
                        }
                    },
                    {
                        "if": {
                            "lessThan": {
                                "left": {
                                    "device": {
                                        "devices": [
                                            "{{Lux Sensor}}"
                                        ],
                                        "component": "main",
                                        "capability": "illuminanceMeasurement",
                                        "attribute": "illuminance"
                                    }
                                },
                                "right": {
                                    "integer": 250
                                }
                            },
                            "then": [
                                {
                                    "command": {
                                        "devices": [
                                            "{{Entrance Lights}}"
                                        ],
                                        "commands": [
                                            {
                                                "component": "main",
                                                "capability": "switchLevel",
                                                "command": "setLevel",
                                                "arguments": [
                                                    {
                                                        "integer": 100
                                                    }
                                                ]
                                            }
                                        ]
                                    }
                                }
                            ]
                        }
                    },
                    {
                        "if": {
                            "between": {
                                "value": {
                                    "time": {
                                        "reference": "Now"
                                    }
                                },
                                "start": {
                                    "time": {
                                        "reference": "Noon",
                                        "offset": {
                                            "value": {
                                                "integer": -3
                                            },
                                            "unit": "Hour"
                                        }
                                    }
                                },
                                "end": {
                                    "time": {
                                        "reference": "Midnight",
                                        "offset": {
                                            "value": {
                                                "integer": -3
                                            },
                                            "unit": "Hour"
                                        }
                                    }
                                }
                            },
                            "then": [
                                {
                                    "command": {
                                        "devices": [
                                            "{{Sonos Kitchen}}"
                                        ],
                                        "commands": [
                                            {
                                                "component": "main",
                                                "capability": "mediaPlayback",
                                                "command": "play"
                                            }
                                        ]
                                    }
                                }
                            ]
                        }
                    }
                ]
            }
        }
    ]
}

I try removing things but I could not nail it down yet… I remember that it worked at a certain point but I don’t recall what I did after all…

Thanks for your help!
Diego

Thank you for the information. I received the same error when none of the conditions in the or operator were true. After I changed the value to be evaluated as true, the Rule was executed.
In your case is at least one condition true?
If you see the values match a condition but the Rule keeps saying it is false, please share with me the executionID and RuleID over DM.
Just verify the first condition in “and” is configured as you expect because currently, only one presence sensor must be active for the Rule to execute.

1 Like

Gotcha! So, this basically means that the IF condition returns False and there is no else, so there is nothing to run… I guess this should be ignored anyway, instead of throwing an error…

I did a test adding an else statement and put some silly command, and then the execution is successful.

As for the purpose of the rule (the “and” part), is to run when the location_mode is away and my wife or I get home.

Thanks again @nayelyz for your help!

@nayelyz The result can be Success, Failure or Ignored. But what does that actually mean?

In this example Ignored seems to be suggestive of the result of an if action not being used (no else), and you also see it for Rules with a single every action. However rules can have multiple top level actions that are independent and there only seems to be a single result.

So what actually constitutes a rule as a whole being a Success or a Failure, and what is unsuccessful about it being Ignored?

I will check this with the engineering team. I’ll let you know once I get more info.

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

1 Like

That didn’t make any sense to me and indeed isn’t what I see. I’ve only done some basic tests but a Rule that implements ‘if A then B else C’ will certainly return Success regardless of whether A is true or false, provided B or C actually ‘do something’.

By ‘do something’ I mean something like run a command or execute a scene.

If neither B or C ‘do anything’, for example they are nested conditions returning false, then the result is Ignored.

Hi, @orangebucket

Indeed, you are right. I edited my previous comment and try to be more clear about it.