Variable Introduction and Overview
Variables are a powerful tool that let you store and use custom values in both your Dashboards and Rule Engine. Acting like containers that hold data, variables allow you to gather information from multiple devices, coordinate actions across them, remember settings, or easily adjust rules.
This feature, exclusive to our Premium users, enables you to fine-tune your smart home setup, making automation rules and dashboards more flexible and personalized. Whether dealing with numbers, true/false conditions, or text, variables provide an extra layer of adaptability that simplifies and enhances your interaction with your smart devices on the SharpTools.io platform.
Variables are a Premium only feature, and can be accessed during your Premium trial period. If you are using the free tier, please send us an email to support@sharptools.io if you'd like us to reset your trial to give Variables a try.
What can I do with variables?
Variables can creatively supplement both Dashboards and the Rule Engine. Here are a few popular applications of variables:
Consolidate several devices' status into a singular summary for display on the dashboard
For example: combining the status of numerous water sensors or motion statuses within an entire floor.
Synchronize attribute values across several devices
For example: synchronizing on/off commands for multiple lights, dimming numerous lights to the same intensity, or setting several air conditioners to the same cooling level.
Store a device's attribute value
For example: retaining the volume level of a speaker or light's dimming level.
Save an easily adjustable threshold for use in rule conditions
For example: adjusting the temperature threshold for a heater/AC dynamically.
Supported variable types
- Text: Stores string values
- True / False: Stores a boolean value of true or false
- Number: Stores numeric values (integer and decimal)
How to create variables?
The Manage Variables screen can be accessed from Manage Resources, Manage Rules, and the Rule Editor. All the previously created variables can be found here along with their current values. To create a new variable, tap "Create Variable" button at the bottom-right corner.
Caution: Deleting a variable could disrupt your existing automation rules or dashboards that utilize the variable.
Use Variables in Rule Engine
Triggers
Variables can be incorporated into the rule trigger in two ways:
- When a variable changes and meets the condition specified in the trigger
- Note: Variable triggers can be compared to a static value or another variable
For example, if the value of variable $hasAnyLeak changes and becomes True.
- When the value of a location or device attribute changes and meets a trigger condition that compares the attribute value to a variable value
For example, when the Thermostat's temperature changes, and the temperature value exceeds variable $numTemperature's value
You can switch the value input field between Manual Input or Variable Selector by tapping the icon next to the input field.
Flow
Variables can be incorporated into IF_Condition, Device Command, or Set Variable in the rule Flow section:
IF_Condition
The usage of variables in IF_Condition mirrors that in the Trigger.
- A variable can be compared to a static value or another variable.
- An attribute value of a location/device can be compared to a variable's value.
Device Command
A variable can be utilized as a parameter when sending a command to a device.
For example, you can set the speaker's volume level using the value of the $intVolume variable.
You can switch the value input field between Manual Input or Variable Selector by tapping the icon next to the input field.
Set Variable
There are five types of value sources available when setting a variable's value. The options depend on the chosen variable data type (Text, Number, True/False).
Manual Input: Set the variable to a static value, like True, 50, or "On".
(The value input options depend on the variable data type.)
Device Attribute: Assign a variable's value using a device attribute's value.
Ex: Set a Number variable's value using a light's dim level, or a Text variable's value using a door's contact state.
Location Attribute: Assign a variable's value using a location attribute's value.
Ex: Set a Text variable's value using the SHM/HSM or Mode state.
- Variable: Set the variable value using another variable's value
Expression: Evaluate a logical or math expression and set the variable to the resulting value of the expression
Use Variables in Dashboard
Variables can be added to the dashboard through the Add Item list while editing the dashboard. The current value of the variable can be viewed or altered through the added variable tiles. Common tile settings like 'Security' can also be applied to variable tiles, for instance, to make a variable read-only.
By default, the Variable Tile displays an input prompt (toggle for True/False variable) when tapped in the dashboard to allow value updates. You can customize the tile to a open hyperlink when the tile is tapped: such as a website, another dashboard, or execute a rule by using the special Hyperlink syntax. This flexibility allows you to achieve a variety of different creative actions.