private String currentSwitch
private int level
private int rate
+ private int hue
+ private int saturation
private String switchLatestValue
def sendEvent
def timers
- SwitchLevel(Closure sendEvent, String id, String label, String displayName, int level, String switchState, String switchLatestValue) {
+ SwitchLevel(Closure sendEvent, String id, String label, String displayName, int level, int hue, int saturation, String switchState, String switchLatestValue) {
this.sendEvent = sendEvent
this.timers = new SimulatedTimer()
this.id = id
this.displayName = displayName
this.level = level
this.rate = level
+ this.hue = hue
+ this.saturation = saturation
this.switchState = switchState
this.currentSwitch = switchState
this.switchLatestValue = switchLatestValue
}
//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"]
+ 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: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ sendEvent([name: "hue", value: "$hue", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ sendEvent([name: "saturation", value: "$saturation", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ }
+ }
+
def setLevel(int level) {
if (this.level != level) {
println("the switch with id:$id is setted to level $level!")