//Create a class for color control package ColorControl import Timer.SimulatedTimer public class ColorControl { private String id private String label private String displayName private String color private int hue private int saturation ColorControl(String id, String label, String displayName, String color, int hue, int saturation) { this.id = id this.label = label this.displayName = displayName this.color = color this.hue = hue this.saturation = saturation } //By model checker def setValue(String value, String name) { if (name == "color") { this.color = value println("the color of the light is changed to $value!") } else if (name == "hue") { this.hue = value.toInteger() println("The hue level of the light is changed to $value!") } else { this.saturation = value.toInteger() println("The saturation level of the light is changed to $value!") } } //methods def setColor(String 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: [value: "$color"]]) } def setHue(int hue) { this.hue = hue println("The hue level of the light is changed to $hue!") sendEvent([name: "hue", value: "$hue", deviceId: this.id, descriptionText: "", displayed: true, linkText: "", isStateChange: false, unit: "", data: [value: "$hue"]]) } def setSaturation(int saturation) { this.saturation = saturation println("The saturation level of the light is changed to $saturation!") sendEvent([name: "saturation", value: "$saturation", deviceId: this.id, descriptionText: "", displayed: true, linkText: "", isStateChange: false, unit: "", data: [value: "$saturation"]]) } def currentValue(String deviceFeature) { if (deviceFeature == "color") { return color } else if (deviceFeature == "saturation") { return saturation } else if (deviceFeature == "hue") { return hue } } }