X-Git-Url: http://plrg.eecs.uci.edu/git/?p=smartthings-infrastructure.git;a=blobdiff_plain;f=SwitchLevel%2FSwitchLevels.groovy;h=bc9140cc4344c844f06a23bdf562ee654790c41f;hp=d9d2e267617a05943ffcc70f5eea37e0501cc240;hb=f719b3a1011f5d99e474a4164b09e3ab528a9dfe;hpb=591f965b054a99429e5f0c7c44078a58bcc38e06 diff --git a/SwitchLevel/SwitchLevels.groovy b/SwitchLevel/SwitchLevels.groovy index d9d2e26..bc9140c 100644 --- a/SwitchLevel/SwitchLevels.groovy +++ b/SwitchLevel/SwitchLevels.groovy @@ -13,8 +13,11 @@ public class SwitchLevels { private String label = "switchLevel0" private String displayName = "switchLevel0" private int level = 50 + private int currentLevel = 50 private int rate = 50 + private int currentRate = 50 private int hue = 30 + private int currentHue = 30 private int saturation = 70 private String switchState = "on" private String currentSwitch = "on" @@ -28,16 +31,22 @@ public class SwitchLevels { if (init) { this.level = 50 + this.currentLevel = 50 this.rate = 50 + this.currentRate = 50 this.hue = 30 + this.currentHue = 30 this.saturation = 70 this.switchState = "off" this.currentSwitch = "off" this.switchLatestValue = "off" } else { this.level = 60 + this.currentLevel = 60 this.rate = 60 + this.currentRate = 60 this.hue = 50 + this.currentHue = 50 this.saturation = 90 this.switchState = "on" this.currentSwitch = "on" @@ -70,8 +79,11 @@ public class SwitchLevels { 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"] switchLevels[0].setColor(metaData) } @@ -86,7 +98,9 @@ public class SwitchLevels { if (this.level != level) { switchLevels[0].setLevel(level) this.level = level + this.currentLevel = level this.rate = level + this.currentRate = level } } @@ -95,6 +109,8 @@ public class SwitchLevels { switchLevels[0].setLevel(level) this.level = level this.rate = level + this.currentLevel = level + this.currentRate = level } } @@ -143,6 +159,8 @@ public class SwitchLevels { } else if (eventDataMap["name"] == "level") { if (eventDataMap["value"].toInteger() != switchLevels[0].level) { this.level = eventDataMap["value"].toInteger() + this.currentLevel = eventDataMap["value"].toInteger() + this.currentRate = eventDataMap["value"].toInteger() this.rate = eventDataMap["value"].toInteger() switchLevels[0].setValue(eventDataMap["value"], "level") sendEvent(eventDataMap)