//Create a class for color control package ColorControl import SmartThing.SmartThings //Importing mutable integer class import MutableInteger.MutableInteger public class ColorControls extends SmartThings { List colorControls = new ArrayList() ColorControls(Closure sendEvent, boolean init) { // Only initialize one time since we only have one device for each capability colorControls = smartThings // Initialization StringBuilder id = new StringBuilder("colorControlID0") StringBuilder label = new StringBuilder("colorControl") StringBuilder displayName = new StringBuilder("colorControl0") StringBuilder color = new StringBuilder() MutableInteger hue = new MutableInteger() MutableInteger saturation = new MutableInteger() if (init) { color.append("Red") hue.setValue(30) saturation.setValue(40) } else { color.append("Blue") hue.setValue(50) saturation.setValue(50) } colorControls.add(new ColorControl(sendEvent, id, label, displayName, color, hue, saturation)) } // Methods to set values def setColor(LinkedHashMap metaData) { colorControls[0].setColor(metaData) } def setColor(String color) { colorControls[0].setColor(color) } def setHue(int hue) { colorControls[0].setHue(hue) } def setHue(double hue) { colorControls[0].setHue((int) hue) } def setSaturation(int saturation) { colorControls[0].setSaturation(saturation) } def setSaturation(double saturation) { colorControls[0].setSaturation((int) saturation) } def on() { colorControls[0].on() } def off() { colorControls[0].off() } // Methods to return values def getCurrentHue() { List tmpValues = new ArrayList() tmpValues.add(colorControls[0].getCurrentHue()) return tmpValues } def getCurrentSaturation() { List tmpValues = new ArrayList() tmpValues.add(colorControls[0].getCurrentSaturation()) return tmpValues } def getCurrentColor() { List tmpValues = new ArrayList() tmpValues.add(colorControls[0].getCurrentColor()) return tmpValues } }