private String displayName = "colorControl0"
private String color = "red"
private String currentColor = "red"
- private String currentSwitch = "off"
+ private String currentSwitch = "on"
private int level = 50
private int currentLevel = 50
private int hue = 50
this.deviceNumbers = deviceNumbers
this.colorControls = []
- def initHue = Verify.getIntFromList(30, 50)
+ /*def initHue = Verify.getIntFromList(30, 50)
this.hue = initHue
def initSat = Verify.getIntFromList(40, 50)
this.saturation = initSat
- def init = Verify.getInt(0,2)
- if (init == 0) {
+ def initColor = Verify.getBoolean()
+ if (initColor) {
this.color = "red"
} else {
this.color = "blue"
}
+ def init = Verify.getBoolean()
+ if (init) {
+ this.currentSwitch = "off"
+ } else {
+ this.currentSwitch = "on"
+ }*/
colorControls.add(new ColorControl(sendEvent, id, label, displayName, this.color, this.hue, this.saturation, this.level, this.currentSwitch, this.colorTemperature))
}
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
}
}
+
+ def setLevel(long level) {
+ if (level != this.level) {
+ this.currentLevel = level
+ this.level = level
+ println("The level of the light is changed to $level!")
+ sendEvent([name: "level", value: "$level", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ }
+ }
def setColorTemperature(int colorTemperature) {
if (colorTemperature != this.colorTemperature) {
private String id = "colorTemperatureID0"
private String label = "colorTemperature0"
private String displayName = "colorTemperature0"
- private String currentSwitch = "off"
+ private String currentSwitch = "on"
private int level = 50
private int currentLevel = 50
private int colorTemperature = 15000
this.deviceNumbers = deviceNumbers
this.colorTemperatues = []
- def initLevel = Verify.getIntFromList(50, 70)
+ /*def initLevel = Verify.getIntFromList(50, 70)
this.level = initLevel
def initTemp = Verify.getIntFromList(10000, 15000)
this.colorTemperature = initTemp
this.currentSwitch = "off"
} else {
this.currentSwitch = "on"
- }
+ }*/
colorTemperatues.add(new ColorTemperature(sendEvent, id, label, displayName, this.level, this.currentSwitch, this.colorTemperature))
}
//methods
+ def setLevel(long level) {
+ if (level != this.level) {
+ this.currentLevel = level
+ this.level = level
+ colorTemperatues[0].setLevel(level)
+ }
+ }
+
def setLevel(int level) {
if (level != this.level) {
this.currentLevel = level
case "mode":
//def randomVariable = Math.abs(new Random().nextInt() % 3)
def modes = ["away", "home", "night"]
- def userInput = modes[0]
+ def userInput = modes[1]
if (modeVariables == 0) {
mode0 = metaData['name']
this.deviceNumbers = deviceNumbers
this.switches = []
- /*def initLevel = Verify.getIntFromList(30, 50, 70)
+ def initLevel = Verify.getIntFromList(30, 50, 70)
this.currentLevel = initLevel
def init = Verify.getBoolean()
- if (init) {
+ /*if (init) {
this.switchState = "off"
this.currentSwitch = "off"
this.switchLatestValue = "off"
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
}
}
+
+ def setLevel(long level) {
+ if (this.level != level) {
+ println("the switch with id:$id is setted to level $level!")
+ this.level = level
+ this.rate = level
+ sendEvent([name: "level", value: "$level", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ }
+ }
def on() {
if (this.switchState != "on") {
private String displayName = "switchLevel0"
private int level = 50
private int rate = 50
- private String switchState = "off"
- private String currentSwitch = "off"
- private String switchLatestValue = "off"
+ private String switchState = "on"
+ private String currentSwitch = "on"
+ private String switchLatestValue = "on"
SwitchLevels(Closure sendEvent, int deviceNumbers) {
this.sendEvent = sendEvent
this.rate = level
}
}
+
+ def setLevel(long level) {
+ if (this.level != level) {
+ switchLevels[0].setLevel(level)
+ this.level = level
+ this.rate = level
+ }
+ }
def on() {
switchLatestValue = "on"