Removing getXXX methods + properties. Adding getProperty feature to SmartThing(s)
[smartthings-infrastructure.git] / SwitchLevel / SwitchLevels.groovy
1 //Create a class for switch level
2 package SwitchLevel
3 import SmartThing.SmartThings
4
5 public class SwitchLevels extends SmartThings {
6         List switchLevels = new ArrayList()
7
8         SwitchLevels(Closure sendEvent, boolean init) {
9                 // Only initialize one time since we only have one device for each capability
10                 switchLevels = smartThings
11
12                 // Initialization
13                 String id = "switchLevelID0"
14                 String label = "level"
15                 String displayName = "switchLevel"
16                 Integer level
17
18                 if (init)
19                         level = 50
20                 else
21                         level = 60
22
23                 switchLevels.add(new SwitchLevel(sendEvent, id, label, displayName, level))
24         }
25
26         // Methods to set values
27         def setLevel(String newValue) {
28                 setLevel(newValue.toInteger())
29         }
30
31         def setLevel(long newValue) {
32                 setLevel((int) newValue)
33         }
34
35         def setLevel(int newValue) {
36                 switchLevels[0].setLevel(newValue)
37         }
38 }