Removing getXXX methods + properties. Adding getProperty feature to SmartThing(s)
[smartthings-infrastructure.git] / ColorControl / ColorControls.groovy
1 //Create a class for color control
2 package ColorControl
3 import SmartThing.SmartThings
4
5 //Importing mutable integer class
6 import MutableInteger.MutableInteger
7
8 public class ColorControls extends SmartThings {
9         List colorControls = new ArrayList()
10         
11         ColorControls(Closure sendEvent, boolean init) {
12                 // Only initialize one time since we only have one device for each capability
13                 colorControls = smartThings
14
15                 // Initialization
16                 String id = "colorControlID0"
17                 String label = "colorControl"
18                 String displayName = "light"
19                 String color
20                 Integer hue
21                 Integer saturation
22
23                 if (init) {
24                         color = "Red"
25                         hue = 30
26                         saturation = 40
27                 } else {                
28                         color = "Blue"
29                         hue = 50
30                         saturation = 50
31                 }
32
33                 colorControls.add(new ColorControl(sendEvent, id, label, displayName, color, hue,
34                                                    saturation))
35         }
36
37         // Methods to set values
38         def setColor(LinkedHashMap metaData) {
39                 colorControls[0].setColor(metaData)
40         }
41
42         def setColor(String color) {
43                 colorControls[0].setColor(color)
44         }
45
46         def setHue(int hue) {
47                 colorControls[0].setHue(hue)
48         }
49         
50         def setHue(double hue) {
51                 colorControls[0].setHue((int) hue)
52         }
53
54         def setSaturation(int saturation) {
55                 colorControls[0].setSaturation(saturation)      
56         }
57         
58         def setSaturation(double saturation) {
59                 colorControls[0].setSaturation((int) saturation)
60         }
61
62         def on() {
63                 colorControls[0].on()
64         }
65
66         def off() {
67                 colorControls[0].off()
68         }
69 }