Rules Glossary

Actions:

CommandAction

Send command(s) to device(s).

EveryAction

Perform actions based on an interval specified in the rule.

IfAction

Perform actions based on the result of a boolean condition evaluation.

LocationAction

Set the location mode.

SleepAction

Allows for adding a delay during the processing of other actions provided in the rule.


Conditions:

EqualsCondition

Checks for equal values. ex: If my Bedroom Switch is on.

"equals": {
    "left": {
        "device": {
            "devices": ["9277539C-0D51-4CF6-813D-E96017F70E29"],
            "component": "main",
            "capability": "switch",
            "attribute": "switch"
        }
    }, 
    "right": {
        "string": "on"
    }
}

GreaterThanCondition

Checks if a value is greater than a provided value. ex: If a light's level is larger than a given value.

"greater_than": {
    "left": {
        "integer": 50
    },
    "right": {
        "device": {
            "devices": ["15E8ED60-422A-45D7-91A6-131502BE77ED"],
            "component": "main",
            "capability": "switchLevel",
            "attribute": "level"
        }
    }
}

GreaterThanOrEqualsCondition

Checks if a value is greater than or equal to a provided value. ex: If a light's level is larger to equal to a given value.

"greater_than_or_equals": {
    "left": {
        "integer": 50
    },
    "right": {
        "device": {
            "devices": ["15E8ED60-422A-45D7-91A6-131502BE77ED"],
            "component": "main",
            "capability": "switchLevel",
            "attribute": "level"
        }
    }
}

LessThanCondition

Checks if a value is less than a provided value. ex: If a light's level is less than a given value.

"less_than": {
    "left": {
        "integer": 50
    },
    "right": {
        "device": {
            "devices": ["15E8ED60-422A-45D7-91A6-131502BE77ED"],
            "component": "main",
            "capability": "switchLevel",
            "attribute": "level"
        }
    }
}

LessThanOrEqualsCondition

Checks if a value is less than or equal to a provided value. ex: If a light's level is less than or equal to a given value.

"less_than_or_equals": {
    "left": {
        "integer": 50
    },
    "right": {
        "device": {
            "devices": ["15E8ED60-422A-45D7-91A6-131502BE77ED"],
            "component": "main",
            "capability": "switchLevel",
            "attribute": "level"
        }
    }
}

BetweenCondition

Checks if a value is between the provided values.

"between": {
    "value": {
        "device": {
            "devices": ["0746171B-DF74-4C57-8B1B-6676AB449C71"],
            "component": "main",
            "capability": "switchLevel",
            "attribute": "level"
        }
    },
    "start": {
        "integer": 50
    },
    "end": {
        "integer": 75
    }
}

Operands:

DeviceOperand

Allows for the use of the state of a device to act as a condition.

LocationOperand

Allows for the use of the location mode state to act as a condition

ArrayOperand

Allows for evaluation of multiple operands.


Misc Rule API Terms

Trigger

In the Rules API a trigger acts as a way to start the execution of a rule. When we create a rule with an EqualsCondition that uses a DeviceOperand the device being used will then act as a trigger for the rule. In the example that follows the switch in the EqualsCondition is the trigger. When that device is used the rule engine will then evaluate the EqualsCondition and determine if it can proceed to execute the rule.

{
    "name": "Turn on lights when switch is turned on.",
    "actions": [
    {
        "if": {

            "equals": {
                "left": {
                    "device": {
                        "devices": ["2CFC68C5-95A6-477C-804C-8704E3A161DF"],
                        "component": "main",
                        "capability": "switch",
                        "attribute": "switch"
                    }
                },
                "right": {
                    "string": "on"
                }
            },
            "then": [
                {
                    "command": {
                        "devices": ["4269AC7F-5B05-4B17-B5BD-86FDB0577912", "6A62F2C6-AA00-4E95-AD28-F060AEBC200E"],
                        "commands": [{
                            "component": "main",
                            "capability": "switch",
                            "command": "on"
                        }]
                    }
                }
            ]
        }
    }
    ]

}