//Create a class for switch device package Switch import SmartThing.SmartThings public class Switches extends SmartThings { List switches = new ArrayList() Switches(Closure sendEvent, boolean init) { switches = smartThings // Initialization StringBuilder id = new StringBuilder("switchID0") StringBuilder label = new StringBuilder("switch") StringBuilder displayName = new StringBuilder("switch0") StringBuilder currentSwitch = new StringBuilder() if (init) currentSwitch.append("off") else currentSwitch.append("on") switches.add(new Switch(sendEvent, id, label, displayName, currentSwitch)) } // Methods to set values def on() { switches[0].on() } def on(LinkedHashMap metaData) { on() } def off() { switches[0].off() } def off(LinkedHashMap metaData) { off() } // Methods to return values def getCurrentSwitch() { List tmpValues = new ArrayList() tmpValues.add(switches[0].getCurrentSwitch()) return tmpValues } }