Device Preferences
For developers: how to define preferences (inputs) in a driver
Device Preferences
The driver preferences provides the Hubitat Elevation hub with user settings for the driver. Preferences for a driver are more simplistic than the preferences for an app as they all appear on a single page. Preferences are also different from an app in that they are defined within the metadata block.
Structure
metadata {
preferences {
// ...
}
}
Entries
Each entry within the preferences section is an input which is a single setting for the device.
input
Each input must have a name and type, though a title is also recommended. Depending on the type, additional parameters may also be supported. Possible input parameters:
-
name- Uniquely identifies this setting -
type- The data type of the setting which may be one ofbool,date,decimal,email,enum,number,password,time,text(with behavior generally similar to those of app preferences) -
title- The text to be shown in the driver UI -
description- The long text description of the setting (optional or"") -
required- Specifies whether or not this setting requires a value before the UI allows saving (trueorfalse) -
defaultValue- The default value displayed for the setting if none is specified -
options- Only available when the type isenum. Allows you to specify the values that appear in the dropdown. -
range- Only available when the type isnumberordecimal. Specify aStringin the format "low..high" with the range of valid numeric values, e.g.,"0..10".
Example
preferences {
input name: "settingName", type: "text", title: "My Setting", description: "Enter Setting Text", required: true
}