How do I determine/query the list of capabilities for a Z-Wave Device?

I’m new to SmartThings and SmartApp development. One element of the device-capabilities relationship escapes me.

I have seen the capabilities taxonomy list and I understand how it acts like an “interface” in OO terms. I also see how my switch (GE/Jasco wall outlet) is assigned a device type (“Z-Wave Switch”) when it is discovered.

What I can’t find anywhere in the IDE or the docs is a definitive list of which capabilities/interfaces the “Z-Wave Switch” implements. Is this defined in some class or is it meant to be discovered per device? For example, might one Z-Wave outlet implement both “capability.energyMeter” and “capability.switch”?

Also, where are the possible values of device.deviceTypeName defined? I can see in the IDE UI that my switch has a friendly type of “Z-Wave Switch” but I can’t find the value to use in an app.

I’m envisioning an app that, given a specific device as an input, will enumerate the capabilities. It would a good learning experience, even if it lacked much practical value.

1 Like

You can see this in the code for the device type, but it’s not intuitive. In the IDE, click on the My Device Types tab and in the top right will be New SmartDevice. Click that, then fill in a Name and Namespace (might be optional, I forget) and click Create at the bottom. This will start the code for a new device with that name. At this screen in the top right is a drop-down for Device Type Templates. Click that and choose the device type you’d like to look at. It will present the code and at the top under Metadata you will see all the capabilities it is being created with.

For “Z-Wave Switch” there is Actuator, Indicator, Switch, Polling, Refresh and Sensor. Rinse and repeat with any stock device type. If you create your own device type or add one from the community, you’ll see those capabilities directly in the My Device Types tab.

you should be able to access a list of capabilities in a smart app via:
log.debug someDevice.capabilities.inspect()
this method (capabilities) is documented (somewhat) here:
https://graph.api.smartthings.com/ide/doc/device

1 Like

Thanks, both of those suggestions are helpful. Using the IDE I can now see the definition of the expected capabilities.

I’m still struggling to determine what my device type should be for an input. The metadata doesn’t include a short name.

definition (name: "Z-Wave Switch", namespace: "smartthings", author: "SmartThings") 

My assumption (carried over from other languages) is that the dash and space shouldn’t be there, but if I take the metadata literally I’d do something like this:

preferences {
    section("Explore the capabilities of this device ...") {
        input "device1", "device.Z-Wave Switch", multiple: false        
    }

Mike, does the inspect() method actually interrogate the device or does it just use the metadata?

inspect() is a groovy method, it knows nothing about ST or its devices.
I’ve not searched for a specific device type as you are, but likely the string would need to match what’s seen in the ide, spaces and all.

I’ve added this SmartApp below, that I got from (I guess) Paul. I’ve made a slight modification to his original code to also display the device ID, which I needed for a REST endpoint. I just leave this app installed and choose a device whenever I have questions as to as a device’s capability or commands.

/* * Device Information * * Copyright 2014 Paul Spee All Rights Reserved * */ definition( name: "Device Information", namespace: "dpvorster", author: "Paul Spee", description: "Display Device Information", category: "My Apps", iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png", iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png", iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png")

preferences {
page name: "selectCapability"
page name: "selectDevice"
page name: “displayDevice”
}

def selectCapability() {
def pageProperties = [
name: “selectCapability”,
title: “Select Capability of Device”,
nextPage: “selectDevice”,
install: false,
uninstall: true
]

return dynamicPage(pageProperties) {
	section() {
    	input "mycapability", "enum", title: "Which Capability?", metadata:[values:["alarm", "battery", "configuration", "contactSensor", "illuminanceMeasurement", "motionSensor", "polling", "presenceSensor", "relativeHumidityMeasurement", "sensor", "switch", "temperatureMeasurement", "thermostatMode", "threeAxisMeasurement", "waterSensor"]], required: true, multiple: false
	}
}

}

def selectDevice() {
def pageProperties = [
name: “selectDevice”,
title: “Select Device with ${mycapability} Capability”,
nextPage: “displayDevice”,
install: false,
uninstall: true
]

return dynamicPage(pageProperties) {
	section() {
    	input "mydevice", "capability.${mycapability}", title: "Which Device?", required: true, multiple: false
	}
}

}

def displayDevice() {
def pageProperties = [
name: “displayDevice”,
title: “${mydevice.displayName} (${mydevice.name})”,
install: true,
uninstall: false
]

def mydeviceState = ""
def cr = false
mydevice.supportedAttributes.each {
    if (cr) mydeviceState += "\n"
    def myvalue = mydevice.currentValue("$it")
	mydeviceState += "$it: $myvalue"
    cr = true
}

return dynamicPage(pageProperties) {
	section("DeviceID") {
    	paragraph "${mydevice.id}"
	}
	section("Capabilities") {
    	paragraph "${mydevice.capabilities}"
	}
    section("Attributes") {
    	paragraph "$mydeviceState"
    }
    section("Commands") {
    	paragraph "${mydevice.supportedCommands}"
	}
}

}

def installed() {
}

def updated() {
}

3 Likes

Very clever use of the capability.

The API definitely prefers capabilities over devices. Apparently this is the device type name I need:

input "device1", "device.zWaveSwitch", multiple: false        

I just got there through trial and error.

I’ll try to layer in some of your other other features to expand my understanding.

Thank you,
Hugh

1 Like

Paul Spee gets all the credit. My sole contribution was the small section with the device ID :).

Great idea! Thanks for this.

Anyone know how to get this code working to view a new device? I and in the IDE with all of the code loaded and have the device selected in the Simulator but cannot get any commands to work. any help is greatly appreciated.

Charles

This Thread is very old and I don’t know if the code in it still works. But a new device type handler was just contributed to the community recently which exposes all of the Z wave capabilities of a device, so it might be of help. :sunglasses:

JD,
Thanks I always know when I see a reply from you I am getting the best info. That worked like a charm. Thank you again.

1 Like