# Cloud Connected Device Tutorial

**URL:** <https://community.smartthings.com/t/cloud-connected-device-tutorial/222280>\
**Category:** Tutorials\
**Created:** [March 8, 2021, 9:17pm UTC](https://community.smartthings.com/t/cloud-connected-device-tutorial/222280 "2021-03-08T21:17:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jody.albritton](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/jody.albritton/32/220661_2.png) [@jody.albritton](https://community.smartthings.com/u/jody.albritton)\
**Post date:** [March 8, 2021, 9:17pm UTC](https://community.smartthings.com/t/cloud-connected-device-tutorial/222280/1 "2021-03-08T21:17:15Z")

</div>

[In February](https://community.smartthings.com/t/endpoint-smartapps-with-file-store-contexts/219761), we showed you how to automate a light based on your Zoom status with an Endpoint SmartApp. This month, let’s look at how to do this using a Schema Device.

We will be creating a Schema SmartApp to automatically build a cloud connected device with custom capabilities. This will represent our meeting status and allow Rules to react to updates.

**Account Prerequisites**

AWS Serverless Account  
AWS IAM Credentials  
Samsung Account  
Zoom Developer Account

**Software Prerequisites**

Install Serverless CLI

`npm -g install serverless`

Install SmartThings CLI

`npm -g install @smartthings/cli`

Clone example repo

`git clone https://github.com/SmartThingsDevelopers/zoom-connect.git `

## Preparation

### Custom Capabilities

Follow instructions here:

> [@Custom Capability and CLI Developer Preview](https://community.smartthings.com/t/custom-capability-and-cli-developer-preview/197296):
>
> Overview At SmartThings we want to provide tooling to allow developers to get their device integrations working in the SmartThings app. These changes will allow an integrator to move from using custom commands and attributes to custom capabilities. DTH Migration For Custom Capabilities In order to follow along with the example set forth in this guide, you will want to have the CLI set up, so make sure that you take this step first. You can download the CLI here from the [releases tab](https://github.com/SmartThingsCommunity/smartthings-cli/releases) and read more about it in the [README](https://github.com/SmartThingsCommunity/smartthings-cli/blob/master/packages/cli/README.md). It is also recommended that you familiarize yourself with the concepts: [Custom Capabilities](https://developer.smartthings.com/docs/devices/capabilities/custom-capabilities)[Capability Presentations](https://developer.smartthings.com/docs/devices/capabilities/capability-presentations)Walkthrough We are going to walk through a simple example of updating our Device Type Handler (DTH) so that devices installed with the DTH will be …

The custom capability files can be found in the definitions folder of the project.

Use the information obtained from your Serverless account and update serverless.yml

```auto

org: your-serverless-org-here

service: your-serverless-service-name

```

Use the information obtained from the developer Workspace and update serverless.yml

```auto

myEnvironment:

DEVICE_PROFILE_ID:

dev: your-device-profile-id

```

Ensure that the AWS IAM ID and SECRET are stored and accessible to the environment you are working on. Enter the following command in the terminal while inside the folder of the project.

You can either use a certificate or set these at run time. On Mac/Linux you can use

```auto

$ export AWS_ACCESS_KEY_ID=YOUR_ID_HERE

```

```auto

$ export AWS_SECRET_ACCESS_KEY=YOUR_KEY_HERE

```

Once everything is configured properly, run the deploy command.

```auto

$ serverless deploy --stage dev --region us-east-1

```

### Provide permission to SmartThings

Next, you will need to grant SmartThings permission to execute this Lambda function. There are two ways you can grant permissions; only one method is required.

### Register your Lambda function with SmartThings

Before you register your SmartApp, make a note of the ARN for your Lambda function. You can find the ARN of your Lambda function from the Lambda function page on your AWS console. Read more about ARNs on [Amazon’s documentation](https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html).

In the Developer Workspace create a SmartApp using AWS Lambda and Serverless

[https://smartthings.developer.samsung.com/workspace/projects/new](https://smartthings.developer.samsung.com/workspace/projects/new)

 ![](https://global.discourse-cdn.com/smartthings/original/3X/3/4/34d42ae7f1385f6c9f13f4bd681daee9bf94e431.png)

 ![](https://global.discourse-cdn.com/smartthings/original/3X/1/9/19f10d026a4bd7e5a4b82c47b4c2595b9be32287.png)

 ![](https://global.discourse-cdn.com/smartthings/original/3X/4/9/49d8a1060b71996cebd1f2de61c8983718892800.png)

### Zoom Oauth Registration

Note your APP ID, Client ID, and Client Secret  
Create a user level OAuth App using the Zoom Developer’s portal.

1. On the App Credentials screen enter [SmartThings](https://api.smartthings.com/oauth/callback) for “Redirect URL for OAuth”

2. Features Page: Enable event subscriptions, select presence event types, and subscribe to user presence events.

Finish the wizard and head back to your code editor.

We will make some changes to the environment variables here

[code block]

Re-run the deploy command for the Serverless app.

```auto

$ serverless deploy --stage dev --region us-east-1

```

Once complete, you should have the SmartApp ready to deploy to test. With Developer Mode enabled the new application will be present under “My Apps” in the SmartThings mobile client.
