//Create a class for switch device package Switch import SmartThing.SmartThing public class Switch extends SmartThing { // id, label, and display name of the device String id String label String displayName // Maps from features to values HashMap deviceValuesMap = new HashMap() // Possible values for eventsSince method List possibleValues = new ArrayList(); Switch(Closure sendEvent, String id, String label, String displayName, String currentSwitch) { deviceValueSmartThing = deviceValuesMap idSmartThing = id labelSmartThing = label displayNameSmartThing = displayName sendEventSmartThings = sendEvent possibleValuesSmartThings = possibleValues // Initialization this.id = id this.label = label this.displayName = displayName possibleValues.add("on") possibleValues.add("off") deviceValuesMap.put("switch", currentSwitch) } // Methods to set values def on() { action("on", "switch") } def on(LinkedHashMap metaData) { on() } def off() { action("off", "switch") } def off(LinkedHashMap metaData) { off() } }