Multiple Instance of Switch Capability

Hi SmartThings Support Team,

I am having difficulty finding in your documentation on how I can create multiple instance of switch in one device handler.

Base on the documentation, the switch has predefined functions “on()” and “off()”. Would it be possible to create another instance like “on2” and “off2”?

Regards,
Jonathan

You can create custom commands to do that but that is not the typical way that you would create a device that has multiple switches. Because that command won’t be recognized by built-in SmartThings apps. The way this is typically handled is by creating a driver that uses the Parent/Child relationship. You have a parent device which handles the actual communication with the device and then one child device for each switch instance you want. That way, if the device has two independent switches, you get two devices in SmartThings to control.

1 Like

Hi Ryan,

Thanks for the hint I have created a custom command, and it works.
The way I call the custom command not by “switch.customCommand”, but I call it directly “customCommand” inside the actions.

By the way I have been developing a device that has multiple capabilities and multiple set of switch. Do you think that I will be having some roadblocks ahead?

Yes. Without creating child devices this will not integrate easily with SmartThings Apps. There is only one switch attribute allowable per device. So, you will not be able to tell which of the switches are on and which are off. I would use the parent/child method.

1 Like