C2C Integration - Device Profile creation via SmartThings API

I am using st-schema-nodejs for cloud connected device integration.
I create device profile for a device (say switch) and added device by sending profileId as part of discovery response.

On SmartThings App, I am able to see the device but not able to select to do any controls.
On further probing, i found the below popup on developer workspace.

Is there a way to add the device profile to project programmatically (via APIs or other means)?
I want to avoid to login to workspace and add the device profile to project manually.

Please help.

@AlejandroPadilla

Hi @prakash_m it sounds more like a problem related to the initial values of the device, you can use any device profile created on Workspace, SmartThings CLI or API.

Did you receive an interaction result related to it?

Please see the request and response i received for creating profile, i am not able to find what is missing.

I followed the documentation from here API | Developer Documentation | SmartThings.

All i want is to avoid logging into workspace and manually click “ADD DEVICE PROFILE TO PROJECT”.
Without adding device profile to project, i am not able to select & control the device (although it lists) from SmartThings App.

It is not necessary to add the device profile to your project if you want to test it, as I previously mentioned, it seems to be a problem related to the initial values of the devices

Note: It will be necessary in the process to certify your integration It also needs to start from Developer Workspace

I don’t understand the problem related to initial values of the device, can you be more specific?

There seem to be no Issue in creating device profile via API, account linking, discovering devices everything works fine. Issue is only in controlling devices, devices just get listed in SmartThings App and does not present options to control. Nothing happens when clicked on a device on SmartThings App and there seem no request being sent to our cloud.

Just by adding device profile to Project, able to control device from SmartThings App, absolutely no other changes in our cloud or else where.

Some more information for the profile json (created via API), just a comparison before and after adding the profile to project, in case if it can help.

// BEFORE clicking add profile to project

{
“id”: “59280b3e-88c9-483f-881c-66c883fdb37b”,
“name”: “switch new psotman”,
“metadata”: {
“deviceType”: “Switch”,
“deviceTypeId”: “Switch”
},
“migrationStatus”: “NOT_MIGRATED”,
“status”: “DEVELOPMENT”,
“preferences”: ,
“components”: [
{
“label”: “main”,
“id”: “main”,
“capabilities”: [
{
“id”: “motionSensor”,
“version”: 1,
“ephemeral”: false
}
],
“categories”: [
{
“name”: “Switch”,
“categoryType”: “manufacturer”
}
]
}
],
“owner”: {
“ownerType”: “USER”,
“ownerId”: “f408a6e2-5bb9-839f-1ecc-c78d5ebfd1a1”
}
}

// AFTER clicking add profile to project

{
“id”: “59280b3e-88c9-483f-881c-66c883fdb37b”,
“name”: “switch new psotman”,
“metadata”: {
“deviceType”: “Switch”,
“vid”: “ST_a655de55-bce1-44c8-b4b7-6a5349276c1a”,
“mnmn”: “fwtu”,
“ocfDeviceType”: “oic.d.switch”,
“deviceTypeId”: “Switch”,
“ocfSpecVer”: “core 1.1.0”,
“mnid”: “fwtu”,
“mnId”: “fwtu”
},
“migrationStatus”: “NOT_MIGRATED”,
“status”: “DEVELOPMENT”,
“preferences”: ,
“components”: [
{
“label”: “main”,
“id”: “main”,
“capabilities”: [
{
“id”: “motionSensor”,
“version”: 1,
“ephemeral”: false
}
],
“categories”:
}
],
“owner”: {
“ownerType”: “USER”,
“ownerId”: “f408a6e2-5bb9-839f-1ecc-c78d5ebfd1a1”
}
}

I am exploring the possibility for a cloud platform to create device profiles programmatically and start using them seamlessly.

@AlejandroPadilla @nayelyz

@prakash_m sorry for the delay I was doing some tests to check the behavior, for the problem you describe the problem can be related to the initial values I’m referring to the values that are assigned on the stateRefreshHandler for the different capabilities, or it could also be related with a problem related with the presentation.

The first device profile doesn’t have the VID that is related to the device profile presentation. So, that is likely the cause of the problem you’re experiencing on the app. It is most likely that when you click the option on Workspace, it triggers the creation of a presentation

I tested all three options: CLI, Workspace, and Postman. The result for the first two is that the presentation was created, but for the API, it was not. For more information presentation API documentation

@AlejandroPadilla I did spend some time to try & figure out the list of API and the sequence it has to be called but no luck.
I tried the below APIs

  1. Create device profile => https://api.smartthings.com/v1/deviceprofiles
  2. Generate device config => https://api.smartthings.com/v1/presentation/types/{typeIntegrationId}/deviceconfig
  3. Create device config => https://api.smartthings.com/v1/presentation/deviceconfig

The same behavior as described earlier.
Can you please help me the set of APIs to be called if in some sequence and the fields that are mandatory in the payload?

@prakash_m Sure, the error in your steps is that after creating the device config, you forgot to update your device profile. So, the correct steps are:

1- Create a device profile → API documentation
2- Create the device config → API documentation
3- Update the device profile → API documentation

Example of the last point:

{
    "id": "ed3e53a1-ef5e-4d7f-86fa-cd30da196025",
    "name": "ThermostatProfile",
    "metadata": {
        "vid": "ST_98314275-0bc0-466f-940b-07b6487cb945",
        "deviceType": "Thermostat",
        "mnmn": "0AJJ"
    },
    "status": "DEVELOPMENT",
    "components": [
        {
            "label": "main",
            "id": "main",
            "capabilities": [
                {
                    "id": "temperatureMeasurement",
                    "version": 1,
                    "ephemeral": false
                },
                {
                    "id": "thermostatMode",
                    "version": 1,
                    "ephemeral": false
                },
                {
                    "id": "refresh",
                    "version": 1,
                    "ephemeral": false
                }
            ],
            "categories": []
        }
    ]
}

As you can notice we added the vid on this point

1 Like