1 //Create a class for color control
3 import Timer.SimulatedTimer
6 public class ColorControl {
9 private String displayName
12 private int saturation
14 ColorControl(String id, String label, String displayName, String color, int hue, int saturation) {
17 this.displayName = displayName
20 this.saturation = saturation
24 def setValue(String value, String name) {
25 if (name == "color") {
27 println("the color of the light is changed to $value!")
28 } else if (name == "hue") {
29 this.hue = value.toInteger()
30 println("The hue level of the light is changed to $value!")
32 this.saturation = value.toInteger()
33 println("The saturation level of the light is changed to $value!")
38 def setColor(String color) {
40 println("The color of the light is changed to $color!")
41 sendEvent([name: "color", value: "$color", deviceId: this.id, descriptionText: "",
42 displayed: true, linkText: "", isStateChange: false, unit: "", data: [value: "$color"]])
47 println("The hue level of the light is changed to $hue!")
48 sendEvent([name: "hue", value: "$hue", deviceId: this.id, descriptionText: "",
49 displayed: true, linkText: "", isStateChange: false, unit: "", data: [value: "$hue"]])
52 def setSaturation(int saturation) {
53 this.saturation = saturation
54 println("The saturation level of the light is changed to $saturation!")
55 sendEvent([name: "saturation", value: "$saturation", deviceId: this.id, descriptionText: "",
56 displayed: true, linkText: "", isStateChange: false, unit: "", data: [value: "$saturation"]])
59 def currentValue(String deviceFeature) {
60 if (deviceFeature == "color") {
62 } else if (deviceFeature == "saturation") {
64 } else if (deviceFeature == "hue") {