Looking for very simple examples


(Bobfrankston) #1

Looking for two examples

  • Putting a button on the screen and turn a device on/off when I press it
  • Responding to a Restful API to turn a device on/off

(swanny) #2

For a simple button, I would suggest the “On / Off Button Tile” sample device type that you can find by creating a new Device Type and browsing Device Type Examples from the coding screen.

For the Restful API, I’m assuming you mean for something to make REST calls to SmartThings? If so, this thread has a simple example. Everything else I found was mixed in with a lot of code.

If you mean to call a REST api, the docs look pretty straightforward:
https://graph.api.smartthings.com/ide/doc/deviceType
There are probably some good examples as well, but I haven’t explored that area yet myself.


(Bobfrankston) #3

Thanks – I’m going to continue to go through the documentation to find answers. Following your suggestion I did find “Big Turn Off” but am now trying to figure out how to make it appear as a button in the app and how to actually connect to the device. I look more into the documentation and experiment.

In the case of RESTful – I want to have the app LISTEN so that I can do a web page or an external app that uses HTTP to send commands (and, even better, listen for results). There is an OAUTH associated with the app – here too an appropriate example putting it together would save me a little time.

(Geekier the better, of course)


(Michael) #4

Look in the support knowledge base for example app code for web services. Once you have that setup then you will need to follow these instructions for getting the OAuth tokens:
http://docs.smartthings.com/en/latest/smartapp-web-services-developers-guide/implementation.html

The access token you get will not expire for 50 years or something like that so that is a one time process.