ST Web Services - Quick Start Help?

So I’m simultaneously learning about Groovy and the SmartThings API (I’m an Asp.Net / c# developer). I’m playing with making a Web Service SmartApp and an ASP.Net web site to consume and control it. I’ve implemented and understand the Web Service sample (article 1) and consuming REST and using OAuth (article 2) is old hat. Now I’m looking to extend my Web Service SmartApp beyond the sample “list” and “update” switches methods. While I keep looking at Groovy language specifications I’m wondering if anyone can get me a jump start on a couple ST concepts:

  1. I understand devices are accessed by capability, but there’s duplication. If I have a dimmer and want to authorize access to it through my service it seems to be available in both capability.switch and capability.switchLevel. Do I even need to authorize capability.switchLevel because I can test for that capability on the device later?

  2. More of a Groovy quick start question (related to Q1) - how would I modify the sample code below if I wanted to include an array of capabilities from device.capabilities for a switch (to see if its a dimmer, or I’m assuming other types of devices support this base capability)?

    def listSwitches() {
    def resp = []
    switches.each {
    resp << [name: it.displayName, id:, value: it.currentValue(“switch”)]
    return resp

  3. In a community topic I read somewhere that the ActiON Dashboard was a good example to look at a ST Web Service app, but it looks like that is now SmartTiles and the source is no longer available. Does anyone have an example of a more feature rich ST Web Service than the docs walkthrough they could point me to? Or is there a lingering copy of the ActiON WS code out there somewhere in the universe?

.1. No. Currently you only need to authorize a Device once. But technically the user could have a Device that is a dimmer, but not a switch…

.3. Search for “ThingLayer” as a good example, still open source.

You can use an expression like the getAllDevices() method in the following code dedupe your list of devices

preferences {
  section("Allow CoolApp to Control These Things...") {
    //SmartThings prefers the use of capability rather than device:
    input "switches", "capability.switch", title: "Which Switches?", multiple: true, required: false
    input "dimmables", "capability.switchLevel", title: "Which Dimmables?", multiple: true, required: false
    input "motions", "capability.motionSensor", title: "Which Motion Sensors?", multiple: true, required: false

//example method 
def listDevices() {
    allDevices.collect {
        //do something with the devices

//method to get all the devices and dedupe them
private getAllDevices() {
    ([] + switches + dimmables + motions)?.findAll()?.unique { }