Capability

The Capability object encapsulates information about a certain Capability.

A Capability object cannot be created. You can get the Capabilities for a given device using the capabilities method on a Device instance:

def capabilities = mydevice.capabilities

For documentation for the available Capabilities, you can refer to the Capabilities Reference.


getAttributes()

Signature:
List<Attribute> getAttributes()
Returns:
List <Attribute> - A list of Attributes of this capability. An empty list will be returned if this Capability has no Attributes.

Example:

preferences {
    section() {
        input "mySwitch", "capability.switch"
    }
}
...
def mySwitchCaps = mySwitch.capabilities

// log each capability supported by the "mySwitch" device, along
// with all its supported attributes
mySwitchCaps.each {cap ->
    log.debug "Capability name: ${cap.name}"
    cap.attributes.each {attr ->
        log.debug "-- Attribute name; ${attr.name}"
    }
}
...

getCommands()

Signature:
List<Command> getCommands()
Returns:
List <Command> - A list of Commands of this capability. An empty list will be returned if this Capability has no commands.

Example:

preferences {
    section() {
        input "mySwitch", "capability.switch"
    }
}
...
def mySwitchCaps = mySwitch.capabilities

// log each capability supported by the "mySwitch" device, along
// with all its supported commands
mySwitchCaps.each {cap ->
    log.debug "Capability name: ${cap.name}"
    cap.commands.each {comm ->
        log.debug "-- Command name: ${comm.name}"
    }
}
...

getName()

The name of the capability.

Signature:
String getName()
Returns:
String - the name of the capability.

Example:

preferences {
    section() {
        input "mySwitch", "capability.switch"
    }
}
...
def mySwitchCaps = mySwitch.capabilities

// log each capability supported by the "mySwitch" device
mySwitchCaps.each {cap ->
    log.debug "Capability name: ${cap.name}"
}
...