Create a new Automation

Automations allow a user to control their SmartThings ecosystem without manual intervention. An example of an Automation is a WebHook or AWS Lambda function that uses the SmartThings REST API to control and get status notifications from SmartThings devices.


This article demonstrates how to create an Automation that sets the color of a light based on the weather in a given zip code. This Automation is a WebHook SmartApp.

We will cover:

  • 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 npn installed (verified with npm version 4.0.5 and Node 7.4.0).
  • ngrok installed to create a secure tunnel for a globally available URL for fast testing.
  • Docker for running Redis. Alternatively, install and run Redis manually.
  • A Samsung account and the SmartThings app.
  • A SmartThings-compatible color bulb, such as SYLVANIA Smart RGBW, LIFX, or Philips Hue.

Step 1. Download the sample code

  1. Download the Weather Color Light SmartApp on GitHub.
  2. 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. Run 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

  1. Follow the steps to create an Automation in Developer Workspace.
  2. Set the SmartApp information for the Automation.

    • For the SmartApp type select WebHook endpoint and enter the https: URL you copied from Step 2.
    • For the Scope, click Add and select the following scopes:
      • r:devices:*
      • x:devices:*

    SmartApp Info1

  3. Click SAVE.
  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/ with it.
  6. Click SELF-PUBLISH 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

Test your light bulb in the SmartThings app.

  1. Make sure you enable the Developer Mode.
  2. Go to the 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 installing 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 above. If you did not restart the npm server, you will see this error in the npm server terminal: 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