Hosting with AWS Lambda

You can develop a SmartThings SmartApp as an AWS Lambda function. This requires that you grant SmartThings the permission to execute your Lambda function. You must also register your Lambda function with SmartThings as a SmartApp to be integrated into SmartThings.

Follow the steps below:

Deploy your Lambda function

Ensure that you deployed your Lambda function on AWS properly. You may refer to Apex tool for this task.

To confirm that your Lambda function is deployed properly, login to your AWS console, and go to Lambda under Services and you should see your function listed.

Provide permission to SmartThings

Next, you will need to grant SmartThings the permission to execute this Lambda function. Execute the below AWS command on a terminal shell:

aws lambda add-permission --profile  --function-name  --statement-id smartthings --principal  --action lambda:InvokeFunction
  • where is your named profile as stored in your AWS config file. See here for more information.
  • is the name of your Lambda function in AWS. This is the same as the value of the environment variable LAMBDA_FUNCTION_NAME. You can locate this environment variable on your Lambda function page of your AWS console.
  • is the account id to which you are granting the permission to execute your Lambda function. Use 906037444270 for SmartApp and 148790070172 for SmartThings Schema.

NOTE

To confirm that the permission is properly granted to the SmartThings account, navigate to the Lambda function page on your AWS console, click the Triggers tab, and click the View function policy down arrow. This will display JSON description showing that SmartThings can now invoke your function.

Register Lambda function with SmartThings

Ensure you have a SmartThings account

  • First, make sure you have a Samsung account. Visit this link to create an account if you do not have it.

Make a note of the ARN

  • From the Lambda function page on your AWS console, make a note of the ARN for your Lambda function. See here for more on ARNs.
  • For example, for the above Lambda function testuseast1_openlighton the ARN is arn:aws:lambda:us-east-1:123456789000:function:testuseast1_openlighton.

Register your Lambda

  • On SmartThings Developer Workspace specify the above-noted ARN while registering your Lambda function as a SmartApp. Make sure to select the LAMBDA option.

AWS regions and SmartThings Locations

When an end-user installs a SmartApp, it is always installed at the end-user’s Location. If that SmartApp is a Lambda function, then the AWS region where this Lambda function is deployed becomes important. For better execution latency of your SmartApp, you should deploy your Lambda function on an AWS region that is geographically closer to the end-user’s Location.