I’m trying to predefine that all switch type will be selected for an app I’m coding.

I would like to know whether the defaultValue can work. And if so, how I can make it work


You can’t use defaultValue for a device you want to select. Only the user can select devices during the installation of the app. This is a security mechanism.

You lock it down to a single devicetype

capability.capabilityName can be swaped for device.deviceTypeName

If you need a example check out PlantLink-DirectMonitor.groovy or ThinkingCleanerer.groovy

Thanks for the advice, the issue is that not all switches are using the same device type (have 3 different ones)!


That’s the beauty of Capabilities. They are Device Type independent. All light switches, outlets, and light bulbs support a capability of “Switch”, for example. So a smart app simply needs to look for devices that support the switch capability.