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 <my-profile-name> --function-name <my-function-name> --statement-id smartthings --principal <PRINCIPAL ID FROM SMARTTHINGS> --action lambda:InvokeFunction
<my-profile-name>is your named profile as stored in your AWS config file. See here for more information.
<my-function-name>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.
<PRINCIPAL ID FROM SMARTTHINGS>is the account id to which you are granting the permission to execute your Lambda function. Use
906037444270for SmartApp and
148790070172for SmartThings Schema.
Register Lambda function with SmartThings
Ensure you have a SmartThings account
- First, make sure you have a Samsung account. Click Log in on the top of this page 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_openlightonthe ARN is
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.