Schema Devices and Custom Capabilities

Creating custom capabilties for schema devices

Using the SmartThings CLI and Developer Workspace

We are going to create a Cloud Connected Device using Schema and webhooks. Our base device will be a basic switch.

The first part of this tutorial will cover create the connector, oAuth server, and adding the Switch to SmartThings. The second part of the tutorial will cover adding a custom capability to this new device.

Prerequisites:

  • Samsung Account
  • Developer Workspace Access
  • Developer Mode Enabled
  • Glitch Account
  • Text File

Step 1: Remix this Glitch account (connector)

  1. Set the values in the .env file using .env-example as a guide.

  2. Once the remixed app is up and running copy its URL to your text file.

  3. Register the webhook url in SmartThings Developer Workspace and deploy it for testing.

Step 2: Remix this Glitch account (OAuth)

  1. Edit the .env file to set your own client ID and secret, for example:
  EXPECTED_CLIENT_ID="somerandomvalueyouchoose"
  EXPECTED_CLIENT_SECRET="anotherrandomvalueyouchoose"
  AUTH_REQUEST_PATH="/oauth/login"
  ACCESS_TOKEN_REQUEST_PATH="/oauth/token"

Step 3: Run each of your newly remixed apps in their own browser window.

You should now have three browser windows open.

  1. Developer Workspace
  2. Remixed Connector
  3. Remixed oAuth Server

Step 4: Register in the developer workspace

Name your Connector

Click Register App In the Cloud Connector Box

Click Webhook Endpoint

Enter your connector URL

Click Next

Now Move to the oAuth app tab from Step 2.

Create a Client ID and Secret in the .env file

Back in the workspace these are the ID and Secret you will use in the form.

"Client ID" = the client ID you created in step two
"Client Secret" = the client secret you created in step two
"Authorization URI" = your-glitch-project.glitch.me/oauth/login
"Token URI" =  your-glitch-project.glitch.me/oauth/token

Click Next

Edit your catalog entry. NOTE your image must be 240x240px

Click Next

WARNING - You need to copy the values from the screen

Edit the .env file for your connector app, using the copy button from this screen and copy the Client ID and Client Secret to their fields.

Click Go To Project Overview
Click Deploy to Test
Click Got It

Step 5: Create Your Starter Device Profile

Choose Option 2

Add a Device Profile

Create a new one

On this screen

Give your profile a name and description

Select “Switch” for the Device Type

Enter a random string for the Vendor ID

Click Add Capability

Find the Switch Capability, click add and close the window.

Click Next

Set the State to “Switch”
Set the Action to “Switch”

Click Create Device Profile

On the following screen copy your “Device Profile ID”

Step 6: Edit your connector.js file on the connector app tab

Step 7: Confirm that you can install this device in your mobile app

Put the SmartThings mobile app in developer mode and tap the “+” button at the top to add a device. Scroll down to My Testing Devices tap on it, and select your connector. Complete the OAuth login process and return to the Devices page. You will be prompted to complete the integration and your device will be added to the room.

4 Likes

@jody.albritton been waiting for this all summer, so pretty excited! I see you mention “part 2” in the opening of this post, but I can’t find it anywhere. Is it still forthcoming?

1 Like

Coming this week. Were you able to create a device successfully using the above tutorial and can you provide any feedback, positive or negative? Thanks!

1 Like

Jody I didn’t follow the specific instructions above because I already have a C2C connector setup on AWS using previous documentation/tutorials. And I’ve previously used the Developer Workspace to create custom Device Profiles. My issue is that my devices can’t quite be modeled right with the built-in capabilities. I was wondering if I could follow the other tutorial and use the new CLI to create custom capabilities and then maybe they would appear in Developer Workspace for use? I ran out of time to explore that this weekend.

Can’t wait for part 2!

Is it coming out soon?

Thanks for your help Jody.

Mobile app release triggered a regression. Fix is currently in QA/Internal testing and should be released to the public in the next two weeks. We are working hard to get custom capabilities to everyone using the new app with custom devices.

2 Likes

Ah ok, it is not just a matter of not knowing how to add custom capabilities, they are not available yet.

I’ll stop searching then!

Thanks