Remove all smartapp subscriptions from a device


(CopyCat73) #1

I’m trying to figure out how to remove all subscriptions from a DTH. From my own smartapp I create and delete dth’s, but these may have gotten subscriptions from other smartapps which causes an error when trying to delete them. I dont see any methods in devices to remove subscriptions, do I need to iterate all smartapps and do an unsubscribe(mydth)?


(zraken) #2

Go to each specific device you want to remove from all subscriptions and then select the “SmarApps” tab on the top right. Here you will find a listing of all smart apps that are using this device, you will need to go into each app and remove the device. This is the simplest procedure I’ve found so far.
If you want to do this for all devices using a specific DTH, you will have to visit each device using that DTH and manually remove it from the smart apps listed for each device.
Let’s see if someone else has a better suggestion.


(CopyCat73) #3

I meant from code actually. not by hand.


#4

You’re trying to delete what, the device? The DTH? Or a smartapp?
If you’re trying to delete a device, it doesn’t matter how many apps it’s installed to, you can delete in the phone app.
If you’re trying to delete a DTH in the IDE, you can’t until you have no devices using it. Either remove the devices or assign them to different DTH. Then you can delete the DTH. But you don’t need to do that.
If you’re trying to remove a smartapp, you can do that from the phone app. If you’re trying to totally uninstall it, you can’t do that when you have an instance of it currently running (Aka, installed on your system.)
Now, your question doesn’t make a lot of sense. Smartapps subscribe to devices, not DTHs. Devices use the DTH but you can have multiples devices using the same DTH, not all of them will be talking to each smartapp.
If you are writing your own smartapp, that doesn’t mean that no other smartapps can be subscribed to that device. There are probably many devices that have multiple subscriptions. That’s kind of the point of the system.
You also can’t write code to delete a DTH. It doesn’t work that way.
What exactly are you trying to write a smartapp to do?