Attribute Object

For developers: documentation of the Attribute object

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.)

Properties

  • 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 values
    • STRING: a String value
    • DYNAMIC_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 BigDecimal
    • DATE: 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 conventional
  • name - String: the name of this attribute.
  • possibleValues - List<String>: a list of possible values for this attribute if dataType is ENUM.

Methods

getValues

Returns a list of possible values for an ENUM type attribute (e.g., ["on", "off"] for the switch attribute from a capability "Switch" device).

Signature

List<String> getValues()

Parameters

none

Returns

List<String> - the list of possible values for the attribute.