1 //Create a class for switch level
3 import SmartThing.SmartThings
5 //Importing mutable integer class
6 import MutableInteger.MutableInteger
8 public class SwitchLevels extends SmartThings {
9 List switchLevels = new ArrayList()
11 SwitchLevels(Closure sendEvent, boolean init) {
12 // Only initialize one time since we only have one device for each capability
13 switchLevels = smartThings
16 StringBuilder id = new StringBuilder("switchLevelID0")
17 StringBuilder label = new StringBuilder("switchLevel")
18 StringBuilder displayName = new StringBuilder("switchLevel0")
19 MutableInteger level = new MutableInteger()
26 switchLevels.add(new SwitchLevel(sendEvent, id, label, displayName, level))
29 // Methods to set values
30 def setLevel(String newValue) {
31 setLevel(newValue.toInteger())
34 def setLevel(long newValue) {
35 setLevel((int) newValue)
38 def setLevel(int newValue) {
39 switchLevels[0].setLevel(newValue)
42 // Methods to return values
43 def getCurrentLevel() {
44 List tmpValues = new ArrayList()
45 tmpValues.add(switchLevels[0].getCurrentLevel())