1 //Create a class for color control
3 import SmartThing.SmartThing
5 public class ColorControl extends SmartThing {
6 // id, label, and display name of the device
10 // Maps from features to values
11 HashMap<String, String> deviceValuesMap = new HashMap<String, String>()
12 HashMap<String, Integer> deviceIntValuesMap = new HashMap<String, Integer>()
14 ColorControl(Closure sendEvent, String id, String label, String displayName, String currentColor, Integer currentHue, Integer currentSaturation) {
15 deviceValueSmartThing = deviceValuesMap
16 deviceIntValueSmartThing = deviceIntValuesMap
18 labelSmartThing = label
19 displayNameSmartThing = displayName
20 sendEventSmartThings = sendEvent
25 this.displayName = displayName
27 deviceValuesMap.put("color", currentColor)
28 deviceIntValuesMap.put("hue", currentHue)
29 deviceIntValuesMap.put("saturation", currentSaturation)
32 def setColor(LinkedHashMap metaData) {
33 def hexColor = metaData.hex
64 // Methods to set values
65 def setColor(String newValue) {
66 action(newValue, "color")
69 def setHue(int newValue) {
70 action(newValue, "hue")
73 def setHue(double newValue) {
74 setHue((int) newValue)
77 def setSaturation(int newValue) {
78 action(newValue, "saturation")
81 def setSaturation(double newValue) {
82 setSaturation((int) newValue)