//Create a class for switch level package SwitchLevel import SmartThing.SmartThings //Importing mutable integer class import MutableInteger.MutableInteger public class SwitchLevels extends SmartThings { List switchLevels = new ArrayList() SwitchLevels(Closure sendEvent, boolean init) { // Only initialize one time since we only have one device for each capability switchLevels = smartThings // Initialization StringBuilder id = new StringBuilder("switchLevelID0") StringBuilder label = new StringBuilder("switchLevel") StringBuilder displayName = new StringBuilder("switchLevel0") MutableInteger level = new MutableInteger() if (init) level.setValue(50) else level.setValue(60) switchLevels.add(new SwitchLevel(sendEvent, id, label, displayName, level)) } // Methods to set values def setLevel(String newValue) { setLevel(newValue.toInteger()) } def setLevel(long newValue) { setLevel((int) newValue) } def setLevel(int newValue) { switchLevels[0].setLevel(newValue) } // Methods to return values def getCurrentLevel() { List tmpValues = new ArrayList() tmpValues.add(switchLevels[0].getCurrentLevel()) return tmpValues } }