1 //Create a class for color control
3 import SmartThing.SmartThings
5 //Importing mutable integer class
6 import MutableInteger.MutableInteger
8 public class ColorControls extends SmartThings {
9 List colorControls = new ArrayList()
11 ColorControls(Closure sendEvent, boolean init) {
12 // Only initialize one time since we only have one device for each capability
13 colorControls = smartThings
16 StringBuilder id = new StringBuilder("colorControlID0")
17 StringBuilder label = new StringBuilder("colorControl")
18 StringBuilder displayName = new StringBuilder("colorControl0")
19 StringBuilder color = new StringBuilder()
20 MutableInteger hue = new MutableInteger()
21 MutableInteger saturation = new MutableInteger()
26 saturation.setValue(40)
30 saturation.setValue(50)
33 colorControls.add(new ColorControl(sendEvent, id, label, displayName, color, hue,
37 // Methods to set values
38 def setColor(LinkedHashMap metaData) {
39 colorControls[0].setColor(metaData)
42 def setColor(String color) {
43 colorControls[0].setColor(color)
47 colorControls[0].setHue(hue)
50 def setHue(double hue) {
51 colorControls[0].setHue((int) hue)
54 def setSaturation(int saturation) {
55 colorControls[0].setSaturation(saturation)
58 def setSaturation(double saturation) {
59 colorControls[0].setSaturation((int) saturation)
67 colorControls[0].off()
70 // Methods to return values
72 List tmpValues = new ArrayList()
73 tmpValues.add(colorControls[0].getCurrentHue())
77 def getCurrentSaturation() {
78 List tmpValues = new ArrayList()
79 tmpValues.add(colorControls[0].getCurrentSaturation())
83 def getCurrentColor() {
84 List tmpValues = new ArrayList()
85 tmpValues.add(colorControls[0].getCurrentColor())