//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 String id = "switchID0" String label = "switch" String displayName = "switch" String currentSwitch if (init) currentSwitch = "off" else currentSwitch = "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() } }