private String displayName
private String switchState
private String currentSwitch
- private int level
+ private int currentLevel
private int rate
private int hue
private int saturation
this.id = id
this.label = label
this.displayName = displayName
- this.level = level
+ this.currentLevel = level
this.rate = level
this.hue = hue
this.saturation = saturation
//By Apps
def setColor(LinkedHashMap metaData) {
- if ((this.level != metaData["level"]) || (this.hue != metaData["hue"]) || (this.saturation != metaData["saturation"])) {
- this.level = metaData["level"]
+ if ((this.currentLevel != metaData["level"]) || (this.hue != metaData["hue"]) || (this.saturation != metaData["saturation"])) {
+ this.currentLevel = metaData["level"]
this.rate = metaData["level"]
this.hue = metaData["hue"]
this.saturation = metaData["saturation"]
}
def setLevel(int level) {
- if (this.level != level) {
+ if (this.currentLevel != level) {
println("the switch with id:$id is setted to level $level!")
- this.level = level
+ this.currentLevel = level
this.rate = level
sendEvent([name: "level", value: "$level", deviceId: this.id, descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
}
def setLevel(long level) {
- if (this.level != level) {
+ if (this.currentLevel != level) {
println("the switch with id:$id is setted to level $level!")
- this.level = level
+ this.currentLevel = level
this.rate = level
sendEvent([name: "level", value: "$level", deviceId: this.id, descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
this.currentSwitch = value
} 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()
}
}
def currentValue(String deviceFeature) {
if (deviceFeature == "level") {
- return level
+ return currentLevel
} else if (deviceFeature == "switch") {
return switchState
}
def latestValue(String deviceFeature) {
if (deviceFeature == "level") {
- return level
+ return currentLevel
} else if (deviceFeature == "switch") {
return switchState
}
private String id = "switchLevelID0"
private String label = "switchLevel0"
private String displayName = "switchLevel0"
- private int level = 50
+ private int currentLevel = 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"
+ private String switchState = "off"
+ private String currentSwitch = "off"
+ private String switchLatestValue = "off"
SwitchLevels(Closure sendEvent, int deviceNumbers, boolean init) {
this.sendEvent = sendEvent
this.switchLevels = []
if (init) {
- this.level = 50
+ this.currentLevel = 50
this.rate = 50
this.hue = 30
this.saturation = 70
- this.switchState = "off"
- this.currentSwitch = "off"
- this.switchLatestValue = "off"
+ this.switchState = "on"
+ this.currentSwitch = "on"
+ this.switchLatestValue = "on"
} else {
- this.level = 60
+ this.currentLevel = 60
this.rate = 60
this.hue = 50
this.saturation = 90
- this.switchState = "on"
- this.currentSwitch = "on"
- this.switchLatestValue = "on"
+ this.switchState = "off"
+ this.currentSwitch = "off"
+ this.switchLatestValue = "off"
}
- switchLevels.add(new SwitchLevel(sendEvent, id, label, displayName, this.level, this.hue, this.saturation, this.switchState, this.switchLatestValue))
+ switchLevels.add(new SwitchLevel(sendEvent, id, label, displayName, this.currentLevel, this.hue, this.saturation, this.switchState, this.switchLatestValue))
}
//Methods for closures
//By Apps
def setColor(LinkedHashMap metaData) {
- if ((this.level != metaData["level"]) || (this.hue != metaData["hue"]) || (this.saturation != metaData["saturation"])) {
- this.level = metaData["level"]
+ if ((this.currentLevel != metaData["level"]) || (this.hue != metaData["hue"]) || (this.saturation != metaData["saturation"])) {
+ this.currentLevel = metaData["level"]
this.rate = metaData["level"]
this.hue = metaData["hue"]
this.saturation = metaData["saturation"]
}
def setLevel(int level) {
- if (this.level != level) {
+ if (this.currentLevel != level) {
switchLevels[0].setLevel(level)
- this.level = level
+ this.currentLevel = level
this.rate = level
}
}
def setLevel(long level) {
- if (this.level != level) {
+ if (this.currentLevel != level) {
switchLevels[0].setLevel(level)
- this.level = level
+ this.currentLevel = level
this.rate = level
}
}
}
} else if (eventDataMap["name"] == "level") {
if (eventDataMap["value"].toInteger() != switchLevels[0].level) {
- this.level = eventDataMap["value"].toInteger()
+ this.currentLevel = eventDataMap["value"].toInteger()
this.rate = eventDataMap["value"].toInteger()
switchLevels[0].setValue(eventDataMap["value"], "level")
sendEvent(eventDataMap)