Skip to content

Latest commit

 

History

History
93 lines (78 loc) · 2.38 KB

STEP_2.md

File metadata and controls

93 lines (78 loc) · 2.38 KB

Step 2: Create a device profile

Devices on the SmartThings platform use device profiles to define device features and functionality on the platform.

You will need to create a device profile for your camera device before joining it with the SmartThings platform. In this step, we use the CLI to create a device profile.

Create your device profile

First, we need to create a JSON definition for the device profile. You can find a predefined device profile definition in step_02/sample_files/deviceprofile.json:

{
	"name": "My WebRTC Camera",
	"metadata": {
		"vid": "03e80c0d-afc5-3c58-a66b-e796e4094946",
		"mnmn": "SmartThingsCommunity",
		"ocfDeviceType": "oic.d.camera",
		"stunServer": "stun.st-av.net"
	},
	"components": [
		{
			"label": "main",
			"id": "main",
			"capabilities": [
				{
					"id": "motionSensor",
					"version": 1,
					"ephemeral": false
				},
				{
					"id": "button",
					"version": 1,
					"ephemeral": false
				},
				{
					"id": "webrtc",
					"version": 1,
					"ephemeral": false
				},
				{
					"id": "imageCapture",
					"version": 1,
					"ephemeral": false
				},
				{
					"id": "healthCheck",
					"version": 1,
					"ephemeral": false
				}
			],
			"categories": [
				{
					"name": "Camera",
					"categoryType": "manufacturer"
				}
			]
		}
	]
}

Use the CLI to create a new device profile using the provided JSON:

$ cd step_2/sample_files
$ smartthings deviceprofiles:create -i deviceprofile.json

Record the id of your device profile for use in the next step.

NOTE: The id provided below is for illustrative purposes only. You will receive a unique id after creating your device profile.

{
    "id": "a86c7dbb-4cc3-47b8-894b-d0715490d82a",
    "name": "My WebRTC Camera",
	...
}

Add your device profile to your .env file:

DEVICE_PROFILE=a86c7dbb-4cc3-47b8-894b-d0715490d82a

Create an exported variable in your working directory src/lib/utils.js file with the device profile ID. Replace the text DEVICE_PROFILE_ID_HERE with the device profile ID from the previous step.

module.exports.deviceProfile = () => process.env.DEVICE_PROFILE

After creating your device profile and adding it to your .env file, you are ready to move to step 3