Using custom device in a Smart App

I am not able to find a solution for this. I have created a device handler modifying the code to the Garage Door simulation. I added a custom command to it to change the state of the device.

I now have a smart app where I want to only add this new device type I created. How do I only add devices of this device type and call my custom command? Coz when add code to look for the capability it shows several device. And I am not sure what will happen if I try calling my custom command on any device.

You have options

  1. Specify the device type on input
    https://docs.smartthings.com/en/latest/smartapp-developers-guide/preferences-and-settings.html#device-specific-inputs

  2. Create the device from the SmartApp
    https://docs.smartthings.com/en/latest/ref-docs/smartapp-ref.html#addchilddevice

1 Like

Thanks for the helps. That works.

Is there an example for the second option?

Yes. Searching the ST classic developer docs (there is search box in the left side bar) for addChildDevice should find a few.