Context Variables (Rule Engine)
Context Variables are variables that only exist during the execution of a rule and can provide additional context about the rule or event which triggered the rule. For example, if a rule was triggered by a device, context variables are set which include details about the device name, attribute, value, and other helpful details of the event that triggered the rule.
Variables are a Premium feature. If you are using the free tier, please let us know if you’d like us to reset your trial, so you can try things out.
You may also be interested in the Use Cases and Examples screenshots posted in the community which helps provide some examples in the context of real rules.
Context Variable Structure
- Event - these are variables that provide context about the event that triggered the rule to start running.
- Metadata - this provides information about the rule itself.
- Rule Name ($context.event.ruleName) - the name of the rule defined by the user.
- Rule ID ($context.event.ruleId) - the rule ID created by the system and can be found in the final part of the URL when editing a rule.
- location - rule was triggered by a Location event
- device - rule was triggered by a Device event
- variable - rule was triggered by a SharpTools Variable event
- dashboard - rule was run directly from a SharpTools dashboard via Rule Tile
- timer - rule was triggered by a timer (eg. recurring time, sunrise, sunset)
- http - rule was triggered from an HTTP Trigger
How to Use Context Variables
Please note that the available dropdown options are filtered based on the rule triggers defined in the Triggers section.