SmartThings solution for remotely controlling smart switches via a web interface.
This solution consists of the following components:
- A SmartThings SmartApp which provides an API to interact with switches controlled by SmartThings.
- An ExpressJS server application which proxies the SmartThings API so that the OAuth2 authentication can be abstracted away from the user.
- An AngularJS web application that provides the actual user interface.
If run with an environment variable FNLLC=1, the app will authenticate with Schedule Master (used by FNLLC for airplane scheduling). It does this through my other project, schedulemaster-api.
To set up, you need to install the SmartApp in a SmartThings environment. The best way to do this is to install from GitHub. General instructions can be found here. You can also install by copying and pasting the code directly into the SmartThings IDE, see instructions here.
The app requires the following environment variables:
Variable | Description |
---|---|
SESSION_SECRET | A secret key for Express sessions |
SM_OAUTH_ID | The client ID for the Schedule Master API |
SM_OAUTH_SECRET | The client secret for the Schedule Master API |
SM_API_URL | The URL for the Schedule Master API |
SMARTAPP_ACCESS_TOKEN | An OAuth2 access token from SmartThings |
SMARTAPP_BASE_URL | The installation endpoint for the SmartThings Smartapp |
TIMER_DEFAULT | Optional time of day to default for timers in the application (Example: TIMER_DEFAULT=7:00AM) |
LOGGLY_TOKEN | Optional token for logging to Loggly |
LOGGLY_SUBDOMAIN | Subdomain for logging to Loggly, required if LOGGLY_TOKEN is provided |
The SmartThings access token and base URL must be obtained from SmartThings using Postman or a similar tool. See the documentation for more information.
To run the web application:
npm install
npm start
To run it with the FNLLC authentication enabled:
npm run start:fnllc