SmartThings Community

Subscribing to Virtual Device?


#1

I have virtual devices created by Alexa Virtual Device Creator. I’m not sure how to subscribe to these devices in my SmartApp.
While I can use input to select a virtual device then I get its handle with which I could subscribe to it, I’m looking for a way to subscribe to the device using its name or any other known parameter of it.


(Tony Fleisher) #2

you cannot. The smart app has to be authorized to access the device (via explicit setup in settings) in order for the smart app to access the device object.


(Tony Fleisher) #3

The one exception is devices that were created by this smartapp, which are available via getChildDevice methods.
https://docs.smartthings.com/en/latest/ref-docs/smartapp-ref.html#getchilddevice


#4

So how do I create a virtual device by this smartapp?


(Tony Fleisher) #5

There is a method called addChildDevice for that:
https://docs.smartthings.com/en/latest/ref-docs/smartapp-ref.html#addchilddevice

You should be able to find some examples in the SmartThingsPublic repo.