}
//methods
+ def setColor(LinkedHashMap metaData) {
+ def hexColor = metaData.hex
+ switch (hexColor) {
+ case "#0000FF":
+ color = "Blue"
+ break;
+ case "#00FF00":
+ color = "Green"
+ break;
+ case "#FFFF00":
+ color = "Yellow"
+ break;
+ case "#FF6000":
+ color = "Orange"
+ break;
+ case "#BF7FBF":
+ color = "Purple"
+ break;
+ case "#FF5F5F":
+ color = "Pink"
+ break;
+ case "#FF0000":
+ color = "Red"
+ break;
+ default:
+ color = "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: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ }
+ }
+
def setColor(String color) {
if (color != this.color) {
this.currentColor = color
//methods
+ def setColor(LinkedHashMap metaData) {
+ def hexColor = metaData.hex
+ switch (hexColor) {
+ case "#0000FF":
+ color = "Blue"
+ break;
+ case "#00FF00":
+ color = "Green"
+ break;
+ case "#FFFF00":
+ color = "Yellow"
+ break;
+ case "#FF6000":
+ color = "Orange"
+ break;
+ case "#BF7FBF":
+ color = "Purple"
+ break;
+ case "#FF5F5F":
+ color = "Pink"
+ break;
+ case "#FF0000":
+ color = "Red"
+ break;
+ default:
+ color = "Blue"
+ break;
+ }
+ if (color != this.color) {
+ this.currentColor = color
+ this.color = color
+ colorControls[0].setColor(color)
+ }
+ }
+
def setColor(String color) {
if (color != this.color) {
this.currentColor = color
//Create a class for Events
package Event
+import groovy.json.JsonSlurper
public class Event {
private String deviceId
private boolean isStateChange
private String unit
private String data
+ private jsonData
private int integerValue
private double doubleValue
private List integerValues = ["battery", "hue", "saturation", "energy", "level", "temperature",
this.isStateChange = isStateChange
this.unit = unit
this.data = data
+ this.jsonData = new groovy.json.JsonSlurper().parseText(data)
this.displayed = displayed
if (integerValues.contains(name)) {
this.integerValue = value.toInteger()
def httpPostJson(LinkedHashMap metaData, Closure inputData) {
inputData(metaData)
}
+
+def httpPostJson(LinkedHashMap metaData) {
+
+}
this.currentPresence = value
}
+ def currentState(String deviceFeature) {
+ return [rawDateCreated: [time: System.currentTimeMillis()]]
+ }
def currentValue(String deviceFeature) {
if (deviceFeature == "presence") {
presenceSensors.collect(Input)
}
+ def currentState(String deviceFeature) {
+ presenceSensors[0].currentState(deviceFeature)
+ }
def currentValue(String deviceFeature) {
presenceSensors[0].currentValue(deviceFeature)//It is called if we have only one device
this.goal = value.toInteger()
}
}
+
+ def currentValue(String deviceFeature) {
+ if (deviceFeature == "steps")
+ return steps
+ else if (deviceFeature == "goal")
+ return goal
+ }
+
+ def latestValue(String deviceFeature) {
+ if (deviceFeature == "steps")
+ return steps
+ else if (deviceFeature == "goal")
+ return goal
+ }
}
stepSensors[0].currentValue(deviceFeature)//It is called if we have only one device
}
+ def latestValue(String deviceFeature) {
+ stepSensors[0].currentValue(deviceFeature)//It is called if we have only one device
+ }
+
def getAt(int ix) {
stepSensors[ix]
}
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"presence":"0","dni":"mobile0"}'])
presenceSensorObject.setValue([name: "presence.present", value: "present", deviceId: "presenceSensorID0", descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"presence":"1","dni":"mobile0"}'])
+presenceSensorObject.setValue([name: "presence.not present", value: "present", deviceId: "presenceSensorID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"presence":"1","dni":"mobile0"}'])
/////
/*events*/
//
//For appTouch:
/*events*/
-appObject.setValue([name: "Touched", value: "touched", deviceId: "appID0", descriptionText: "",
+appObject.setValue([name: "Touched", value: "touched", deviceId: "appTouchID0", descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
/////
/*events*/
private String id
private int isTouched
private String label
+ private String name
+
Touched(Closure sendEvent, int isTouched) {
this.sendEvent = sendEvent
this.isTouched = isTouched
this.label = "app0"
this.id = "appID0"
+ this.name = "app0"
}
//By Model Checker