}
//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
+ println("The color of the light is changed to $color!")
+ sendEvent([name: "color", value: "$color", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ }
+ }
+
def setColor(String color) {
if (color != this.color) {
this.currentColor = color