https://github.com/smartthingscommunity/smartapp-example-no-devices-nodejs-lambda
Give Lambda SmartApps a try without any physical devices.
https://github.com/smartthingscommunity/smartapp-example-no-devices-nodejs-lambda
aws-lambda smartthings-smartapp-example
Last synced: 12 months ago
JSON representation
Give Lambda SmartApps a try without any physical devices.
- Host: GitHub
- URL: https://github.com/smartthingscommunity/smartapp-example-no-devices-nodejs-lambda
- Owner: SmartThingsCommunity
- License: apache-2.0
- Created: 2021-01-13T19:47:49.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2022-10-17T17:25:58.000Z (over 3 years ago)
- Last Synced: 2025-03-26T02:42:40.314Z (12 months ago)
- Topics: aws-lambda, smartthings-smartapp-example
- Language: JavaScript
- Homepage:
- Size: 196 KB
- Stars: 5
- Watchers: 9
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# Get started with Lambda SmartApps
This example allows you to test a Lambda SmartApp without requiring any physical devices. It can also be invoked locally using [Serverless CLI](https://www.serverless.com/framework/docs/providers/aws/cli-reference/) without requiring any accounts or deployments.
## Invoke Locally
Test locally using [serverless invoke local](https://www.serverless.com/framework/docs/providers/aws/cli-reference/invoke-local/) by passing in example SmartThings event payload data. This will enable you to exercise the various event handlers in the SmartApp without needing to deploy the changes.
### Examples
First, `npm install` to pull in serverless.
#### Installed event handler
`npx serverless invoke local -f smartapp -p payloads/install.json`
#### Scheduled event handler
`npx serverless invoke local -f smartapp -p payloads/schedule.json`
See [payloads](payloads) for more event data that conforms to the SmartThings SmartApp API.
## Run in AWS
### Prerequisites
- An [AWS](https://www.serverless.com/framework/docs/providers/aws/guide/credentials/) account (free tier is fine).
- A [Samsung account](https://account.samsung.com/membership/index.do) and the SmartThings mobile application.
- A [Developer Workspace](https://smartthings.developer.samsung.com/workspace/) account.
### Deploy
1. Install the dependencies for this app: `npm install`.
1. Follow the instructions to [setup AWS credentials](https://www.serverless.com/framework/docs/providers/aws/guide/credentials/) for serverless.
1. Deploy the Lambda function: `npx serverless deploy`.
1. Follow the steps to grant SmartThings [permission to execute your Lambda function](https://smartthings.developer.samsung.com/docs/smartapps/aws-lambda.html). **This is required for successful registration.**
### Register
Follow the instructions for [registering a SmartApp](https://smartthings.developer.samsung.com/docs/smartapps/app-registration.html) with the SmartThings platform.
- The following OAuth2 scopes are required.
- `r:locations:*`
### Test
Follow the instructions for [testing a SmartApp](https://smartthings.developer.samsung.com/docs/testing/how-to-test.html).
Once installed, the app should schedule itself to say hello every minute.