Infrastructure compatible for all groups instead of switches.
[smartthings-infrastructure.git] / SwitchLevel / SwitchLevels.groovy
index 6ceaf8fb2b0ea51acb62b56a8510331928e0ee62..09bf7a6f163c480949b40dc5b5a48681f168a625 100644 (file)
@@ -17,6 +17,8 @@ public class SwitchLevels {
        private String displayName = "switchLevel0"
        private int level = 50
        private int rate = 50
+       private int hue = 30
+       private int saturation = 70
        private String switchState = "on"
        private String currentSwitch = "on"
        private String switchLatestValue = "on"
@@ -39,7 +41,7 @@ public class SwitchLevels {
                        this.currentSwitch = "on"
                        this.switchLatestValue = "on"
                }*/
-               switchLevels.add(new SwitchLevel(sendEvent, id, label, displayName, this.level, this.switchState, this.switchLatestValue))
+               switchLevels.add(new SwitchLevel(sendEvent, id, label, displayName, this.level, this.hue, this.saturation, this.switchState, this.switchLatestValue))
        }
 
        //Methods for closures
@@ -63,6 +65,16 @@ public class SwitchLevels {
        }
 
        //By Apps
+       def setColor(LinkedHashMap metaData) {
+               if ((this.level != metaData["level"]) || (this.hue != metaData["hue"]) || (this.saturation != metaData["saturation"])) {
+                       this.level = metaData["level"]
+                       this.rate = metaData["level"]
+                       this.hue = metaData["hue"]
+                       this.saturation = metaData["saturation"]
+                       switchLevels[0].setColor(metaData)
+               }
+       }
+
        def setLevel(int level) {
                if (this.level != level) {
                        switchLevels[0].setLevel(level)