X-Git-Url: http://plrg.eecs.uci.edu/git/?p=smartthings-infrastructure.git;a=blobdiff_plain;f=SwitchLevel%2FSwitchLevel.groovy;h=2b5020eab7b4334234e02e550919768618d25b60;hp=7db6a168d8cecdbe1ab33404aa6ab33b1e54ec08;hb=f719b3a1011f5d99e474a4164b09e3ab528a9dfe;hpb=8e05ecd8d97bab91e6ed971b172d1fa3d6b4f9fe diff --git a/SwitchLevel/SwitchLevel.groovy b/SwitchLevel/SwitchLevel.groovy index 7db6a16..2b5020e 100644 --- a/SwitchLevel/SwitchLevel.groovy +++ b/SwitchLevel/SwitchLevel.groovy @@ -9,8 +9,11 @@ public class SwitchLevel { private String switchState private String currentSwitch private int level + private int currentLevel private int rate + private int currentRate private int hue + private int currentHue private int saturation private String switchLatestValue def sendEvent @@ -24,8 +27,11 @@ public class SwitchLevel { this.label = label this.displayName = displayName this.level = level + this.currentLevel = level this.rate = level + this.currentRate = level this.hue = hue + this.currentHue = hue this.saturation = saturation this.switchState = switchState this.currentSwitch = switchState @@ -36,8 +42,11 @@ public class SwitchLevel { def setColor(LinkedHashMap metaData) { if ((this.level != metaData["level"]) || (this.hue != metaData["hue"]) || (this.saturation != metaData["saturation"])) { this.level = metaData["level"] + this.currentLevel = metaData["level"] this.rate = metaData["level"] + this.currentRate = metaData["level"] this.hue = metaData["hue"] + this.currentHue = metaData["hue"] this.saturation = metaData["saturation"] println("the switch with id:$id is setted to level $level and hue to $hue and saturation to $saturation!") sendEvent([name: "level", value: "$level", deviceId: this.id, descriptionText: "", @@ -58,7 +67,9 @@ public class SwitchLevel { if (this.level != level) { println("the switch with id:$id is setted to level $level!") this.level = level + this.currentLevel = level this.rate = level + this.currentRate = level sendEvent([name: "level", value: "$level", deviceId: this.id, descriptionText: "", displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}']) } @@ -68,7 +79,9 @@ public class SwitchLevel { if (this.level != level) { println("the switch with id:$id is setted to level $level!") this.level = level + this.currentLevel = level this.rate = level + this.currentRate = level sendEvent([name: "level", value: "$level", deviceId: this.id, descriptionText: "", displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}']) } @@ -132,7 +145,9 @@ public class SwitchLevel { } else if (name == "level") { println("the switch with id:$id is setted to level $value!") this.level = value.toInteger() + this.currentLevel = value.toInteger() this.rate = value.toInteger() + this.currentRate = value.toInteger() } }