X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=ColorControl%2FColorControl.groovy;h=4878c48b9f82c55e43a105068269d29e1b6f02dc;hb=752df0b3baa7349d6a0f5bdefb7d644a552bea2e;hp=0e9ced0f3d70afae552600d363ac1ccdd2175ee9;hpb=9ba86613e2bf63d553369c526274b040c116c5de;p=smartthings-infrastructure.git diff --git a/ColorControl/ColorControl.groovy b/ColorControl/ColorControl.groovy index 0e9ced0..4878c48 100644 --- a/ColorControl/ColorControl.groovy +++ b/ColorControl/ColorControl.groovy @@ -66,37 +66,38 @@ public class ColorControl { //methods def setColor(LinkedHashMap metaData) { def hexColor = metaData.hex + def newColor switch (hexColor) { case "#0000FF": - color = "Blue" + newColor = "Blue" break; case "#00FF00": - color = "Green" + newColor = "Green" break; case "#FFFF00": - color = "Yellow" + newColor = "Yellow" break; case "#FF6000": - color = "Orange" + newColor = "Orange" break; case "#BF7FBF": - color = "Purple" + newColor = "Purple" break; case "#FF5F5F": - color = "Pink" + newColor = "Pink" break; case "#FF0000": - color = "Red" + newColor = "Red" break; default: - color = "Blue" + newColor = "Blue" break; } - if (color != this.color) { - this.currentColor = color - this.color = color - println("The color of the light is changed to $color!") - sendEvent([name: "color", value: "$color", deviceId: this.id, descriptionText: "", + if (newColor != this.color) { + this.currentColor = newColor + this.color = newColor + println("The color of the light is changed to $newColor!") + sendEvent([name: "color", value: "$newColor", deviceId: this.id, descriptionText: "", displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}']) } }