The command in this line of Erick’s sample is the one that creates the device based on the profile you created, you just need to put its ID in the profile property of deviceOpt:
Yes, the SmartApp SDK is based on the Core SDK.
The command of ctx.api.devices.create(deviceOpt) is actually using the create function in devices.ts of the Core SDK, so, the call is different but it should work using the same object as the sample. Something like:
const {SmartThingsClient, BearerTokenAuthenticator} = require('@smartthings/core-sdk')
const client = new SmartThingsClient(new BearerTokenAuthenticator('{YOUR-PAT-TOKEN}'))
let deviceOpt = {
label: deviceLabel,
locationId: locationId,
app: {
profileId: 'xxxx-xxxx-xxx', //A real profile ID
installedAppId: installedAppId //A real installedAppId
}
};
client.devices.create(deviceOpt).then(locations => {
console.log("Device created")
})
However, I’m not sure if using the Core SDK you got an installedAppId because it is needed for the device creation.
About the condition you mention, I believe it will work if all the necessary properties like label, roomId, profileId are the main keys of the JSON object, you can see this based on the references to the values, for example: definition.roomId where definition is the parameter in create()