I can't seem to find enough API information

So forgive me if I’m missing the obvious, but I can’t seem to find details about property values and what they do. Maybe it’s specific groovy, but I’ve search google to no end.

For example, lets that the input item. We have name, title, type, required, description, etc that can be set. I’ve only managed to decipher much of this from examples, but where can I find more information about other properties, or values that can be set. What other types are there?

Same question for page and the list goes on. I just can’t seem to find details. Another one I need help with is href on a section. What are the possible states? Can I set to my own html page?

Just would like to be pointed in the right direction.

–Thanks.

1 Like

API documentation has been an issue since ST’s beginnings. My advice is to look at the smart apps others have built that implement what you’re trying to do. Some copy & paste action into your app will help. Honestly, it’s how I learned, aside from looking at the official ST app’s code that rolled out with the system’s start.

1 Like

Thanks. That’s pretty much what I’ve been doing. And it’s painful.

3 Likes

I would also check out the developer documentation.

I have been and are still struggling with this. I have started to document some of this as I go along. If you send me your e-mail address by PM, I will e-mail you a copy.

Welcome to the club! Half of what’s in the docs is not valid and half of API is not documented.

Good luck!

1 Like

Thanks, been there done that. It’s only marginally helpful. It doesn’t seem to be kept up to date. Would be nice if the community was able to edit easily. Perhaps ST would allow some active members to be contributors to the github repo?

ST just hired a full time documentation writer. They announced it on the last developer call last week.

Not writing fast enough :slight_smile:

1 Like

I’d like to add my vote for more documentation. It’s been my biggest hurdle in starting out with Smartthings.

I’m glad to hear a doc writer has been hired.

I undersand wanting to get your product out there, but when you’re selling a product that pitches the ability for people to write their own apps, don’t you think you’d want the documentation ready when the product launches? Sorry if this post seems negative but I’ve been struggling to write my on app as well and have no success without A LOT of help from the community. Needless to say I am frustrated as well.

It’s about time they hired a document writer. This is vital stuff. On the flip-side, given how many apps we’ve all created with the zero or poor documentation, it gives a good example of how easy it can be to write apps for ST. So there is that.

I just started writing my first app this weeked, and at this point I am quite frustrated by exactly the same thing as the OP. I’ve been a professional developer for 15+ years (C, C++, C#, Java), currently doing embedded development in C#.

I’m having the hardest time with the simplest things. Maybe someone can specifically help me with what I want to do: I want to see in code whether a switch is currently on or off:

def currentOn = (switch1 == “on”)
log.debug “$switch1.currentState”

The first statement is never true, and the second statement prints null.

So, how do I get the current state of a switch?

Help would be greatly appreciated. StackOverflow needs a SmartThings section!

Thanks!

Some hacking resulted in switch1.currentSwitch, which seemed to work. I log.debug’ed “$switch1.supportedAttributes” to get “[power, switch]”, combined with the “reference” document currentAttributename. So at least this provides some path forward to investigate the API.

The next question is - I want to flash the light 3 times, with a second or two on/off. The light flashes, but it’s pretty much random what the period is, and whether it finally stays on or off:

if (currentOn) {
switch1.off()
}

    switch1.on()
	switch1.off(delay: 2000)
    switch1.on(delay: 2000)
	switch1.off(delay: 2000)
    switch1.on(delay: 2000)
    switch1.off(delay: 2000)
    
    if (currentOn) {
		switch1.on()
    }

It almost looks like the messages are not arriving in the order I specify. This is running in the simulator with a virtual switch and physical lamp.

You can also use device.currentValue(attribute) where attribute is one of the attributes you identified.

This is from Docs > Reference Material > Class Definitions > Device

if (!device) {
    log.debug "Device not found"
} else {
    log.debug "device attributes ${device.supportedAttributes}"
    log.debug "device switch value ${device.currentValue("switch")}"
}

You can also use device.currentState(attribute) then access one of the properties of the state class. For example:

def state = device.currentState("switch")
log.debug "time: ${state.date} value: ${state.value}"

I believe this documents the device type handler. The documentation for device class can be found here .

I wrote a small Smart App which displays the capabilities, attributes and commands of a selected device. I will post the source on GitHub later.

A good place to get information on your devices is the IDE.

2 Likes

That app is a great idea!

I put the code on GitHub https://github.com/orandasoft/SmartThings.git

1 Like

Does anyone know how to use Cards and the sub-Tiles of Cards - can’t seem to find any documentation on this

Does anyone know the correct syntax and options for the “buttons” input would be nice to be able to fire a process from a click instead of sending the user to a next page just to activate a feature…