Variable Introduction and Overview

Variables are a way to store custom values that can be used in both the SharpTools.io Rule Engine and Dashboards. A variable's value can be modified by using a Variable Tile in the dashboard or using the 'Set Variable' action in an automation rule and can be accessed across dashboards and/or rules as the value is persistent across 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 be used in a variety of creative ways with both Dashboards and the Rule Engine. Here are some common use cases for variables:
  1. Aggregate the status of multiple devices into a single summary for display in the dashboard
    ex: status of multiple water sensors, motion status within a whole floor
  2. Sync attribute value across multiple devices
    ex: turn multiple lights on/off, dim multiple lights to the same level, and set multiple ACs to the same cooling point.
  3. Store a device's attribute value
    ex: resume the speaker's volume level or light's dim level
  4. Store a threshold that can be easily adjusted and used in rule conditions
    ex: dynamically change temperature threshold for heater/AC

Supported variable types

  1. Text: Stores string values
  2. True / False: Stores a boolean value of true or false
  3. 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.
The variable name must by unique across your account and only alpha-numeric characters are accepted. No space, underscore (_), dash (-), dot (.) or other symbol is allowed. Once the variable is created, the variable name cannot be modified. We recommend using a clear and self-explaining variable name to help avoid confusion later. Once the variable is created, you can can come back to the Manage Variables screen to update its value or delete the variable at any time.

Please be cautious when deleting a variable as it may interrupt your existing automation rules or dashboards that use the variable.

Use Variables in Rule Engine

Triggers

Variables can be used in the rule trigger in two ways:
  1. When a variable changes and meets the condition specified in the trigger
    • Note: Variable triggers can be compared to a static value or to another variable
    • For example, if variable $hasAnyLeak value changes and the value is True.
  2. When a location or device attribute's value changes and meets a trigger condition which compares the attribute value to a variable value
    • For example, when the Thermostat's temperature changes, and the temperature value is greater than variable $numTemperature's value
The value input field can be switched between  Manual Input or  Variable Selector by tapping the icon next to the input field.

Flow

Variables can be used in IF_Condition, Device Command, or Set Variable in the rule Flow section:
  1. IF_Condition
    • Using variables in IF_Condition is similar to using Variables in the Trigger.
      • A variable can be compared to a static value or another variable.
      • A location/device's attribute value can be compared to a variable's value.
  2. Device Command
    • A variable can be used as an parameter when sending a command to a device. 
    • For example, set speaker's level (volume) by using the $intVolume variable's value
      (Tap the icon next to the argument input field to change between Manual Input or Variable Selector)
  3. Set Variable
    • There are four types of value sources that can be used when setting a variable's value. The available source type options depend on the selected variable data type (Text, Number, True/False). 
      • Manual Input: set variable to a static value, such as True, 50, or "On". (The value input options depend on the variable data type.)
      • Device Attribute: set a variable using a device attribute's value.
        Ex: set a N umber variable's value using a light's dim level, or set a Text variable's value using a door's contact state.
      • Location Attribute:  set a variable 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

Use Variables in Dashboard

Variables can be added to the dashboard through the Add Item list when editing the dashboard. The variable's current value can be viewed or changed through the variable tiles. Tile Settings that are common to other tiles such as 'Security' can be applied to Rule tiles as well - for example, to make a variable read-only.
By default, the Variable Tile will show 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, such as a website, another dashboard, or execute a rule by using the special Hyperlink syntax when the tile is tapped. This flexibility allows you to achieve a variety of different creative actions.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.