Go to Body Go to Navigation

Create a new Automation

Automations use a RESTful SmartThings API to automatically control and get status notifications from IoT devices. An Automation can be a WebHook or an AWS Lambda function, developed in the language of your choice and hosted wherever you prefer.


We will guide you through the steps to create your first Automation SmartApp. This Automation will set the color of a light based on the weather in a given zip code area.

This is a WebHook SmartApp. It demonstrates the use of the new SmartThings API for Automations, and showcases the following:

  • SmartApp installation and configuration flow.
  • HTTP Signature verification to ensure that the incoming requests are from SmartThings.
  • Integrating with a third-party API (Weather API, in this case).
  • Actuating the devices using the SmartThings API.
  • Creating schedules and handling scheduled executions.


  • Node.js and npm installed (verified with npm version 4.0.5 and Node 7.4.0).
  • ngrok installed to create a secure tunnel to create a globally available URL for fast testing.
  • A Samsung account and the SmartThings app.
  • A SmartThings-compatible color bulb, such as SYLVANIA Smart RGBW or LIFX, or Philips Hue.
  • Make sure you open an account (it is free) on Developer Workspace.


If you are using an Android phone, then you can use the SmartThings app. Support for the SmartThings app on iPhone will be available soon.

Step 1. Download the sample code

  1. Download the code for Weather Color Light SmartApp from this GitHub repository.
  2. To use the code for Weather Color Light SmartApp, create an API key with Open Weather Map (free tier is fine), and store it in an environment variable named WEATHER_API_KEY.

Step 2. Start your WebHook service

  1. Install the dependencies for this app: npm install.
  2. Start the server: npm start.
  3. Start ngrok (in another terminal window/tab): ngrok http 3005. Copy the https: URL to your clipboard.

Step 3. Create a new Automation

For more information on creating a new Automation, see here.

  1. Go to the Automation section of the Developer Workspace.
  2. Define the SmartApp Info.

    • For the SmartApp Type select WebHook endpoint and enter the https URL you copied from the above step.
    • For the Scope, click on Settings and select the following scopes:

      • r:devices:*,
      • x:devices:*,
      • r:schedules, and
      • w:schedules

      SmartApp Info1

  3. Click SAVE AND NEXT.
  4. In the next screen you will be presented with the Public Key.
  5. Copy this public key and replace the contents of the file config/smartthings_rsa.pub with it.
  6. Click CONFIRM to register your automation in self-publishing mode.

Step 4. Restart your WebHook service

  1. Stop the npm server: CTRL-C.
  2. Start the server again: npm start (this ensures that the public key will be used to verify requests from SmartThings).

Step 5. Test your Automation

  1. If you are on an Android phone, then use the SmartThings app. Make sure you enable the Developer Mode.
  2. Go to Automations tab and add your Automation. After a moment you will see the Example Weather Color Light app. Tap on it to install it.
  3. Enter all the required inputs on the configuration screens.
  4. Once installed, the configured bulb will turn on and its color will be either:
    • Purple (if precipitation is in the forecast),
    • Orange (if the forecast calls for temperatures above 80 degrees Fahrenheit),
    • Blue (if the forecast calls for temperatures below 50 degrees Fahrenheit), or
    • White (if no precipitation and temperature between 50 and 80 degrees Fahrenheit). The app will check the current weather at the interval set during installation.


  • When you try to install the SmartApp, if you get the error Something went wrong. Please try to install the SmartApp again, then:
    • Make sure you restart the npm server as specified in Step 4-2 above. If you did not restart the npm server, in the npm server terminal you will see this error: forbidden - failed verifySignature.


The concept of a SmartThings-connected color bulb that changes its color based upon weather or other environmental data is not new or original to this example. The SmartThings Community has created several similar solutions, including:

More Information