The Settings > Hub Variables page allows you to create and manage hub variables and hub variable connectors.
Creating a Hub Variable
To create a hub variable, select the New Variable button:
Then fill in the required information:
- Provide a name for the variable. This is how you will reference the variable later in apps (e.g., rules, Hubitat® Dashboard, etc.). It can contain letters, numbers, or spaces but may not contain an of the following characters: ' " \ ~ [ ] < > In this example, we will call the variable
- Select a Variable Type for the new variable. Options include Number (integer, negative or positive), Decimal (number including a decimal point, positive or negative), String (text, including letters, numbers, spaces, etc.), Boolean (true or false), or DateTime (a specific date, time of day, or time and date both). In this example, we will use String:
- Provide an initial value for the variable (all variables must be initialized with a valid value for the specified type):
Managing Hub Variables
The table at the top of the Hub Variables page displays the current hub variables (if any have been created) and their current values. Note that current values only update on page reload or when the Refresh button is selected. The table also provides ways to manage these variables.
To create a hub variable connector, select the Create link in the Connector column (B). If a connector has been created, the type of the connector will appear in the Connector column with the type of connector that was created (A), and selecting the link will take you to the device page for that connector.
What is a Connector? How Do I Choose a Connector Type?
A connector is a device you can create that is tied to the hub variable. These devices can be used in apps that cannot work natively with hub variables, which some older apps or community apps may not support. More and more apps are becoming able to work with hub variables (a relatively new feature) directly. That option is preferred if available (for example, Hubitat Dashboard, Rule Machine with Rule 5.x and newer, and many other built-in apps and community apps can use hub variables directly).
If the app you're using does not support hub variables but does support a device of a supported connector type, then you can create a connector of the appropriate type for use with the app. Options vary based on variable type, but for example, a Number variable can be used with a Dimmer connector to set values 1-100 and can be used in an app that supports dimmer-type devices.
Setting Values Manually
While variable values will generally be set by an app (e.g., a rule), the value can be set manually by selecting the current value under the Value column and providing a new value. (Note: the value is saved immediately.)
Finding Variables in Use By Apps
If a variable is in use by an app, the variable name in the Name column will appear in colored text, and selecting the variable name will pop up a list of apps that have registered their use of this variable. Select Done to dismiss this list and return to the hub variables table. This will not show instances that use only the variable connector, if created and used. Connectors act like regular devices, and their use can be checked by navigating to the connector device page and checking the In use by section.
Deleting a Variable
To delete a hub variable, select the Delete link under the Delete column (C). This will delete the hub variable and, if created, the associated connector. It is recommended to remove a variable from app apps by which it or an associated connector are in use (see above) before deleting a variable.