API Documentation?

I found https://graph.api.smartthings.com/ide/documentation but I am looking for specific api functions for ‘switch’.

I am trying to get the current level of a MultiLevelSwitch.

@realsol,

There’s not much to a switch, either on or off. See https://graph.api.smartthings.com/ide/doc/capabilities

Maybe tell us what you’re trying to do or looking for more specifically and we can help.

@realsol - Better API documentation is coming soon. Smartthings just hired some (last couple weeks) dedicated to creating and improving the developer docs.

That said, what are you trying to do? People here may be able to help.

That was fast. I was just editing my original post.

I am trying to get the current level of a MultiLevelSwitch.

@realsol,

switch.latestValue(“level”)

where “switch” is the object

Here’s an app where I’m getting and setting multi level switches:

Twack

Thank you very much. Is there a way that I can tell if it is a standard switch (on/off) or a dimmer?

I edited my last post, should answer your question

I am still getting a nul value (in the simulator). Even tried using a ‘real’ switch I have installed. Here is my code

def appTouch(evt) {

switcheson?.on()
    def level = multilevelswitch?.latestvalue("level")
    log.debug "$level"
    settings.MultilevelSwitch?.setLevel(number)
    lock?.lock()
    unlock?.unlock()
switchesoff?.off()		

}

@realsol,

Post all of the app. How are you enumerating the “multilevelswitch”?

OK. But don’t make too much fun of my as this is code that I am just altering from on of the sample apps.

/**
 *  Scenes
 *
 *  Author: Ryan Nathanson / Modified by Robert Griffin
 */

preferences {
/*		section("When I Change To This Mode") {
		input "newMode", "mode", title: "Mode?", required: false
        
        }*/
	section("Lock these doors") {
		input "lock", "capability.lock", multiple: true, required: false
	}
section("Unlock these doors") {
			input "unlock", "capability.lock", multiple: true, required: false
	}
	section("Dim These Lights") {
	input "MultilevelSwitch", "capability.switchLevel", multiple: true, required: false
	}
    
    
    section("How Bright?"){
     input "number", "number", title: "Percentage, 0-99", required: false
    }

section("Turn On These Switches"){
input "switcheson", "capability.switch", multiple: true, required: false
}

section("Turn Off These Switches"){
input "switchesoff", "capability.switch", multiple: true, required: false
}
}

def installed() {
//subscribe(location)
subscribe(app)

}

def updated() {
unsubscribe()
//subscribe(location)
subscribe(app)

}

def uninstalled() {
unsubscribe()
}

/*def changedLocationMode(evt) {

    switcheson?.on()
//    switchesoff?.off()
        settings.MultilevelSwitch?.setLevel(number)
        lock?.lock()
        unlock?.unlock()
    switchesoff?.off()

}*/

def appTouch(evt) {

    switcheson?.on()
        def level = multilevelswitch?.latestvalue("level")
        log.debug "$level"
        settings.MultilevelSwitch?.setLevel(number)
        lock?.lock()
        unlock?.unlock()
    switchesoff?.off()		
}

Your multilevelswitch is a container not a switch object. You would have to enumerate through them to get each switches’ level.

like:
for switch in multilevelswitch {

log.debug switch.latestvalue(“level”)

}

Maybe look at this app and you’ll understand better.

Got it. I should never start coding at 5am. It was a case issue. I am now getting the correct value. I really appreciate your time on this.

Do you know if there is a way to tell if a switch is a MultilevelSwitch?

@realsol,

Did you look at the links I posted? I answered your question earlier and said to look at the code.

Twack

I sure did. Without you I don’t think I would have had any hair left tonight. It worked out get. This is basically what I am doing:

            def thelatest = switches.latestValue("level")
            log.debug "$thelatest"
            if (switches.latestValue("level") == [99]) {
              log.debug "Using switches.setLevel(99). $thelatest"
              settings.switches.setLevel(99)
            } else {
              log.debug "Using switches.on(). $thelatest"
              switches.on()

This lets my GE Dimmer Switch come on instantly if at full level, and gradually come on if at a dim. Also a regualar on/off switch which is looking for either on or off works great with this code since latestValue(“level”) always returns a null.

Thanks for all of your help. I finally figured out the docs (capability) which will help as I plug along.

Be careful, this stuff is addicting. I used to drink and do drugs. Now it’s smartthings. Crack for geeks! :grin:

Twack