X-Git-Url: http://plrg.eecs.uci.edu/git/?p=smartthings-infrastructure.git;a=blobdiff_plain;f=ColorControl%2FColorControls.groovy;h=3538447ce14bad689fd59d4e68a8e752d8d49219;hp=6eb5ac65f9f26a3e597cc07c72c7e9d86c9b86d1;hb=d00fd74ad7e497d6849c284c6ba69db2d3ec8e65;hpb=e378d6a65b25030f8914dc97f04b81ddff351d9c diff --git a/ColorControl/ColorControls.groovy b/ColorControl/ColorControls.groovy index 6eb5ac6..3538447 100644 --- a/ColorControl/ColorControls.groovy +++ b/ColorControl/ColorControls.groovy @@ -37,6 +37,19 @@ public class ColorControls { this.color = "blue" } + def initHue = Verify.getIntFromList(30, 50, 70) + this.hue = initHue + def initSat = Verify.getIntFromList(40, 50, 60) + this.saturation = initSat + def init = Verify.getInt(0,2) + if (init == 0) { + this.color = "red" + } else if (init == 1) { + this.color = "green" + } else { + this.color = "blue" + } + colorControls.add(new ColorControl(id, label, displayName, this.color, this.hue, this.saturation)) } @@ -83,18 +96,24 @@ public class ColorControls { //methods def setColor(String color) { - colorControls[0].setColor(color) - this.color = color + if (color != this.color) { + colorControls[0].setColor(color) + this.color = color + } } def setHue(int hue) { - colorControls[0].setHue(hue) - this.hue = hue + if (hue != this.hue) { + colorControls[0].setHue(hue) + this.hue = hue + } } def setSaturation(int saturation) { - colorControls[0].setSaturation(saturation) - this.saturation = saturation + if (saturation != this.saturation) { + colorControls[0].setSaturation(saturation) + this.saturation = saturation + } } def currentValue(String deviceFeature) {