Go to Body Go to Navigation

SmartApp Basics

You develop a SmartThings SmartApp either to integrate a third-party cloud-to-cloud device into the SmartThings cloud, or to create an automation. You can combine both the automation and the device integration in a single SmartApp, or you can create them in separate SmartApps.

Basic concept

The basic concept of a SmartApp is as follows:

  • The SmartApp can either be an AWS Lambda function, or a WebHook with a RESTful API interface.
  • A WebHook in this context is a web services application, that is, an API endpoint on the internet, which can receive incoming HTTP POST requests. You can write and host your application / API endpoint using the language and the tools of your choice. However, the WebHook must be an HTTPS URL.
  • To publish your application, you must register your WebHook or Lambda function on the SmartThings development portal. See App Registration.
  • Next you will need to implement lifecycle event handlers in your WebHook or Lambda function to complete the integration. And you will also need to implement the event handlers for the device events from the device cloud. See Lifecycles for a comprehensive overview of lifecycles, and SmartApp API reference for the API your SmartApp must implement.
  • When the integration is complete, your SmartApp will begin a lifecycle, and will interact with the SmartThings cloud on a lifecycle phase-basis.

Interaction with the SmartThings cloud

A SmartApp comes to exist when it is successfully registered in the SmartThings cloud, and continues its life until it is uninstalled by the end-user. Throughout its lifecycle, the SmartApp is called by the SmartThings cloud during specific lifecycle phases. The SmartApp, in turn, can call into the SmartThings RESTful API.

For example, consider an automation SmartApp. When the end-user configures the automation to monitor an open/close sensor, the automation subscribes to open/close sensor events. The SmartThings cloud waits on these open/close sensor events. Anytime an open/close event occurs, it is first noticed by the SmartThings cloud, which then calls back the automation SmartApp.

In this way, the SmartThings cloud is constantly listening to the automation-specific lifecycle events generated in the SmartThings cloud, and is making RESTful calls to the automation, always associating each call with a particular lifecycle phase.

Similarly, consider a Cloud-to-Cloud device integration, for example, for a LIFX bulb. With this integration the LIFX bulb will appear in the end-user’s SmartThings app. The end-user can then view and actuate this LIFX bulb from an Automation within the SmartThings app. For example, when the end-user turns on the LIFX bulb in the mobile app, the SmartThings cloud notices this device command, and calls the SmartApp with the device command. The SmartApp then relays this device command to the LIFX cloud, which then sends the on command to the LIFX bulb, and the user’s mobile app is updated.

In addition to the lifecycle event handlers for the SmartThings cloud, a SmartApp can contain other functionality. For example it can interface with a third-party service, or it can define its own user interface.