Adding missing methods; rearranging initial values.
[smartthings-infrastructure.git] / ColorControl / ColorControls.groovy
index 90223c54bdd233baf3feb1690ed53477676ef9e9..a2c93de0049933825c71eb151b9b857806f20588 100644 (file)
@@ -38,7 +38,7 @@ public class ColorControls {
                        this.currentSaturation = 40
                        this.colorTemperature = 10000
                        this.color = "Red"
-                       this.currentSwitch = "off"
+                       this.currentSwitch = "on"
                } else {
                        this.level = 50
                        this.currentLevel = 50
@@ -48,7 +48,7 @@ public class ColorControls {
                        this.currentSaturation = 50
                        this.colorTemperature = 15000
                        this.color = "Blue"
-                       this.currentSwitch = "on"
+                       this.currentSwitch = "off"
                }
                colorControls.add(new ColorControl(sendEvent, id, label, displayName, this.color, this.hue, this.saturation, this.level, this.currentSwitch, this.colorTemperature))
        }
@@ -188,6 +188,14 @@ public class ColorControls {
                        colorControls[0].setHue(hue)
                }
        }
+       
+       def setHue(double hue) {
+               if (hue != this.hue) {
+                       this.hue = hue
+                       this.currentHue = hue
+                       colorControls[0].setHue((int) hue)
+               }
+       }
 
        def setSaturation(int saturation) {
                if (saturation != this.saturation) {
@@ -196,6 +204,14 @@ public class ColorControls {
                        colorControls[0].setSaturation(saturation)                      
                }       
        }
+       
+       def setSaturation(double saturation) {
+               if (saturation != this.saturation) {
+                       this.currentSaturation = saturation
+                       this.saturation = saturation
+                       colorControls[0].setSaturation(saturation)                      
+               }       
+       }
 
        def setLevel(int level) {
                if (level != this.level) {