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.

Prerequisites

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 Redismanually.

A Samsung account and the SmartThings app (currently available for Android).

A SmartThings-compatible color bulb, such as SYLVANIA Smart RGBW, LIFX, or Philips Hue.

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.

Troubleshooting

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.

Credits

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: