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
  • where <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 906037444270 for SmartApp and 148790070172 for SmartThings Schema.

Register Lambda function with SmartThings

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. Read 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

From the project creation page on Developer Workspace, select Automation.

  • Name your Automation and click CREATE PROJECT.
  • In the Develop menu, click Automation to register your Automation. The Hosting tab will open.
  • Select the AWS Lambda hosting type.
    • Enter the Target ARN you located above.
  • Click Next to open the App Scope tab.
  • Select the OAuth2 scopes required for the device cloud to communicate with SmartThings Cloud.
  • Click Next to open the App Settings tab.
  • Enter an Automation Display Name to be shown in the SmartThings app.
  • Select whether you will allow single or multiple SmartApp Instances.
    • Multiple instances allows users to install this SmartApp more than once, with different configurations in the same location.
    • Single instance allows users to install this SmartApp once, using a single configuration in one location.
  • Add any Custom Parameters used in your SmartApp code.
  • Click SAVE.

After saving the above information, you can return to the Automation page to access the public key, client ID, and client secret for this SmartApp.

SmartApp Connector info

See also