Weather light

This Automation is a webhook that sets the color of a light based on the weather.

This sample demonstrates:

  • Automation registration in Developer Workspace.
  • HTTP Signature verification to ensure that incoming requests are from SmartThings.
  • Integrating with a third-party API (Weather API).
  • Actuating 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.
  • A Samsung account and the SmartThings app on iOS or Android.
  • A SmartThings-compatible color bulb, such as SYLVANIA Smart RGBW or LIFX, or Philips Hue.

Initial setup

Clone the GitHub repository.

Create an API key with Open Weather Map (free tier is fine), and store it in an environment variable named WEATHER_API_KEY.

Open your project file in a terminal and install the dependencies for this application:

npm install

Then start the server:

npm start

Open another terminal window to start ngrok. This is to create a secure tunnel for a globally available URL for testing.

ngrok http 3005

Copy the https: URL to your clipboard.

Register an Automation

Go to Developer Workspace to register a new Automation.

Refer to the documentation for a description of the required fields.

  • Select a webhook and enter the https: URL you copied earlier.
  • Add the following scopes to your Automation. These allow your Automation to read and execute to all available devices. Read more about OAuth scopes.
    • r:devices:*
    • x:devices:*

Save these settings to deploy your Automation for testing.

The next screen displays your Public Key. Copy this public key and replace the contents of the file config/ with it.

Stop the npm server with CTRL-C and restart:

npm start

Test the Automation

Open your SmartThings app and enable Developer Mode.

After restarting the SmartThings app, go to the Automations tab and tap ADD AUTOMATION. You can now see and install your Automation. Enter the required inputs on the configuration screens.

Once installed, the configured bulb will turn on.

Depending on the weather forecast, its color will be purple (precipitation), orange (temperatures above 80 degrees Fahrenheit), blue (temperatures below 50 degrees Fahrenheit), or white (no precipitation and temperature between 50 and 80 degrees Fahrenheit).

The Automation will check the current weather at the interval set during installation.


When installing the Automation in the SmartThings app, you may get the following error:

Something went wrong. Please try to install the SmartApp again

You may not have restarted the npm server as specified above. If this is the case, you will also see this error in the npm server terminal:

forbidden - failed verifySignature

Make sure to restart the npm server.

What's next