Based on the SmartThings Schema Interaction Types, may I ask if there is any method to implement deleting device and updating device(friendlyName) through SmartThings Schema Interaction Types?
For example, if I change the name of my device, the device name can also be changes in SmartThings APP. If I delete a device in my APP, the device can also be deleted in SmartThings APP.
I tried to do send the new familyName in discoveryCallback while changing the device name, but It seems not the way I thought to change the device name.
If not, is there any other way?
I tried API(API | SmartThings Developers) and Personal Access Tokens to retrieve deviceID so that I can update certain device label or delete device, but it seems not workable. Because each Personal Access Tokens is corresponding to the user’s Samsung Account. Once the project is published, Other users will have their own accounts. Using API and Personal Access Tokens which is generated from my account cannot find others’ devices.
To delete the device, you need to send the corresponding global error in a stateCallback. Here’s a post where I shared more information about the deletion process:
This cannot be done, the friendlyName parameter is only considered when the device is discovered for the first time. Please, take a look at this post:
That discussion seems to unlink the account or integration instead of deleting a device. What I asked is to initiate deleting a certain device from my side. If that is doable, the callback payload should have externalDeviceId to delete a certain device.
Or like this? Which is modified from device error example here.
Let me make some tests and I’ll get back to you.
Update: @exosite, the team confirmed you can use that error to delete the device from a stateCallback, just remember that, if you send the device again in a discoveryResponse, it will be created:
let deviceState = [
{
externalDeviceId:"device-id",
deviceError:[
{
errorEnum: "DEVICE-DELETED",
detail: "Device deleted by third"
}
]
}
]
const updateRequest = new StateUpdateRequest(process.env.ST_CLIENT_ID, process.env.ST_CLIENT_SECRET);
updateRequest.updateState(accessTokens.callbackUrls, accessTokens.callbackAuthentication, deviceState)
.catch((error)=>{// the request shouldn't be successful as the error causes an exception that will delete the device
console.log("delete success ", error)
})
Hi, @Surabhi_S!
Do you mean when a user deletes the device from the third-party cloud and you need to delete it from the SmartThings side?
If so, you can send from your cloud a device global error called “DEVICE-DELETED” in a State callback. For example: