//Create a class for relay switch device package RelaySwitch import SmartThing.SmartThings public class RelaySwitches extends SmartThings { List relaySwitches = new ArrayList() RelaySwitches(Closure sendEvent, boolean init) { // Only initialize one time since we only have one device for each capability relaySwitches = smartThings // Initialization StringBuilder id = new StringBuilder("relaySwitchID0") StringBuilder label = new StringBuilder("relaySwitch") StringBuilder displayName = new StringBuilder("relaySwitch0") StringBuilder currentSwitch = new StringBuilder() if (init) currentSwitch.append("off") else currentSwitch.append("on") relaySwitches.add(new RelaySwitch(sendEvent, id, label, displayName, currentSwitch)) } // Methods to set values def on() { relaySwitches[0].on() } def on(LinkedHashMap metaData) { on() } def off() { relaySwitches[0].off() } def off(LinkedHashMap metaData) { off() } // Methods to return values def getCurrentSwitch() { List tmpValues = new ArrayList() tmpValues.add(relaySwitches[0].getCurrentSwitch()) return tmpValues } }