Reference › SmartApp › Page › Section › DeviceSetting
A device setting creates a control that allows the user to select one or more devices. The list of devices presented is filtered by the capabilities specified in the setting definition. For example
section.deviceSetting("motionSensors")
.capability("motionSensor")
.multiple(true)
- capabilities
- capability
- closeOnSelection
- defaultValue
- description
- disabled
- excludeCapabilities
- excludeCapability
- multiple
- name
- permissions
- preselect
- required
- submitOnChange
- translateDefaultValue
▸ capabilities(items
: string[]): DeviceSetting
Sets the required capabilities for the devices in the selection options. To appear in the selection list, devices must have all of the specified capabilities.
Parameters:
Name | Type |
---|---|
items |
string[] |
Returns: DeviceSetting
▸ capability(item
: string): DeviceSetting
Sets the required capability for the devices in the selection options.
Parameters:
Name | Type |
---|---|
item |
string |
Returns: DeviceSetting
▸ closeOnSelection(value
: boolean): DeviceSetting
Specifies whether this input should close on selection.
Parameters:
Name | Type |
---|---|
value |
boolean |
Returns: DeviceSetting
▸ defaultValue(value
: string | number): DeviceSetting
Inherited from SectionSetting.defaultValue
Sets the initial value displayed in the setting when first shown to the user.
Parameters:
Name | Type |
---|---|
value |
string | number |
Returns: DeviceSetting
▸ description(value
: string): DeviceSetting
Inherited from SectionSetting.description
Sets value displayed in the setting control. Defaults to 'Tap to Set' for most types of settings.
Parameters:
Name | Type |
---|---|
value |
string |
Returns: DeviceSetting
▸ disabled(value
: boolean): DeviceSetting
Inherited from SectionSetting.disabled
Disables the ability to use the control
Parameters:
Name | Type |
---|---|
value |
boolean |
Returns: DeviceSetting
▸ excludeCapabilities(items
: string[]): DeviceSetting
Devices with these capabilities will be excluded from the selection options
even though they match the criteria specified in the capabilities()
method
Parameters:
Name | Type |
---|---|
items |
string[] |
Returns: DeviceSetting
▸ excludeCapability(item
: string): DeviceSetting
Devices with this capability will be excluded from the selection options
even though they match the criteria specified in the capabilities()
method
Parameters:
Name | Type |
---|---|
item |
string |
Returns: DeviceSetting
▸ multiple(value
: boolean): DeviceSetting
Specifies whether this device setting can have multiple values.
Parameters:
Name | Type |
---|---|
value |
boolean |
Returns: DeviceSetting
▸ name(value
: string): DeviceSetting
Inherited from SectionSetting.name
Sets the name of this setting. Used to reference the setting value during the processing of events. Also used as part of the i18n key for translating the displayed name and description of the setting. All settings on a page must have unique names.
Parameters:
Name | Type |
---|---|
value |
string |
Returns: DeviceSetting
▸ permissions(value
: string | string[] | PermissionsEnum[]): DeviceSetting
The required permissions for the selected device(s). This value can be
specified as a string (rwx
), an array of strings(['r','w','x']
), or
an array of typescript enum values ([PermissionsEnum.R, PermissionsEnum.W, PermissionsEnum.X]
)
Parameters:
Name | Type |
---|---|
value |
string | string[] | PermissionsEnum[] |
Returns: DeviceSetting
▸ preselect(value
: boolean): DeviceSetting
Specifies whether the first device in the list of options should be pre selected.
Parameters:
Name | Type |
---|---|
value |
boolean |
Returns: DeviceSetting
▸ required(value
: boolean): DeviceSetting
Inherited from SectionSetting.required
Specifies that the control must be set in order to save the configuration page
Parameters:
Name | Type |
---|---|
value |
boolean |
Returns: DeviceSetting
▸ submitOnChange(value
: boolean): DeviceSetting
Inherited from SectionSetting.submitOnChange
Causes the page to be submitted and re-rendered any time the value of the setting is changed, rather than requiring the user to tap Next or Done. This behavior is useful when the the presence or enabled/disabled status of some settings depend on the value of other settings.
Parameters:
Name | Type |
---|---|
value |
boolean |
Returns: DeviceSetting
▸ translateDefaultValue(value
: string): DeviceSetting
Inherited from SectionSetting.translateDefaultValue
Sets the initial value of the setting by passing the specified value through the i18n translation process.
You might want to use translatedDefaultValue
rather than defaultValue
in a case like setting the
default value of a text setting to the word "Kitchen" in the language of the user. defaultValue('Kitchen')
will set the value "Kitchen" regardless of the user's language or whether there were localization file entries
for the key "Kitchen". However, translateDefaultValue('Kitchen')
will look for a localization file entry
with the key "Kitchen" and set the default to that value.
Parameters:
Name | Type |
---|---|
value |
string |
Returns: DeviceSetting