1 //Create a class for color control
3 import SmartThing.SmartThings
5 public class ColorControls extends SmartThings {
6 List colorControls = new ArrayList()
8 ColorControls(Closure sendEvent, boolean init) {
9 // Only initialize one time since we only have one device for each capability
10 colorControls = smartThings
13 StringBuilder id = new StringBuilder("colorControlID0")
14 StringBuilder label = new StringBuilder("colorControl")
15 StringBuilder displayName = new StringBuilder("colorControl0")
16 StringBuilder color = new StringBuilder()
17 MutableInteger hue = new MutableInteger()
18 MutableInteger saturation = new MutableInteger()
23 saturation.setValue(40)
27 saturation.setValue(50)
30 colorControls.add(new ColorControl(sendEvent, id, label, displayName, color, hue,
34 // Methods to set values
35 def setColor(LinkedHashMap metaData) {
36 colorControls[0].setColor(metaData)
39 def setColor(String color) {
40 colorControls[0].setColor(color)
44 colorControls[0].setHue(hue)
47 def setHue(double hue) {
48 colorControls[0].setHue((int) hue)
51 def setSaturation(int saturation) {
52 colorControls[0].setSaturation(saturation)
55 def setSaturation(double saturation) {
56 colorControls[0].setSaturation((int) saturation)
64 colorControls[0].off()
67 // Methods to return values
69 List tmpValues = new ArrayList()
70 tmpValues.add(colorControls[0].getCurrentHue())
74 def getCurrentSaturation() {
75 List tmpValues = new ArrayList()
76 tmpValues.add(colorControls[0].getCurrentSaturation())
80 def getCurrentColor() {
81 List tmpValues = new ArrayList()
82 tmpValues.add(colorControls[0].getCurrentColor())