Skip to content

SmartThingsCommunity/smartapp-example-no-devices-nodejs-lambda

Repository files navigation

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 without requiring any accounts or deployments.

Invoke Locally

Test locally using serverless 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 for more event data that conforms to the SmartThings SmartApp API.

Run in AWS

Prerequisites

Deploy

  1. Install the dependencies for this app: npm install.

  2. Follow the instructions to setup AWS credentials for serverless.

  3. Deploy the Lambda function: npx serverless deploy.

  4. Follow the steps to grant SmartThings permission to execute your Lambda function. This is required for successful registration.

Register

Follow the instructions for registering a SmartApp with the SmartThings platform.

  • The following OAuth2 scopes are required.
    • r:locations:*

Test

Follow the instructions for testing a SmartApp.

Once installed, the app should schedule itself to say hello every minute.