Merge branch 'master' of ssh://plrg.eecs.uci.edu/home/git/smartthings-infrastructure
authoramiraj <amiraj.95@uci.edu>
Mon, 5 Aug 2019 02:58:53 +0000 (19:58 -0700)
committeramiraj <amiraj.95@uci.edu>
Mon, 5 Aug 2019 02:58:53 +0000 (19:58 -0700)
1  2 
ColorControl/ColorControls.groovy

index 306ba87db72324ef0a295e879ba0223e9f6ecde0,0c0832b3921e650d870b2db8814bd212f4106a9b..7a5498053674d6192b89e391c005a221dc561273
@@@ -31,18 -31,16 +31,16 @@@ public class ColorControls 
                this.deviceNumbers = deviceNumbers
                this.colorControls = []
  
-               /*def initHue = Verify.getIntFromList(30, 50, 70)
+               def initHue = Verify.getIntFromList(30, 50)
                this.hue = initHue
-               def initSat = Verify.getIntFromList(40, 50, 60)
+               def initSat = Verify.getIntFromList(40, 50)
                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(sendEvent, id, label, displayName, this.color, this.hue, this.saturation, this.level, this.currentSwitch, this.colorTemperature))
        }
  
  
        //methods
 +      def setColor(LinkedHashMap metaData) {
 +              def hexColor = metaData.hex
 +              switch (hexColor) {
 +                      case "#0000FF":
 +                              color = "Blue"
 +                              break;
 +                      case "#00FF00":
 +                              color = "Green"
 +                              break;
 +                      case "#FFFF00":
 +                              color = "Yellow"
 +                              break;
 +                      case "#FF6000":
 +                              color = "Orange"
 +                              break;
 +                      case "#BF7FBF":
 +                              color = "Purple"
 +                              break;
 +                      case "#FF5F5F":
 +                              color = "Pink"
 +                              break;
 +                      case "#FF0000":
 +                              color = "Red"
 +                              break;
 +                      default:
 +                              color = "Blue"
 +                              break;
 +              }
 +              if (color != this.color) {
 +                      this.currentColor = color
 +                      this.color = color
 +                      colorControls[0].setColor(color)                        
 +              }
 +      }
 +
        def setColor(String color) {
                if (color != this.color) {
                        this.currentColor = color