The purpose of this repository is to demo the making of a SmartThings SmartApp. The demo will adjust lighting brightness based on the cloudiness outside and the time of day. The user will be able to determine the greatest brightness level.
- Hallway lighting.
- Kitchen lighting.
- Outdoor lighting.
- Adjust the lighting for seasonal affective disorder.
- A SmartThings compatible color light.
- An OpenWeather account. The free tier will be enough.
- A Samsung account
- The SmartThings mobile application, Android or iOS.
- A SmartThings Developer Workspace account. You can use your Samsung account login for the Developer Workspace.
- A Heroku account if you want to host this project.
- Node.js installed.
- npm installed.
- ngrok installed. Ngrok will create a secure tunnel to the local node server.
- Get an API key from your OpenWeather account.
- Copy the .env.example file to .env in this project's root directory. You can use this command in the root directory of this project:
cp .env.example .env
. ReplaceYOUR_API_KEY_HERE
with your open weather API key. - Run
npm install
to install the project dependencies. - Start the Node.js server
npm run start
. - Start ngrok
ngrok http 3000
. Once started, copy and save the "Forwarding" HTTPS URL. This is the URL used in the Developer Workspace.
- Log in to the Developer Workspace.
- In the Developer Workspace, create a new project.
- Select "Automation for the SmartThings App" as the project type.
- Give the project the desired name.
- Select "Register App" in the created project.
- Choose "WebHook Endpoint" and enter your ngrok HTTPS URL.
- Give your SmartApp a name and description.
- Enable the following OAuth2 scopes under "Permissions required by your connector app."
r:devices:*
x:devices:*
- Save the APP.
- You will not need the Client ID or Secret for this, but you can save it anyways.
- Click on "VERIFY APP REGISTRATION"; this will send a post to your application with a URL in your logs. Copy this URL and visit it in your browser to verify the connection.
- After you have verified your app registration, then click on the "Deploy to Test" button.
More information on:
- Sign in to the SmartThings app on your smartphone.
- Make sure you have a SmartLight added in the SmartThings app.
- IMPORTANT: Enable developer mode in the SmartThings app. Go to the settings menu and hold down on "About SmartThings" for five seconds. After this, you should see an option to enable developer mode. The SmartThings app will need to restart.
- Open the menu in the SmartThings app and go to SmartApps. Click on the plus sign to add a new SmartApp. If you scroll to the bottom, you should see this app listed under the "Custom" section.
- Fill in the information in the prompt, then click "done > allow" and you should be able to see this project in action.
More information on:
- Heroku can host this project.
- Make sure you add the environment variable for the weather API key.
- Use the URL in your Heroku app for your SmartThings SmartApp. The URL is in the Heroku app settings.
- To verify your SmartThings SmartApp with Heroku, follow the logs
heroku logs --tail
.
More information on:
- Enabling developer mode
- SmartApps Basics
- Registering SmartApp
- SmartApp samples
- SmartApp tutorials
- API reference - capabilities
- API reference - SmartApps
- API reference - SmartThings API
- SmartApp Configuration
This SmartApp got inspiration from weather-color-light-smartapp-nodejs. A fantastic SmartApp that adjusts lighting color based on the current weather.