This sample demonstrates a simple Java server using Spring Boot.
- Java 1.8+
- SmartThings developer account
- Amazon Web Services account
Execute the following command from the project root directory:
./gradlew examples:java-springboot-smartapp:bootRun
Note: it is necessary for the application to be running before you create the SmartApp in the developer console. You will need to restart once configured.
Follow these steps using the developer workspace:
-
Install the AWS CLI.
-
Configure the CLI to use your account.
-
Create a user with DynamoDB permissions.
- Find "My Security Credentials" under your account settings.
- Click on "Users" and then "Add User".
- Give the user a name like "DynamoDB", choose "programmatic" access for the access type and click "Next".
- Choose "Attach existing policies directly", find and add "AmazonDynamoDBFullAccess" and click "Next".
- Click "Next" on the tags page.
- Click "Create User".
- Copy and save both the key id and the key secret.
-
Run
aws configure
and populate as follows:Option Value AWS Access Key ID id from above AWS Secret Access Key secret from above Default region name choose an AWS region geographically close to your end-user's location Default output format enter 'json' here
-
-
Create a new project and choose "Automation for the SmartThings App".
-
Give your project a unique name.
-
Choose "Automation Connector | SmartApp" under "Develop" in the left-hand menu.
-
Choose "WebHook Endpoint" and enter the URL of your endpoint and click "Next".
-
Select the
r:devices:*
andx:devices:*
scopes and click "Next". -
Give your application a name and hit "Save". Note that at this point, you will need to have the application running. (See Build and Run above.)
-
Save the public key created to a file called
smartthings_rsa.pub
in thesrc/main/resources
directory. -
In
src/main/resources
, copyapplication.yml.example
toapplication.yml
and update the client id and client secret with values from your newly created smartapp. If the secret is hidden, hit "regenerate" to get a new client id and client secret. -
Save the new project and click the "Deploy to Test" button.
-
Restart your server (see Build and Run above). (This is necessary because we added the configuration options above.)
First, be sure to enable developer mode in your SmartThings application to see the self-published automation.
Now you should see your SmartApp listed (near the bottom) when you add a new Automation.
If you are not familiar with SmartThings, we have extensive on-line documentation.
To create and manage your services and devices on SmartThings, create an account in the developer workspace.
The SmartThings Community is a good place share and ask questions.
There is also a SmartThings reddit community where you can read and share information.
Licensed under the Apache License, Version 2.0
Copyright 2019 SmartThings, Inc.