This document describes properties and methods available on the Attribute object. (This is not a common need in custom apps, but using the object is possible. If you are simply trying to define a custom attribute in your driver code, see: Device Definition.)
id - Long: the unique id of this attribute.version - Long: the database version of this attribute.dataType - String: The type of data that is stored in this attribute; possible values are:
ENUM: any of a predetermined list of possible String valuesSTRING: a String valueDYNAMIC_ENUM: not currently differentiated from other String values (not recommended for use)JSON_OBJECT: a JSON string (validity not enforced at the driver level but strongly recommended, as apps may depend on parsable JSON value)NUMBER: a numeric type like Integer or BigDecimalDATE: not currently standardized (we suggest using a string attribute with a standard format that works for your driver or apps using it)VECTOR3: not currently standardized, but a format like "[x:1,y:2,z:3]" is conventionalname - String: the name of this attribute.capability - boolean: true if this attribute describes a capability.deviceTypeId - Long: the id of the device type that owns this attribute.possibleValues - List<String>: a list of possible values for this attribute if dataType is ENUM.Returns a list of possible values for an ENUM type attribute (e.g., ["on", "off"] for the switch attribute from a capability "Switch" device).
List<String> getValues()
none
List<String> - the list of possible values for the attribute.
Convert the attribute to a Map.
Map toMap()Map toMap(boolean full)full - Optional; include the values entryA Map with these keys:
id - Long: the attribute iddataType - String: the data typename - String: the attribute namevalues - List<String>: the allowed values (included only when full is true)Get the allowed values as JSON.
String getPossibleValueJson()None
A JSON array String, or the JSON value null if no values are set
Set the allowed values from a JSON array of Strings. null or empty text clears them.
void setPossibleValuesJson(String json)json - JSON array of strings; null or empty text clears the valuesnone
Create an attribute by copying matching properties from a Map of parsed JSON.
Attribute fromJson(Map parsedJson)parsedJson - Map of attribute property names to valuesThe populated Attribute, or null if the Map is null
Create a copy of this attribute, with its own copy of the allowed-values list.
Attribute clone()None
The copied Attribute
CloneNotSupportedException if the superclass cannot be cloned