//methods
def setColor(LinkedHashMap metaData) {
def hexColor = metaData.hex
+ def newColor
switch (hexColor) {
case "#0000FF":
- color = "Blue"
+ newColor = "Blue"
break;
case "#00FF00":
- color = "Green"
+ newColor = "Green"
break;
case "#FFFF00":
- color = "Yellow"
+ newColor = "Yellow"
break;
case "#FF6000":
- color = "Orange"
+ newColor = "Orange"
break;
case "#BF7FBF":
- color = "Purple"
+ newColor = "Purple"
break;
case "#FF5F5F":
- color = "Pink"
+ newColor = "Pink"
break;
case "#FF0000":
- color = "Red"
+ newColor = "Red"
break;
default:
- color = "Blue"
+ newColor = "Blue"
break;
}
- if (color != this.color) {
- this.currentColor = color
- this.color = color
- println("The color of the light is changed to $color!")
- sendEvent([name: "color", value: "$color", deviceId: this.id, descriptionText: "",
+ if (newColor != this.color) {
+ this.currentColor = newColor
+ this.color = newColor
+ println("The color of the light is changed to $newColor!")
+ sendEvent([name: "color", value: "$newColor", deviceId: this.id, descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
}
}
private String id = "colorControlID0"
private String label = "colorControl0"
private String displayName = "colorControl0"
- private String color = "red"
- private String currentColor = "red"
+ private String color = "Red"
+ private String currentColor = "Red"
private String currentSwitch = "on"
private int level = 50
private int currentLevel = 50
private int saturation = 50
private int currentSaturation = 50
private int colorTemperature = 15000
+ private boolean colorChanged = false
ColorControls(Closure sendEvent, int deviceNumbers, boolean init) {
this.colorControls = []
if (init) {
+ this.level = 20
+ this.currentLevel = 20
this.hue = 30
+ this.currentHue = 30
this.saturation = 40
- this.color = "red"
+ this.currentSaturation = 40
+ this.colorTemperature = 10000
+ this.color = "Red"
this.currentSwitch = "off"
} else {
+ this.level = 50
+ this.currentLevel = 50
this.hue = 50
+ this.currentHue = 50
this.saturation = 50
- this.color = "blue"
+ this.currentSaturation = 50
+ this.colorTemperature = 15000
+ this.color = "Blue"
this.currentSwitch = "on"
}
-
colorControls.add(new ColorControl(sendEvent, id, label, displayName, this.color, this.hue, this.saturation, this.level, this.currentSwitch, this.colorTemperature))
}
//methods
def setColor(LinkedHashMap metaData) {
def hexColor = metaData.hex
+ def newColor
switch (hexColor) {
case "#0000FF":
- color = "Blue"
+ newColor = "Blue"
break;
case "#00FF00":
- color = "Green"
+ newColor = "Green"
break;
case "#FFFF00":
- color = "Yellow"
+ newColor = "Yellow"
break;
case "#FF6000":
- color = "Orange"
+ newColor = "Orange"
break;
case "#BF7FBF":
- color = "Purple"
+ newColor = "Purple"
break;
case "#FF5F5F":
- color = "Pink"
+ newColor = "Pink"
break;
case "#FF0000":
- color = "Red"
+ newColor = "Red"
break;
default:
- color = "Blue"
+ newColor = "Blue"
break;
}
- if (color != this.color) {
- this.currentColor = color
- this.color = color
- colorControls[0].setColor(color)
+ if (newColor != this.color) {
+ this.currentColor = newColor
+ this.color = newColor
+ colorControls[0].setColor(newColor)
+ if (this.colorChanged) {
+ this.colorChanged = false
+ } else {
+ this.colorChanged = true
+ }
+ }
+ def newLevel = metaData.level
+ def newHue = metaData.hue
+ def newSaturation = metaData.saturation
+ if (newLevel != null) {
+ setLevel(newLevel)
+ }
+ if (newHue != null) {
+ setHue(newHue)
+ }
+ if (newSaturation != null) {
+ setSaturation(newSaturation)
}
}
'sunriseTime' : 1,
'acceleration' : 2,
'sleeping' : 2,
- 'goal' : 1,
- 'steps' : 1,
+ 'goal' : 2,
+ 'steps' : 2,
'color' : 1,
'colorTemperature' : 1,
'hue' : 1,
'saturation' : 1,
'energy' : 1,
- 'power' : 1,
+ 'power' : 2,
'illuminance' : 1,
'humidity' : 1,
'alarm' : 4,
extractedEvents.write(line)
event.close()
elif eventList[i] == "goal":
- event = open("eventSimulator/stepGoalEvent.groovy", "r")
+ #Write two events subsequently
+ event = open("eventSimulator/stepGoalHighEvent.groovy", "r")
+ for line in event:
+ extractedEvents.write(line)
+ event.close()
+ extractedEvents.write("\n\t\t\tbreak\n")
+ counter = counter + 1
+ extractedEvents.write("\t\tcase %d:\n" % counter)
+ event = open("eventSimulator/stepGoalLowEvent.groovy", "r")
for line in event:
extractedEvents.write(line)
event.close()
elif eventList[i] == "steps":
- event = open("eventSimulator/stepStepsEvent.groovy", "r")
+ #Write two events subsequently
+ event = open("eventSimulator/stepStepsHighEvent.groovy", "r")
+ for line in event:
+ extractedEvents.write(line)
+ event.close()
+ extractedEvents.write("\n\t\t\tbreak\n")
+ counter = counter + 1
+ extractedEvents.write("\t\tcase %d:\n" % counter)
+ event = open("eventSimulator/stepStepsLowEvent.groovy", "r")
for line in event:
extractedEvents.write(line)
event.close()
private String label = "musicPlayer0"
private String displayName = "musicPlayer0"
private int level = 20
+ private int duration = 10
private String mute = "unmuted"
private String status = "pause"
private int trackNumber = 1
if (init) {
this.level = 20
+ this.duration = 10
this.mute = "unmuted"
this.status = "paused"
this.trackNumber = 1
this.trackDescription = "someDescriptions"
} else {
this.level = 30
+ this.duration = 20
this.mute = "muted"
this.status = "playing"
this.trackNumber = 2
}
}
def playTrack(LinkedHashMap metaData) {
- playTrack()
+ playTrack("someTrack")
+ }
+ def playTrackAndResume(String trackData, int duration) {
+ playTrack(trackData)
+ if (duration != this.duration) {
+ this.duration = duration
+ }
+ }
+ def playTrackAndResume(String trackData, int duration, int level) {
+ playTrackAndResume(trackData, duration)
+ if (level != this.level) {
+ this.level = level
+ }
+ }
+ def playTrackAtVolume(String trackData, int level) {
+ playTrack(trackData)
+ if (level != this.level) {
+ this.level = level
+ }
}
def playTrack(String trackToPlay) {
if (status != "play") {
if (init) {
this.goal = 50
- this.steps = 0
+ this.steps = 35
} else {
- this.goal = 60
- this.steps = 1
+ this.goal = 40
+ this.steps = 60
}
stepSensors.add(new StepSensor(id, label, displayName, this.steps, this.goal))
}
+++ /dev/null
- stepSensorObject.setValue([name: "goal", value: "100"/*A number*/, deviceId: "stepSensorID0", descriptionText: "",
- displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ stepSensorObject.setValue([name: "goal", value: "100"/*A number*/, deviceId: "stepSensorID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ stepSensorObject.setValue([name: "goal", value: "20"/*A number*/, deviceId: "stepSensorID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+++ /dev/null
- stepSensorObject.setValue([name: "steps", value: "46"/*A number*/, deviceId: "stepSensorID0", descriptionText: "",
- displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ stepSensorObject.setValue([name: "steps", value: "70"/*A number*/, deviceId: "stepSensorID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ stepSensorObject.setValue([name: "steps", value: "30"/*A number*/, deviceId: "stepSensorID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])