}
def setValue(String value) {
- this.accelerationLatestValue = acceleration
println("the acceleration sensor with id:$id is triggered to $value!")
+ this.accelerationLatestValue = value
this.acceleration = value
this.currentAcceleration = value
this.states.add(value)
private String acceleration = "inactive"
private String currentAcceleration = "inactive"
private String accelerationLatestValue = "inactive"
+
AccelerationSensors(Closure sendEvent, int deviceNumbers) {
//By Model Checker
def setValue(LinkedHashMap eventDataMap) {
if (eventDataMap["value"] != accelerationSensors[0].acceleration) {
+ this.accelerationLatestValue = eventDataMap["value"]
+ this.acceleration = eventDataMap["value"]
+ this.currentAcceleration = eventDataMap["value"]
accelerationSensors[0].setValue(eventDataMap["value"])
- this.accelerationLatestValue = accelerationSensors[0].accelerationLatestValue
- this.acceleration = accelerationSensors[0].acceleration
- this.currentAcceleration = accelerationSensors[0].acceleration
sendEvent(eventDataMap)
}
}
def each(Closure Input) {
accelerationSensors.each(Input)
}
+ def sort(Closure Input) {
+ accelerationSensors.each(Input)
+ }
def find(Closure Input) {
accelerationSensors.find(Input)
}
def each(Closure Input) {
aeonKeyFobs.each(Input)
}
+ def sort(Closure Input) {
+ aeonKeyFobs.sort(Input)
+ }
def find(Closure Input) {
aeonKeyFobs.find(Input)
}
//By model checker
def setValue(String value) {
- this.alarmLatestValue = alarm
println("the alarm with id:$id is triggered to $value!")
+ this.alarmLatestValue = value
this.alarm = value
this.currentAlarm = value
}
def both() {
if (alarm != "both") {
println("the alarm with id:$id is changed to both!")
- this.alarmLatestValue = this.alarm
+ this.alarmLatestValue = "both"
this.alarm = "both"
this.currentAlarm = "both"
sendEvent([name: "alarm", value: "both", deviceId: this.id, descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ sendEvent([name: "alarm.both", value: "both", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
}
}
def off() {
if (alarm != "off") {
println("the alarm with id:$id is changed to off!")
- this.alarmLatestValue = this.alarm
+ this.alarmLatestValue = "off"
this.alarm = "off"
this.currentAlarm = "off"
sendEvent([name: "alarm", value: "off", deviceId: this.id, descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ sendEvent([name: "alarm.off", value: "off", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
}
}
def siren() {
if (alarm != "siren") {
println("the alarm with id:$id is changed to siren!")
- this.alarmLatestValue = this.alarm
+ this.alarmLatestValue = "siren"
this.alarm = "siren"
this.currentAlarm = "siren"
sendEvent([name: "alarm", value: "siren", deviceId: this.id, descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ sendEvent([name: "alarm.siren", value: "siren", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
}
}
def strobe() {
if (alarm != "strobe") {
println("the alarm with id:$id is changed to strobe!")
- this.alarmLatestValue = this.alarm
+ this.alarmLatestValue = "strobe"
this.alarm = "strobe"
this.currentAlarm = "strobe"
sendEvent([name: "alarm", value: "strobe", deviceId: this.id, descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ sendEvent([name: "alarm.strobe", value: "strobe", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
}
}
//By Model Checker
def setValue(LinkedHashMap eventDataMap) {
if (eventDataMap["value"] != alarms[0].alarm) {
+ this.alarmLatestValue = eventDataMap["value"]
+ this.alarm = eventDataMap["value"]
+ this.currentAlarm = eventDataMap["value"]
alarms[0].setValue(eventDataMap["value"])
- this.alarmLatestValue = alarms[0].alarmLatestValue
- this.alarm = alarms[0].alarm
- this.currentAlarm = alarms[0].alarm
sendEvent(eventDataMap)
}
}
def find(Closure Input) {
alarms.find(Input)
}
+ def sort(Closure Input) {
+ alarms.sort(Input)
+ }
def collect(Closure Input) {
alarms.collect(Input)
}
//By Apps
def both() {
if (alarm != "both") {
- alarms[0].both()
- alarmLatestValue = alarm
+ alarmLatestValue = "both"
alarm = "both"
currentAlarm = "both"
+ alarms[0].both()
}
}
def off() {
if (alarm != "off") {
- alarms[0].off()
- alarmLatestValue = alarm
+ alarmLatestValue = "off"
alarm = "off"
currentAlarm = "off"
+ alarms[0].off()
}
}
def siren() {
if (alarm != "siren") {
- alarms[0].siren()
- alarmLatestValue = alarm
+ alarmLatestValue = "siren"
alarm = "siren"
currentAlarm = "siren"
+ alarms[0].siren()
}
}
def strobe() {
if (alarm != "strobe") {
- alarms[0].strobe()
- alarmLatestValue = alarm
+ alarmLatestValue = "strobe"
alarm = "strobe"
currentAlarm = "strobe"
+ alarms[0].strobe()
}
}
+++ /dev/null
-//Create a class for atomic state
-package AtomicState
-
-public class AtomicState {
- def bucketKey
- def accessKey
- def bucketName
- def isBucketCreated
- def grokerSubdomain
- def eventBuffer
- def version
- def isDisabled
- def queue
- def poll
-
- AtomicState() {
- this.version = "1.0"
- this.accessKey = 15
- this.bucketKey = 20
- }
-}
private String displayName = "battery0"
private int battery = 50
private int currentBattery = 50
+ private int batteryLatestValue = 50
Batteries(Closure sendEvent, int deviceNumbers) {
//By Model Checker
def setValue(LinkedHashMap eventDataMap) {
- if (eventDataMap["value"] != batteries[0].battery) {
+ if (eventDataMap["value"].toInteger() != batteries[0].battery) {
+ this.battery = eventDataMap["value"].toInteger()
+ this.currentBattery = eventDataMap["value"].toInteger()
+ this.batteryLatestValue = eventDataMap["value"].toInteger()
batteries[0].setValue(eventDataMap["value"])
- this.battery = batteries[0].battery
- this.currentBattery = batteries[0].battery
sendEvent(eventDataMap)
}
}
def each(Closure Input) {
batteries.each(Input)
}
+ def sort(Closure Input) {
+ batteries.sort(Input)
+ }
def find(Closure Input) {
batteries.find(Input)
}
batteries[0].currentValue(deviceFeature)//It is called if we have only one device
}
+ def latestValue(String deviceFeature) {
+ batteries[0].latestValue(deviceFeature)//It is called if we have only one device
+ }
+
def getAt(int ix) {
batteries[ix]
}
private String displayName
private int battery
private int currentBattery
+ private int batteryLatestValue
Battery(String id, String label, String displayName, int battery) {
this.id = id
this.displayName = displayName
this.battery = battery
this.currentBattery = battery
+ this.batteryLatestValue = battery
}
//By Model Checker
println("the battery level with id:$id is changed to $value!")
this.battery = value.toInteger()
this.currentBattery = value.toInteger()
+ this.batteryLatestValue = value.toInteger()
}
def currentValue(String deviceFeature) {
}
}
+ def latestValue(String deviceFeature) {
+ if (deviceFeature == "battery") {
+ return batteryLatestValue
+ }
+ }
+
}
}
def setValue(String value) {
- this.presenceLatestValue = presence
println("the beacon sensor with id:$id is triggered to $value!")
+ this.presenceLatestValue = value
this.presence = value
this.currentPresence = value
}
//By Model Checker
def setValue(LinkedHashMap eventDataMap) {
if (eventDataMap["value"] != beaconSensors[0].presence) {
+ this.presenceLatestValue = eventDataMap["value"]
+ this.presence = eventDataMap["value"]
+ this.currentPresence = eventDataMap["value"]
beaconSensors[0].setValue(eventDataMap["value"])
- this.presenceLatestValue = beaconSensors[0].presenceLatestValue
- this.presence = beaconSensors[0].presence
- this.currentPresence = beaconSensors[0].presence
sendEvent(eventDataMap)
}
}
def each(Closure Input) {
beaconSensors.each(Input)
}
+ def sort(Closure Input) {
+ beaconSensors.sort(Input)
+ }
def find(Closure Input) {
beaconSensors.find(Input)
}
}
def setValue(String value) {
- this.carbonMonoxideLatestValue = carbonMonoxide
println("the carbon monoxide detector with id:$id is triggered to $value!")
+ this.carbonMonoxideLatestValue = value
this.carbonMonoxide = value
this.currentCarbonMonoxideValue = value
}
//By Model Checker
def setValue(LinkedHashMap eventDataMap) {
if (eventDataMap["value"] != carbonMonoxideDetectors[0].currentCarbonMonoxideValue) {
+ this.carbonMonoxideLatestValue = eventDataMap["value"]
+ this.carbonMonoxide = eventDataMap["value"]
+ this.currentCarbonMonoxideValue = eventDataMap["value"]
carbonMonoxideDetectors[0].setValue(eventDataMap["value"])
- this.carbonMonoxideLatestValue = carbonMonoxideDetectors[0].carbonMonoxideLatestValue
- this.carbonMonoxide = carbonMonoxideDetectors[0].currentCarbonMonoxideValue
- this.currentCarbonMonoxideValue = carbonMonoxideDetectors[0].currentCarbonMonoxideValue
sendEvent(eventDataMap)
}
}
def find(Closure Input) {
carbonMonoxideDetectors.find(Input)
}
+ def sort(Closure Input) {
+ carbonMonoxideDetectors.sort(Input)
+ }
def collect(Closure Input) {
carbonMonoxideDetectors.collect(Input)
}
private String label
private String displayName
private String color
+ private String currentSwitch
+ private int level
private int hue
private int saturation
+ private int colorTemperature
- ColorControl(String id, String label, String displayName, String color, int hue, int saturation) {
+ ColorControl(String id, String label, String displayName, String color, int hue, int saturation, int level, String currentSwitch, int colorTemperature) {
this.id = id
this.label = label
this.displayName = displayName
this.color = color
this.hue = hue
this.saturation = saturation
+ this.level = level
+ this.currentSwitch = currentSwitch
+ this.colorTemperature = colorTemperature
}
//By model checker
} else if ((name == "hue") && (value != this.hue)) {
this.hue = value.toInteger()
println("The hue level of the light is changed to $value!")
- } else if (value != this.saturation) {
+ } else if ((name == "saturation") && (value != this.saturation)) {
this.saturation = value.toInteger()
println("The saturation level of the light is changed to $value!")
+ } else if ((name == "level") && (value != this.level)) {
+ this.level = value.toInteger()
+ println("The level of the light is changed to $value!")
+ } else if ((name == "currentSwitch") && (value != this.currentSwitch)) {
+ this.currentSwitch = value
+ println("The light is changed to $value!")
+ } else if ((name == "colorTemperature") && (value != this.colorTemperature)) {
+ this.colorTemperature = value.toInteger()
+ println("The color temperature level of the light is changed to $value!")
}
}
}
}
+ def setLevel(int level) {
+ if (level != this.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) {
+ this.colorTemperature = colorTemperature
+ println("The color temperature level of the light is changed to $colorTemperature!")
+ sendEvent([name: "colorTemperature", value: "$colorTemperature", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ }
+ }
+
+ def on(String currentSwitch) {
+ if (currentSwitch != this.currentSwitch) {
+ this.currentSwitch = currentSwitch
+ println("The light is changed to $currentSwitch!")
+ sendEvent([name: "switch", value: "$currentSwitch", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ sendEvent([name: "switch.on", value: "$currentSwitch", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ }
+ }
+
+ def off(String currentSwitch) {
+ if (currentSwitch != this.currentSwitch) {
+ this.currentSwitch = currentSwitch
+ println("The light is changed to $currentSwitch!")
+ sendEvent([name: "switch", value: "$currentSwitch", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ sendEvent([name: "switch.off", value: "$currentSwitch", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ }
+ }
+
def currentValue(String deviceFeature) {
if (deviceFeature == "color") {
return color
return saturation
} else if (deviceFeature == "hue") {
return hue
+ } else if (deviceFeature == "level") {
+ return level
+ } else if (deviceFeature == "colorTemperature") {
+ return colorTemperature
+ } else if (deviceFeature == "switch") {
+ return currentSwitch
+ }
+ }
+
+ def latestValue(String deviceFeature) {
+ if (deviceFeature == "color") {
+ return color
+ } else if (deviceFeature == "saturation") {
+ return saturation
+ } else if (deviceFeature == "hue") {
+ return hue
+ } else if (deviceFeature == "level") {
+ return level
+ } else if (deviceFeature == "colorTemperature") {
+ return colorTemperature
+ } else if (deviceFeature == "switch") {
+ return currentSwitch
}
}
}
private String label = "colorControl0"
private String displayName = "colorControl0"
private String color = "red"
+ private String currentSwitch = "off"
+ private int level = 50
private int hue = 50
private int saturation = 50
+ private int colorTemperature = 15000
-
+
ColorControls(Closure sendEvent, int deviceNumbers) {
this.sendEvent = sendEvent
this.deviceNumbers = deviceNumbers
this.color = "blue"
}*/
- colorControls.add(new ColorControl(id, label, displayName, this.color, this.hue, this.saturation))
+ colorControls.add(new ColorControl(id, label, displayName, this.color, this.hue, this.saturation, this.level, this.currentSwitch, this.colorTemperature))
}
//Methods for closures
def find(Closure Input) {
colorControls.find(Input)
}
+ def sort(Closure Input) {
+ colorControls.sort(Input)
+ }
def collect(Closure Input) {
colorControls.collect(Input)
}
def setValue(LinkedHashMap eventDataMap) {
if (eventDataMap["name"] == "color") {
if (eventDataMap["value"] != colorControls[0].color) {
+ this.color = eventDataMap["value"]
colorControls[0].setValue(eventDataMap["value"], "color")
- this.color = colorControls[0].color
sendEvent(eventDataMap)
}
} else if (eventDataMap["name"] == "hue") {
- if (eventDataMap["value"] != colorControls[0].hue) {
+ if (eventDataMap["value"].toInteger() != colorControls[0].hue) {
+ this.hue = eventDataMap["value"].toInteger()
colorControls[0].setValue(eventDataMap["value"], "hue")
- this.hue = colorControls[0].hue
sendEvent(eventDataMap)
}
- } else {
- if (eventDataMap["value"] != colorControls[0].saturation) {
+ } else if (eventDataMap["name"] == "saturation") {
+ if (eventDataMap["value"].toInteger() != colorControls[0].saturation) {
+ this.saturation = eventDataMap["value"].toInteger()
colorControls[0].setValue(eventDataMap["value"], "saturation")
- this.saturation = colorControls[0].saturation
+ sendEvent(eventDataMap)
+ }
+ } else if (eventDataMap["name"] == "switch") {
+ if (eventDataMap["value"] != colorControls[0].currentSwitch) {
+ this.currentSwitch = eventDataMap["value"]
+ colorControls[0].setValue(eventDataMap["value"], "switch")
+ sendEvent(eventDataMap)
+ }
+ } else if (eventDataMap["name"] == "colorTemperature") {
+ if (eventDataMap["value"].toInteger() != colorControls[0].colorTemperature) {
+ this.colorTemperature = eventDataMap["value"].toInteger()
+ colorControls[0].setValue(eventDataMap["value"], "colorTemperature")
+ sendEvent(eventDataMap)
+ }
+ } else if (eventDataMap["name"] == "level") {
+ if (eventDataMap["value"].toInteger() != colorControls[0].level) {
+ this.level = eventDataMap["value"].toInteger()
+ colorControls[0].setValue(eventDataMap["value"], "level")
sendEvent(eventDataMap)
}
}
//methods
def setColor(String color) {
if (color != this.color) {
- colorControls[0].setColor(color)
this.color = color
+ colorControls[0].setColor(color)
}
}
def setHue(int hue) {
- if (hue != this.hue) {
+ if (hue != this.hue) {
+ this.hue = hue
colorControls[0].setHue(hue)
- this.hue = hue
}
}
def setSaturation(int saturation) {
if (saturation != this.saturation) {
- colorControls[0].setSaturation(saturation)
this.saturation = saturation
+ colorControls[0].setSaturation(saturation)
}
}
+ def setLevel(int level) {
+ if (level != this.level) {
+ this.level = level
+ colorControls[0].setLevel(level)
+ }
+ }
+
+ def setColorTemperature(String colorTemperature) {
+ if (colorTemperature != this.colorTemperature) {
+ this.colorTemperature = colorTemperature
+ colorControls[0].setColorTemperature(colorTemperature)
+ }
+ }
+
+ def on(String currentSwitch) {
+ if (currentSwitch != this.currentSwitch) {
+ this.currentSwitch = currentSwitch
+ colorControls[0].on(currentSwitch)
+ }
+ }
+
+ def off(String currentSwitch) {
+ if (currentSwitch != this.currentSwitch) {
+ this.currentSwitch = currentSwitch
+ colorControls[0].off(currentSwitch)
+ }
+ }
+
def currentValue(String deviceFeature) {
colorControls[0].currentValue(deviceFeature)
}
+ def latestValue(String deviceFeature) {
+ colorControls[0].latestValue(deviceFeature)
+ }
+
def getAt(int ix) {
colorControls[ix]
}
private String currentContact
private String latestValue
private String alarmState
+ private List events = []
+ private List timeOfEvents = []
ContactSensor(String id, String label, String displayName, String contactState, String currentContact, String alarmState, String latestValue) {
}
def setValue(String value) {
- this.latestValue = contactState
println("the contact sensor with id:$id is triggered to $value!")
this.contactState = value
this.currentContact = value
+ this.latestValue = value
+ this.events.add(eventDataMap)
+ this.timeOfEvents.add(System.currentTimeMillis())
+ }
+
+ def eventsSince(Date dateObj) {
+ def List happenedEvents = []
+ def sinceThen = dateObj.time
+ for (int i = 0;i < timeOfEvents.size();i++) {
+ if (timeOfEvents[i]>=sinceThen)
+ happenedEvents.add(events[i])
+ }
+ return happenedEvents
}
def on() {
}
}
+ def currentState(String deviceFeature) {
+ if (deviceFeature == "contact") {
+ return contactState
+ }
+ }
+
def latestValue(String deviceFeature) {
if (deviceFeature == "contact") {
return latestValue
def find(Closure Input) {
contacts.find(Input)
}
+ def sort(Closure Input) {
+ contacts.sort(Input)
+ }
def collect(Closure Input) {
contacts.collect(Input)
}
//By Model Checker
def setValue(LinkedHashMap eventDataMap) {
if (eventDataMap["value"] != contacts[0].contactState) {
+ this.latestValue = eventDataMap["value"]
+ this.contactState = eventDataMap["value"]
+ this.currentContact = eventDataMap["value"]
contacts[0].setValue(eventDataMap["value"])
- this.latestValue = contacts[0].latestValue
- this.contactState = contacts[0].contactState
- this.currentContact = contacts[0].contactState
sendEvent(eventDataMap)
}
}
def on() {
- contacts[0].on()
this.alarmState = "armed"
+ contacts[0].on()
}
def off() {
- contacts[0].off()
this.alarmState = "not armed"
+ contacts[0].off()
}
def currentValue(String deviceFeature) {
contacts[0].currentValue(deviceFeature)//It is called if we have only one device
}
+ def currentState(String deviceFeature) {
+ contacts[0].currentState(deviceFeature)//It is called if we have only one device
+ }
+
def latestValue(String deviceFeature) {
contacts[0].latestValue(deviceFeature)//It is called if we have only one device
}
this.label = label
this.displayName = displayName
this.doorState = doorState
+ this.doorLatestValue = doorLatestValue
}
//By Apps
def open() {
if (doorState != "open") {
println("the door with id:$id is open!")
- this.doorLatestValue = this.doorState
+ this.doorLatestValue = "open"
this.doorState = "open"
sendEvent([name: "doorControl", value: "open", deviceId: this.id, descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ sendEvent([name: "doorControl.open", value: "open", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
}
}
if (doorState != "open") {
def task = timers.runAfter(metaData["delay"]) {
println("the door with id:$id is open!")
- this.doorLatestValue = this.doorState
+ this.doorLatestValue = "open"
this.doorState = "open"
sendEvent([name: "doorControl", value: "open", deviceId: this.id, descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ sendEvent([name: "doorControl.open", value: "open", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
}
}
}
def close() {
if (doorState != "closed") {
println("the door with id:$id is closed!")
- this.doorLatestValue = this.doorState
+ this.doorLatestValue = "closed"
this.doorState = "closed"
sendEvent([name: "doorControl", value: "closed", deviceId: this.id, descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ sendEvent([name: "doorControl.closed", value: "closed", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
}
}
if (doorState != "closed") {
def task = timers.runAfter(metaData["delay"]) {
println("the door with id:$id is closed!")
- this.doorLatestValue = this.doorState
+ this.doorLatestValue = "closed"
this.doorState = "closed"
sendEvent([name: "doorControl", value: "closed", deviceId: this.id, descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ sendEvent([name: "doorControl.closed", value: "closed", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
}
}
}
//By Model Checker
def setValue(String value) {
println("the door with id:$id is $value!")
- this.doorLatestValue = this.doorState
+ this.doorLatestValue = value
this.doorState = value
}
def find(Closure Input) {
doorControls.find(Input)
}
+ def sort(Closure Input) {
+ doorControls.sort(Input)
+ }
def collect(Closure Input) {
doorControls.collect(Input)
}
//By Model Checker
def setValue(LinkedHashMap eventDataMap) {
if (eventDataMap["value"] != doorControls[0].doorState) {
+ this.doorState = eventDataMap["value"]
+ this.doorLatestValue = eventDataMap["value"]
doorControls[0].setValue(eventDataMap["value"])
- this.doorState = doorControls[0].doorState
sendEvent(eventDataMap)
}
}
}
}
+ def latestValue(String deviceFeature) {
+ if (deviceFeature == "energy") {
+ return energy
+ }
+ }
}
//By Model Checker
def setValue(LinkedHashMap eventDataMap) {
- if (eventDataMap["value"] != energyMeters[0].energy) {
- energyMeters[0].setValue(eventDataMap["value"])
- this.energy = energyMeters[0].energy
- this.currentEnergy = energyMeters[0].currentEnergy
+ if (eventDataMap["value"].toInteger() != energyMeters[0].energy) {
+ this.energy = eventDataMap["value"].toInteger()
+ this.currentEnergy = eventDataMap["value"].toInteger()
+ energyMeters[0].setValue(eventDataMap["value"])
sendEvent(eventDataMap)
}
}
def find(Closure Input) {
energyMeters.find(Input)
}
+ def sort(Closure Input) {
+ energyMeters.sort(Input)
+ }
def collect(Closure Input) {
energyMeters.collect(Input)
}
energyMeters[0].currentValue(deviceFeature)//It is called if we have only one device
}
+ def latestValue(String deviceFeature) {
+ energyMeters[0].latestValue(deviceFeature)//It is called if we have only one device
+ }
+
def getAt(int ix) {
energyMeters[ix]
}
@Field def log = new Logger()
//Create a global variable for optional property
@Field def optional = false //by default for now
+//Global Object for class AtomicState!
+@Field def atomicState = [history: "15:00"]
//Global variables for files
@Field boolVariable5
+
/////Input Methods/////
//input "",""
def input(String name, String type) {
lockObjects=lockObjects+1
- settings.put(metaData['name'], metaData['name'])
+ settings.put(metaData['name'], new Locks({}, 1))
if (App == "App1") {
extractedObjectsApp1.append("//Object for class lock!\n")
alarmObjects=alarmObjects+1
- settings.put(metaData['name'], metaData['name'])
+ settings.put(metaData['name'], new Alarms({}, 1))
if (App == "App1") {
extractedObjectsApp1.append("//Object for class alarm!\n")
batteryObjects=batteryObjects+1
- settings.put(metaData['name'], metaData['name'])
+ settings.put(metaData['name'], new Batteries({}, 1))
if (App == "App1") {
extractedObjectsApp1.append("//Object for class Battery!\n")
beaconSensorObjects=beaconSensorObjects+1
- settings.put(metaData['name'], metaData['name'])
+ settings.put(metaData['name'], new BeaconSensors({}, 1))
if (App == "App1") {
extractedObjectsApp1.append("//Object for class beacon sensor!\n")
carbonMonoxideDetectorObjects=carbonMonoxideDetectorObjects+1
- settings.put(metaData['name'], metaData['name'])
+ settings.put(metaData['name'], new CarbonMonoxideDetectors({}, 1))
if (App == "App1") {
extractedObjectsApp1.append("//Object for class carbon monoxide detector!\n")
colorControlObjects=colorControlObjects+1
- settings.put(metaData['name'], metaData['name'])
+ settings.put(metaData['name'], new ColorControls({}, 1))
if (App == "App1") {
extractedObjectsApp1.append("//Object for class color control!\n")
contactObjects=contactObjects+1
- settings.put(metaData['name'], metaData['name'])
+ settings.put(metaData['name'], new ContactSensors({}, 1))
if (App == "App1") {
extractedObjectsApp1.append("//Object for class contactSensor!\n")
doorControlObjects=doorControlObjects+1
- settings.put(metaData['name'], metaData['name'])
+ settings.put(metaData['name'], new DoorControls({}, 1))
if (App == "App1") {
extractedObjectsApp1.append("//Object for class door control!\n")
energyMeterObjects=energyMeterObjects+1
- settings.put(metaData['name'], metaData['name'])
+ settings.put(metaData['name'], new EnergyMeters({}, 1))
if (App == "App1") {
extractedObjectsApp1.append("//Object for class energy meter!\n")
illuminanceMeasurementObjects=illuminanceMeasurementObjects+1
- settings.put(metaData['name'], metaData['name'])
+ settings.put(metaData['name'], new IlluminanceMeasurements({}, 1))
if (App == "App1") {
extractedObjectsApp1.append("//Object for class illuminance measurement!\n")
accelerationSensorObjects=accelerationSensorObjects+1
- settings.put(metaData['name'], metaData['name'])
+ settings.put(metaData['name'], new AccelerationSensors({}, 1))
if (App == "App1") {
extractedObjectsApp1.append("//Object for class Acceleration Sensor!\n")
motionSensorObjects=motionSensorObjects+1
- settings.put(metaData['name'], metaData['name'])
+ settings.put(metaData['name'], new MotionSensors({}, 1))
if (App == "App1") {
extractedObjectsApp1.append("//Object for class Motion Sensor!\n")
musicPlayerObjects=musicPlayerObjects+1
- settings.put(metaData['name'], metaData['name'])
+ settings.put(metaData['name'], new MusicPlayers({}, 1))
if (App == "App1") {
extractedObjectsApp1.append("//Object for class music player!\n")
powerMeterObjects=powerMeterObjects+1
- settings.put(metaData['name'], metaData['name'])
+ settings.put(metaData['name'], new PowerMeters({}, 1))
if (App == "App1") {
extractedObjectsApp1.append("//Object for class power meter!\n")
presenceSensorObjects=presenceSensorObjects+1
- settings.put(metaData['name'], metaData['name'])
+ settings.put(metaData['name'], new PresenceSensors({}, 1))
if (App == "App1") {
extractedObjectsApp1.append("//Object for class presence sensor!\n")
humidityMeasurementObjects=humidityMeasurementObjects+1
- settings.put(metaData['name'], metaData['name'])
+ settings.put(metaData['name'], new RelativeHumidityMeasurements({}, 1))
if (App == "App1") {
extractedObjectsApp1.append("//Object for class humidity measurement!\n")
relaySwitchObjects=relaySwitchObjects+1
- settings.put(metaData['name'], metaData['name'])
+ settings.put(metaData['name'], new RelaySwitches({}, 1))
if (App == "App1") {
extractedObjectsApp1.append("//Object for class relay switch!\n")
sleepSensorObjects=sleepSensorObjects+1
- settings.put(metaData['name'], metaData['name'])
+ settings.put(metaData['name'], new SleepSensors({}, 1))
if (App == "App1") {
extractedObjectsApp1.append("//Object for class sleep sensor!\n")
smokeDetectorObjects=smokeDetectorObjects+1
- settings.put(metaData['name'], metaData['name'])
+ settings.put(metaData['name'], new SmokeDetectors({}, 1))
if (App == "App1") {
extractedObjectsApp1.append("//Object for class smoke detector!\n")
stepSensorObjects=stepSensorObjects+1
- settings.put(metaData['name'], metaData['name'])
+ settings.put(metaData['name'], new StepSensors({}, 1))
if (App == "App1") {
extractedObjectsApp1.append("//Object for class step sensor!\n")
switchObjects=switchObjects+1
- settings.put(metaData['name'], metaData['name'])
+ settings.put(metaData['name'], new Switches({}, 1))
if (App == "App1") {
extractedObjectsApp1.append("//Object for class switch!\n")
switchLevelObjects=switchLevelObjects+1
- settings.put(metaData['name'], metaData['name'])
+ settings.put(metaData['name'], new SwitchLevels({}, 1))
if (App == "App1") {
extractedObjectsApp1.append("//Object for class switch level!\n")
temperatureMeasurementObjects=temperatureMeasurementObjects+1
- settings.put(metaData['name'], metaData['name'])
+ settings.put(metaData['name'], new TemperatureMeasurements({}, 1))
if (App == "App1") {
extractedObjectsApp1.append("//Object for class temperature measurement!\n")
thermostatObjects=thermostatObjects+1
- settings.put(metaData['name'], metaData['name'])
+ settings.put(metaData['name'], new Thermostats({}, 1))
if (App == "App1") {
extractedObjectsApp1.append("//Object for class thermostat!\n")
valveObjects=valveObjects+1
- settings.put(metaData['name'], metaData['name'])
+ settings.put(metaData['name'], new Valves({}, 1))
if (App == "App1") {
extractedObjectsApp1.append("//Object for class valve!\n")
speechSynthesisObjects=speechSynthesisObjects+1
- settings.put(metaData['name'], metaData['name'])
+ settings.put(metaData['name'], new SpeechSynthesises({}, 1))
if (App == "App1") {
extractedObjectsApp1.append("//Object for class speech synthesis!\n")
waterSensorObjects=waterSensorObjects+1
- settings.put(metaData['name'], metaData['name'])
+ settings.put(metaData['name'], new WaterSensors({}, 1))
if (App == "App1") {
extractedObjectsApp1.append("//Object for class water sensor!\n")
touchSensorObjects=touchSensorObjects+1
- settings.put(metaData['name'], metaData['name'])
+ settings.put(metaData['name'], new NfcTouch({}, 1))
if (App == "App1") {
extractedObjectsApp1.append("//Object for class Touch Sensor!\n")
imageCaptureObjects=imageCaptureObjects+1
- settings.put(metaData['name'], metaData['name'])
+ settings.put(metaData['name'], new ImageCaptures({}, 1))
if (App == "App1") {
extractedObjectsApp1.append("//Object for class Image Capture!\n")
mobilePresenceObjects=mobilePresenceObjects+1
- settings.put(metaData['name'], metaData['name'])
+ settings.put(metaData['name'], new MobilePresences({}, 1))
if (App == "App1") {
extractedObjectsApp1.append("//Object for class mobile presence!\n")
aeonKeyFobObjects=aeonKeyFobObjects+1
- settings.put(metaData['name'], metaData['name'])
+ settings.put(metaData['name'], new AeonKeyFobs({}, 1))
if (App == "App1") {
extractedObjectsApp1.append("//Object for class aeon key fob!\n")
this[mode5] = userInput
}
- modeVariables=modeVariables+1
+ if (modeVariables != 5)
+ modeVariables=modeVariables+1
+ else
+ modeVariables=0
+
settings.put(metaData['name'], metaData['name'])
this[decimal5] = userInput
}
- decimalVariables=decimalVariables+1
+ if (decimalVariables != 5)
+ decimalVariables=decimalVariables+1
+ else
+ decimalVariables=0
settings.put(metaData['name'], metaData['name'])
this[text5] = userInput
}
- textVariables=textVariables+1
+ if (textVariables != 5)
+ textVariables=textVariables+1
+ else
+ textVariables=0
+
settings.put(metaData['name'], metaData['name'])
this[number5] = userInput
}
- numberVariables=numberVariables+1
+
+ if (numberVariables != 5)
+ numberVariables=numberVariables+1
+ else
+ numberVariables=0
+
settings.put(metaData['name'], metaData['name'])
this[time5] = userInput
}
- timeVariables=timeVariables+1
+ if (timeVariables != 5)
+ timeVariables=timeVariables+1
+ else
+ timeVariables=0
settings.put(metaData['name'], metaData['name'])
case "enum":
if (metaData['options'] != null)
modes = metaData['options']
- else // If it is not named 'options' then it is captured as 'metadata'
+ else if (metaData['metadata'] != null) { // If it is not named 'options' then it is captured as 'metadata'
modes = metaData['metadata']
+ modes = modes['values']
+ }
def userInput = modes[0]
if (enumVariables == 0) {
this[enum5] = userInput
}
- enumVariables=enumVariables+1
+ if (enumVariables != 5)
+ enumVariables=enumVariables+1
+ else
+ enumVariables=0
+
settings.put(metaData['name'], metaData['name'])
this[bool5] = userInput
}
- boolVariables=boolVariables+1
+ if (boolVariables != 5)
+ boolVariables=boolVariables+1
+ else
+ boolVariables=0
+
settings.put(metaData['name'], metaData['name'])
this[phone5] = userInput
}
- phoneVariables=phoneVariables+1
+ if (phoneVariables != 5)
+ phoneVariables=phoneVariables+1
+ else
+ phoneVariables=0
settings.put(metaData['name'], metaData['name'])
this[contact5] = userInput
}
- contactVariables=contactVariables+1
+ if (contactVariables != 5)
+ contactVariables=contactVariables+1
+ else
+ contactVariables=0
settings.put(metaData['name'], metaData['name'])
def preferences(Closure inputData) {
find(inputData) //Run the closure to extract pages/sections/inputMethods
- if (App == "App1") {
+ settings.put("END", "END")
+ if (App == "App1") {
extractedObjectsConstructorApp1.append("//Global variable for settings!\n")
- extractedObjectsConstructorApp1.append("settings = $settings\n")
+ extractedObjectsConstructorApp1.append("settings = [")
+ settings.each{
+ key, value ->
+ if (value != "END")
+ extractedObjectsConstructorApp1.append("$key: $key, ")
+ else
+ extractedObjectsConstructorApp1.append("END: \"END\"]\n")
+ }
} else {
extractedObjectsConstructorApp2.append("//Global variable for settings!\n")
- extractedObjectsConstructorApp2.append("settings = $settings\n")
+ extractedObjectsConstructorApp2.append("settings = [")
+ settings.each{
+ key, value ->
+ if (value != "END")
+ extractedObjectsConstructorApp2.append("$key: $key, ")
+ else
+ extractedObjectsConstructorApp2.append("END: \"END\"]\n")
+ }
}
}
find(inputData) //Run the closure to extract inputMethods
}
+def section(LinkedHashMap metaData, String data, Closure inputData) {
+ find(inputData)
+}
+
def mappings(Closure inputData) {
println("//IGNORE--some data//")
}
@Field def appObject = new Touched(sendEvent, 0)
//Create a global list for events
//@Field def evt = []
-//Global Object for class AtomicState!
-@Field def atomicState = new AtomicState()
//Global Object for class Touch Sensor!
@Field def touchSensorObject = new NfcTouch(sendEvent, 1)
//Global Object for class switch!
def settings
//Zip code
def zipCode = 92617
+//atomicState variable
+def atomicState = [version: "1.01"]
--- /dev/null
+String s = "smoke.detected"
+if (s.contains("smoke"))
+ println(s)
}
}
+ def latestValue(String deviceFeature) {
+ if (deviceFeature == "illuminance") {
+ return illuminance
+ }
+ }
+
}
//By Model Checker
def setValue(LinkedHashMap eventDataMap) {
- if (eventDataMap["value"] != illuminanceMeasurements[0].illuminance) {
+ if (eventDataMap["value"].toInteger() != illuminanceMeasurements[0].illuminance) {
+ this.illuminance = eventDataMap["value"].toInteger()
+ this.currentIlluminance = eventDataMap["value"].toInteger()
illuminanceMeasurements[0].setValue(eventDataMap["value"])
- this.illuminance = illuminanceMeasurements[0].illuminance
- this.currentIlluminance = illuminanceMeasurements[0].illuminance
sendEvent(eventDataMap)
}
}
def find(Closure Input) {
illuminanceMeasurements.find(Input)
}
+ def sort(Closure Input) {
+ illuminanceMeasurements.sort(Input)
+ }
def collect(Closure Input) {
illuminanceMeasurements.collect(Input)
}
illuminanceMeasurements[0].currentValue(deviceFeature)//It is called if we have only one device
}
+ def latestValue(String deviceFeature) {
+ illuminanceMeasurements[0].latestValue(deviceFeature)//It is called if we have only one device
+ }
+
def getAt(int ix) {
illuminanceMeasurements[ix]
}
def find(Closure Input) {
imageCaptureSensors.find(Input)
}
+ def sort(Closure Input) {
+ imageCaptureSensors.sort(Input)
+ }
def collect(Closure Input) {
imageCaptureSensors.collect(Input)
}
def alarmOn() {
if (alarmState != "armed") {
- imageCaptureSensors[0].alarmOn()
this.alarmState = "armed"
+ imageCaptureSensors[0].alarmOn()
}
}
def alarmOff() {
if (alarmState != "not armed") {
- imageCaptureSensors[0].alarmOff()
this.alarmState = "not armed"
+ imageCaptureSensors[0].alarmOff()
}
}
private def modes
private def timeZone
private String mode
+ private String name
private List contacts
private List phoneNumbers
def sendEvent
this.phoneNumbers = [9495379373]
this.sendEvent = sendEvent
this.timeZone = TimeZone.getTimeZone("America/New_York")
+ this.name = "hub0"
}
//By Model Checker
def lock() {
if (lockState != "locked") {
println("the door with id:$id is locked!")
+<<<<<<< HEAD
+=======
//this.lockLatestValue = this.lockState
+>>>>>>> a02c9807815a35c0f57241ee6510a3d312499049
this.lockLatestValue = "locked"
this.lockState = "locked"
this.currentLock = "locked"
sendEvent([name: "lock", value: "locked", deviceId: this.id, descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ sendEvent([name: "lock.locked", value: "locked", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
}
}
if (lockState != "locked") {
def task = timers.runAfter(metaData["delay"]) {
println("the door with id:$id is locked!")
+<<<<<<< HEAD
+=======
//this.lockLatestValue = this.lockState
+>>>>>>> a02c9807815a35c0f57241ee6510a3d312499049
this.lockLatestValue = "locked"
this.lockState = "locked"
this.currentLock = "locked"
sendEvent([name: "lock", value: "locked", deviceId: this.id, descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ sendEvent([name: "lock.locked", value: "locked", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
}
}
}
def unlock() {
if (lockState != "unlocked") {
println("the door with id:$id is unlocked!")
+<<<<<<< HEAD
+=======
//this.lockLatestValue = this.lockState
+>>>>>>> a02c9807815a35c0f57241ee6510a3d312499049
this.lockLatestValue = "unlocked"
this.lockState = "unlocked"
this.currentLock = "unlocked"
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
sendEvent([name: "lock", value: "unlocked", deviceId: this.id, descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+<<<<<<< HEAD
+ sendEvent([name: "lock.unlocked", value: "unlocked", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+=======
+>>>>>>> a02c9807815a35c0f57241ee6510a3d312499049
}
}
if (lockState != "unlocked") {
def task = timers.runAfter(metaData["delay"]) {
println("the door with id:$id is locked!")
+<<<<<<< HEAD
+ this.lockLatestValue = "unlocked"
+ this.lockState = "unlocked"
+ this.currentLock = "unlocked"
+ sendEvent([name: "unlock", value: "unlocked", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ sendEvent([name: "lock", value: "unlocked", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ sendEvent([name: "lock.unlocked", value: "unlocked", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+=======
//this.lockLatestValue = this.lockState
this.lockLatestValue = "locked"
this.lockState = "locked"
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
sendEvent([name: "lock", value: "unlocked", deviceId: this.id, descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+>>>>>>> a02c9807815a35c0f57241ee6510a3d312499049
}
}
}
//By Model Checker
def setValue(String value) {
println("the door with id:$id is $value!")
- this.lockLatestValue = this.lockState
+ this.lockLatestValue = value
this.lockState = value
this.currentLock = value
}
def find(Closure Input) {
locks.find(Input)
}
+ def sort(Closure Input) {
+ locks.sort(Input)
+ }
def collect(Closure Input) {
locks.collect(Input)
}
--- /dev/null
+/////////////////////////////////////////////////////////////////////
+def createAccessToken() {
+ state.accessToken = "accessToken"
+ return state.accessToken
+}
for (int i = 0;i < app2.eventList.size();i++) {
if (app2.eventList[i] == name) {
def event = new Event(value, name, deviceId, descriptionText, displayed, linkText, linkText, isStateChange, unit, data)
- app2.functionList[i](event)
+ if (app2.functionList[i] instanceof String) {
+ String toCall = app2.functionList[i]
+ app2."$toCall"(event)
+ }
+ else
+ app2.functionList[i](event)
}
}
for (int i = 0;i < app1.eventList.size();i++) {
if (app1.eventList[i] == name) {
def event = new Event(value, name, deviceId, descriptionText, displayed, linkText, linkText, isStateChange, unit, data)
- app1.functionList[i](event)
+ if (app1.functionList[i] instanceof String) {
+ String toCall = app1.functionList[i]
+ app1."$toCall"(event)
+ }
+ else
+ app1.functionList[i](event)
}
}
}
--- /dev/null
+/////////////////////////////////////////////////////////////////////
+def runOnce(Date date, Closure methodToCall) {
+ methodTocall()
+}
}
}
}
+
+def sendNotificationToContacts(String text, String recipients, LinkedHashMap metaData) {
+ for (int i = 0;i < recipients.size();i++) {
+ for (int j = 0;j < location.contacts.size();j++) {
+ if (recipients[i] == location.contacts[j]) {
+ println("Sending \""+text+"\" to "+location.phoneNumbers[j].toString())
+ }
+ }
+ }
+}
/////////////////////////////////////////////////////////////////////
def setLocationMode(String mode) {
- location.mode = mode
+ location.setValue([name: "Location", value: "$mode", deviceId: "locationID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ location.setValue([name: "mode", value: "$mode", deviceId: "locationID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
}
eventList.add(event)
functionList.add(FunctionToCall)
}
+////subscribe(obj, event, nameOfFunc)
+def subscribe(Object obj, String event, String nameOfFunction) {
+ objectList.add(obj)
+ eventList.add(event)
+ functionList.add(nameOfFunction)
+}
////subscribe(obj, event, func, data)
def subscribe(Object obj, String event, Closure FunctionToCall, LinkedHashMap metaData) {
objectList.add(obj)
}
}
+def unschedule(String nameOfFunctionToUnschedule) {
+ for (int i = 0;i < timersFuncList.size();i++) {
+ if (timersFuncList[i] instanceof String) {
+ if (timersFuncList[i] == nameOfFunctionToUnschedule) {
+ if (timersList != null)
+ timersList[i].cancel()
+ }
+ }
+ }
+}
+
def unschedule() {
for (int i = 0;i < timersFuncList.size();i++) {
def find(Closure Input) {
mobilePresences.find(Input)
}
+ def sort(Closure Input) {
+ mobilePresences.sort(Input)
+ }
def collect(Closure Input) {
mobilePresences.collect(Input)
}
}
def setValue(String value) {
- this.motionLatestValue = motion
println("the motion sensor with id:$id is triggered to $value!")
+ this.motionLatestValue = value
this.motion = value
this.currentMotion = value
this.states.add(value)
//By Model Checker
def setValue(LinkedHashMap eventDataMap) {
if (eventDataMap["value"] != motionSensors[0].motion) {
+ this.motionLatestValue = eventDataMap["value"]
+ this.motion = eventDataMap["value"]
+ this.currentMotion = eventDataMap["value"]
motionSensors[0].setValue(eventDataMap["value"])
- this.motionLatestValue = motionSensors[0].motionLatestValue
- this.motion = motionSensors[0].motion
- this.currentMotion = motionSensors[0].motion
sendEvent(eventDataMap)
}
}
def find(Closure Input) {
motionSensors.find(Input)
}
+ def sort(Closure Input) {
+ motionSensors.sort(Input)
+ }
def collect(Closure Input) {
motionSensors.collect(Input)
}
public class MusicPlayer {
+ def sendEvent
private String id
private String label
private String displayName
if (mute != "muted") {
println("the music player with id:$id is muted!")
this.mute = "muted"
- sendEvent([name: "mute", value: "mute", deviceId: this.id, descriptionText: "",
+ sendEvent([name: "mute", value: "muted", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ sendEvent([name: "mute.muted", value: "muted", deviceId: this.id, descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
}
}
this.status = "playing"
sendEvent([name: "status", value: "playing", deviceId: this.id, descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ sendEvent([name: "status.playing", value: "playing", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
}
sendEvent([name: "trackDescription", value: "someDescriptions", deviceId: this.id, descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
this.status = "paused"
sendEvent([name: "status", value: "paused", deviceId: this.id, descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ sendEvent([name: "status.paused", value: "paused", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
}
}
def play() {
this.status = "playing"
sendEvent([name: "status", value: "playing", deviceId: this.id, descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ sendEvent([name: "status.playing", value: "playing", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
}
}
def playTrack(String trackToPlay) {
this.status = "playing"
sendEvent([name: "status", value: "playing", deviceId: this.id, descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ sendEvent([name: "status.playing", value: "playing", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
}
sendEvent([name: "trackDescription", value: "someDescriptions", deviceId: this.id, descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
this.status = "playing"
sendEvent([name: "status", value: "playing", deviceId: this.id, descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ sendEvent([name: "status.playing", value: "playing", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
}
sendEvent([name: "trackDescription", value: "someDescriptions", deviceId: this.id, descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
this.status = "playing"
sendEvent([name: "status", value: "playing", deviceId: this.id, descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ sendEvent([name: "status.playing", value: "playing", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
}
}
def setLevel(int level) {
this.status = "playing"
sendEvent([name: "status", value: "playing", deviceId: this.id, descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ sendEvent([name: "status.playing", value: "playing", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
}
sendEvent([name: "trackDescription", value: "someDescriptions", deviceId: this.id, descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
this.status = "stopped"
sendEvent([name: "status", value: "stopped", deviceId: this.id, descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ sendEvent([name: "status.stopped", value: "stopped", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ }
+ }
+ def playText(String text) {
+ println("the music player with id:$id is playing the text:$text!")
+ if (status != "playing") {
+ this.status = "playing"
+ sendEvent([name: "status", value: "playing", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ sendEvent([name: "status.playing", value: "playing", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
}
}
return status
}
}
+
+ def latestValue(String deviceFeature) {
+ if (deviceFeature == "musicPlayer") {
+ return status
+ }
+ }
}
} else {
this.status = "stopped"
}
+<<<<<<< HEAD
+
+=======
def initTrack = Verify.getIntFromList(1, 2, 3)
this.trackNumber = initTrack
def initData = Verify.getBoolean()
} else {
this.trackDescription = "someOtherDescriptions"
}*/
+>>>>>>> a02c9807815a35c0f57241ee6510a3d312499049
musicPlayers.add(new MusicPlayer(sendEvent, id, label, displayName, this.level, this.mute, this.status, this.trackNumber, this.trackData, this.trackDescription))
}
def setValue(LinkedHashMap eventDataMap) {
if (eventDataMap["name"] == "status") {
if (eventDataMap["value"] != musicPlayers[0].status) {
+ this.status = eventDataMap["value"]
musicPlayers[0].setValue(eventDataMap["value"], "status")
- this.status = musicPlayers[0].status
sendEvent(eventDataMap)
}
} else if (eventDataMap["name"] == "level") {
- if (eventDataMap["value"] != musicPlayers[0].level) {
+ if (eventDataMap["value"].toInteger() != musicPlayers[0].level) {
+ this.level = eventDataMap["value"].toInteger()
musicPlayers[0].setValue(eventDataMap["value"], "level")
- this.level = musicPlayers[0].level
sendEvent(eventDataMap)
}
} else if (eventDataMap["name"] == "trackDescription") {
if (eventDataMap["value"] != musicPlayers[0].trackDescription) {
+ this.trackDescription = eventDataMap["value"]
musicPlayers[0].setValue(eventDataMap["value"], "trackDescription")
- this.trackDescription = musicPlayers[0].trackDescription
sendEvent(eventDataMap)
}
} else if (eventDataMap["name"] == "trackData") {
if (eventDataMap["value"] != musicPlayers[0].trackData) {
- musicPlayers[0].setValue(eventDataMap["value"], "trackData")
- this.trackData = musicPlayers[0].trackData
+ this.trackData = eventDataMap["value"]
+ musicPlayers[0].setValue(eventDataMap["value"], "trackData")
sendEvent(eventDataMap)
}
} else if (eventDataMap["name"] == "mute") {
if (eventDataMap["value"] != musicPlayers[0].mute) {
+ this.mute = eventDataMap["value"]
musicPlayers[0].setValue(eventDataMap["value"], "mute")
- this.mute = musicPlayers[0].mute
sendEvent(eventDataMap)
}
}
def find(Closure Input) {
musicPlayers.find(Input)
}
+ def sort(Closure Input) {
+ musicPlayers.sort(Input)
+ }
def collect(Closure Input) {
musicPlayers.collect(Input)
}
//methods
def mute() {
if (mute != "muted") {
- musicPlayers[0].mute()
this.mute = "muted"
+ musicPlayers[0].mute()
}
}
def nextTrack() {
- musicPlayers[0].nextTrack()
if (status != "playing") {
this.status = "playing"
}
- this.trackNumber = musicPlayers[0].trackNumber
+ this.trackNumber = this.trackNumber+1
+ musicPlayers[0].nextTrack()
}
def pause() {
if (status != "paused") {
- musicPlayers[0].pause()
this.status = "paused"
+ musicPlayers[0].pause()
}
}
def play() {
if (status != "playing") {
- musicPlayers[0].play()
this.status = "playing"
+ musicPlayers[0].play()
}
}
def playTrack(String trackToPlay) {
- musicPlayers[0].playTrack(trackToPlay)
if (status != "playing") {
this.status = "playing"
}
- this.trackNumber = musicPlayers[0].trackNumber
+ musicPlayers[0].playTrack(trackToPlay)
}
def previousTrack() {
- musicPlayers[0].previousTrack()
if (status != "playing") {
this.status = "playing"
}
- this.trackNumber = musicPlayers[0].trackNumber
+ if (this.trackNumber != 1)
+ this.trackNumber = this.trackNumber-1
+ musicPlayers[0].previousTrack()
}
def restoreTrack(String trackToRestore) {
musicPlayers[0].restoreTrack(trackToRestore)
}
def resumeTrack(String trackToResume) {
- musicPlayers[0].resumeTrack(trackToResume)
if (status != "playing") {
this.status = "playing"
}
+ musicPlayers[0].resumeTrack(trackToResume)
}
def setLevel(int level) {
- if (level != this.level) {
+ if (level != this.level) {
+ this.level = level
musicPlayers[0].setLevel(level)
- this.level = level
}
}
def setTrack(String trackToSet) {
- musicPlayers[0].setTrack(trackToSet)
if (status != "playing") {
this.status = "playing"
}
- this.trackNumber = musicPlayers[0].trackNumber
+ musicPlayers[0].setTrack(trackToSet)
}
def stop() {
if (status != "stopped") {
- musicPlayers[0].stop()
this.status = "stopped"
+ musicPlayers[0].stop()
}
}
+ def playText(String text) {
+ if (status != "playing") {
+ this.status = "playing"
+ }
+ musicPlayers[0].playText(text)
+ }
def currentValue(String deviceFeature) {
musicPlayers[0].currentValue(deviceFeature)
}
+ def latestValue(String deviceFeature) {
+ musicPlayers[0].latestValue(deviceFeature)
+ }
+
def getAt(int ix) {
musicPlayers[ix]
}
}
}
+ def latestValue(String deviceFeature) {
+ if (deviceFeature == "power") {
+ return power
+ }
+ }
+
}
//By Model Checker
def setValue(LinkedHashMap eventDataMap) {
- if (eventDataMap["value"] != powerMeters[0].power) {
+ if (eventDataMap["value"].toInteger() != powerMeters[0].power) {
+ this.power = eventDataMap["value"].toInteger()
+ this.currentPower = eventDataMap["value"].toInteger()
powerMeters[0].setValue(eventDataMap["value"])
- this.power = powerMeters[0].power
- this.currentPower = powerMeters[0].currentPower
sendEvent(eventDataMap)
}
}
def find(Closure Input) {
powerMeters.find(Input)
}
+ def sort(Closure Input) {
+ powerMeters.sort(Input)
+ }
def collect(Closure Input) {
powerMeters.collect(Input)
}
powerMeters[0].currentValue(deviceFeature)//It is called if we have only one device
}
+ def latestValue(String deviceFeature) {
+ powerMeters[0].latestValue(deviceFeature)//It is called if we have only one device
+ }
+
def getAt(int ix) {
powerMeters[ix]
}
}
def setValue(String value) {
- this.presenceLatestValue = presence
println("the presence sensor with id:$id is triggered to $value!")
+ this.presenceLatestValue = value
this.presence = value
this.currentPresence = value
}
//By Model Checker
def setValue(LinkedHashMap eventDataMap) {
if (eventDataMap["value"] != presenceSensors[0].presence) {
+ this.presenceLatestValue = eventDataMap["value"]
+ this.presence = eventDataMap["value"]
+ this.currentPresence = eventDataMap["value"]
presenceSensors[0].setValue(eventDataMap["value"])
- this.presenceLatestValue = presenceSensors[0].presenceLatestValue
- this.presence = presenceSensors[0].presence
- this.currentPresence = presenceSensors[0].presence
sendEvent(eventDataMap)
}
}
def find(Closure Input) {
presenceSensors.find(Input)
}
+ def sort(Closure Input) {
+ presenceSensors.sort(Input)
+ }
def collect(Closure Input) {
presenceSensors.collect(Input)
}
}
}
+ def latestValue(String deviceFeature) {
+ if (deviceFeature == "humidity") {
+ return humidity
+ }
+ }
}
//By Model Checker
def setValue(LinkedHashMap eventDataMap) {
- if (eventDataMap["value"] != humidityMeasurements[0].humidity) {
- humidityMeasurements[0].setValue(eventDataMap["value"])
- this.humidity = humidityMeasurements[0].humidity
- this.currentHumidity = humidityMeasurements[0].currentHumidity
+ if (eventDataMap["value"].toInteger() != humidityMeasurements[0].humidity) {
+ this.humidity = eventDataMap["value"].toInteger()
+ this.currentHumidity = eventDataMap["value"].toInteger()
+ humidityMeasurements[0].setValue(eventDataMap["value"])
sendEvent(eventDataMap)
}
}
def find(Closure Input) {
humidityMeasurements.find(Input)
}
+ def sort(Closure Input) {
+ humidityMeasurements.sort(Input)
+ }
def collect(Closure Input) {
humidityMeasurements.collect(Input)
}
humidityMeasurements[0].currentValue(deviceFeature)//It is called if we have only one device
}
+ def latestValue(String deviceFeature) {
+ humidityMeasurements[0].latestValue(deviceFeature)//It is called if we have only one device
+ }
+
def getAt(int ix) {
humidityMeasurements[ix]
}
def on() {
if (switchState != "on") {
println("the relay switch with id:$id is on!")
- this.switchLatestValue = this.switchState
+ this.switchLatestValue = "on"
this.switchState = "on"
this.currentSwitch = "on"
sendEvent([name: "switch", value: "on", deviceId: this.id, descriptionText: "",
- displayed: true, linkText: "", isStateChange: false, unit: "", data: [value: "on"]])
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ sendEvent([name: "switch.on", value: "on", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
}
}
if (switchState != "on") {
def task = timers.runAfter(metaData["delay"]) {
println("the relay switch with id:$id is on!")
- this.switchLatestValue = this.switchState
+ this.switchLatestValue = "on"
this.switchState = "on"
this.currentSwitch = "on"
sendEvent([name: "switch", value: "on", deviceId: this.id, descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ sendEvent([name: "switch.on", value: "on", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
}
}
}
def off() {
if (switchState != "off") {
println("the relay switch with id:$id is off!")
- this.switchLatestValue = this.switchState
+ this.switchLatestValue = "off"
this.switchState = "off"
this.currentSwitch = "off"
sendEvent([name: "switch", value: "off", deviceId: this.id, descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ sendEvent([name: "switch.off", value: "off", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
}
}
if (switchState != "off") {
def task = timers.runAfter(metaData["delay"]) {
println("the relay switch with id:$id is off!")
- this.switchLatestValue = this.switchState
+ this.switchLatestValue = "off"
this.switchState = "off"
this.currentSwitch = "off"
sendEvent([name: "switch", value: "off", deviceId: this.id, descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ sendEvent([name: "switch.off", value: "off", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
}
}
}
//By Model Checker
def setValue(String value) {
println("the relay switch with id:$id is $value!")
- this.switchLatestValue = this.switchState
+ this.switchLatestValue = value
this.switchState = value
this.currentSwitch = value
}
def find(Closure Input) {
relaySwitches.find(Input)
}
+ def sort(Closure Input) {
+ relaySwitches.sort(Input)
+ }
def collect(Closure Input) {
relaySwitches.collect(Input)
}
//By Apps
def on() {
if (switchState != "on") {
- relaySwitches[0].on()
- switchLatestValue = switchState
+ switchLatestValue = "on"
switchState = "on"
currentSwitch = "on"
+ relaySwitches[0].on()
}
}
def on(LinkedHashMap metaData) {
if (switchState != "on") {
def task = timers.runAfter(metaData["delay"]) {
- relaySwitches[0].on()
- switchLatestValue = switchState
+ switchLatestValue = "on"
switchState = "on"
currentSwitch = "on"
+ relaySwitches[0].on()
}
}
}
def off() {
if (switchState != "off") {
- relaySwitches[0].off()
- switchLatestValue = switchState
+ switchLatestValue = "off"
switchState = "off"
currentSwitch = "off"
+ relaySwitches[0].off()
}
}
def off(LinkedHashMap metaData) {
if (switchState != "off") {
def task = timers.runAfter(metaData["delay"]) {
- relaySwitches[0].off()
- switchLatestValue = switchState
+ switchLatestValue = "off"
switchState = "off"
currentSwitch = "off"
+ relaySwitches[0].off()
}
}
}
//By Model Checker
def setValue(LinkedHashMap eventDataMap) {
if (eventDataMap["value"] != relaySwitches[0].switchState) {
+ this.switchState = eventDataMap["value"]
+ this.switchLatestValue = eventDataMap["value"]
relaySwitches[0].setValue(eventDataMap["value"])
- this.switchState = relaySwitches[0].switchState
- this.switchLatestValue = relaySwitches[0].switchLatestValue
sendEvent(eventDataMap)
}
}
timeToday = open("Methods/"+"timeToday.groovy", "r")
sendNotification = open("Methods/"+"sendNotification.groovy", "r")
canSchedule = open("Methods/"+"canSchedule.groovy", "r")
+createAccessToken = open("Methods/"+"createAccessToken.groovy", "r")
+runOnce = open("Methods/"+"runOnce.groovy", "r")
App1 = open("Extractor/"+"App1/App1.groovy", "r")
extractedObjectsApp1 = open("Extractor/"+"App1/extractedObjectsApp1.groovy", "r")
extractedObjectsConstructorApp1 = open("Extractor/"+"App1/extractedObjectsConstructorApp1.groovy", "r")
Out.write("import MobilePresence.MobilePresence\n")
Out.write("import MobilePresence.MobilePresences\n")
Out.write("import Event.Event\n")
-Out.write("import AtomicState.AtomicState\n")
Out.write("import Timer.SimulatedTimer\n")
Out.write("\n")
Out.write("//JPF's Verify API\n")
Out.write("\tdef reference\n")
Out.write("\tdef location\n")
Out.write("\tdef app\n")
-Out.write("\tdef atomicState\n")
Out.write("\n")
Out.write("\t//Extracted objects for App1\n")
for line in extractedObjectsApp1:
Out.write("\t\treference = obj\n")
Out.write("\t\tlocation = obj.locationObject\n")
Out.write("\t\tapp = obj.appObject\n")
-Out.write("\t\tatomicState = obj.atomicState\n")
for line in extractedObjectsConstructorApp1:
Out.write("\t\t"+line)
Out.write("\t}\n")
Out.write("\t"+line)
for line in canSchedule:
Out.write("\t"+line)
+for line in createAccessToken:
+ Out.write("\t"+line)
+for line in runOnce:
+ Out.write("\t"+line)
Out.write("\n")
Start = 0
for line in App1:
timeToday = open("Methods/"+"timeToday.groovy", "r")
sendNotification = open("Methods/"+"sendNotification.groovy", "r")
canSchedule = open("Methods/"+"canSchedule.groovy", "r")
+createAccessToken = open("Methods/"+"createAccessToken.groovy", "r")
+runOnce = open("Methods/"+"runOnce.groovy", "r")
App2 = open("Extractor/"+"App2/App2.groovy", "r")
extractedObjectsApp2 = open("Extractor/"+"App2/extractedObjectsApp2.groovy", "r")
extractedObjectsConstructorApp2 = open("Extractor/"+"App2/extractedObjectsConstructorApp2.groovy", "r")
Out.write("\tdef reference\n")
Out.write("\tdef location\n")
Out.write("\tdef app\n")
-Out.write("\tdef atomicState\n")
Out.write("\n")
Out.write("\t//Extracted objects for App2\n")
for line in extractedObjectsApp2:
Out.write("\t\treference = obj\n")
Out.write("\t\tlocation = obj.locationObject\n")
Out.write("\t\tapp = obj.appObject\n")
-Out.write("\t\tatomicState = obj.atomicState\n")
for line in extractedObjectsConstructorApp2:
Out.write("\t\t"+line)
Out.write("\t}\n")
Out.write("\t"+line)
for line in canSchedule:
Out.write("\t"+line)
+for line in createAccessToken:
+ Out.write("\t"+line)
+for line in runOnce:
+ Out.write("\t"+line)
Out.write("\n")
Start = 0
for line in App2:
//By Model Checker
def setValue(LinkedHashMap eventDataMap) {
if (eventDataMap["value"] != sleepSensors[0].sleeping) {
+ this.sleeping = eventDataMap["value"]
sleepSensors[0].setValue(eventDataMap["value"])
- this.sleeping = sleepSensors[0].sleeping
sendEvent(eventDataMap)
}
}
def find(Closure Input) {
sleepSensors.find(Input)
}
+ def sort(Closure Input) {
+ sleepSensors.sort(Input)
+ }
def collect(Closure Input) {
sleepSensors.collect(Input)
}
private String smoke
private String currentSmokeValue
private String smokeLatestValue
+ private String carbonMonoxide
+ private String currentCarbonMonoxideValue
+ private String carbonMonoxideLatestValue
+ private int battery
+ private int batteryLatestValue
- SmokeDetector(String id, String label, String displayName, String smoke, String smokeLatestValue) {
+ SmokeDetector(String id, String label, String displayName, String smoke, String smokeLatestValue, String carbonMonoxide, String carbonMonoxideLatestValue, int battery) {
this.id = id
this.label = label
this.displayName = displayName
this.smoke = smoke
this.currentSmokeValue = smoke
this.smokeLatestValue = smokeLatestValue
+ this.carbonMonoxide = carbonMonoxide
+ this.currentCarbonMonoxideValue = currentCarbonMonoxideValue
+ this.carbonMonoxideLatestValue = carbonMonoxideLatestValue
+ this.battery = battery
+ this.batteryLatestValue = battery
}
- def setValue(String value) {
- this.smokeLatestValue = smoke
- println("the smoke detector with id:$id is triggered to $value!")
- this.smoke = value
- this.currentSmokeValue = value
+ def setValue(String value, String name) {
+ if (name.contains("smoke")) {
+ println("the smoke value of smoke detector with id:$id is triggered to $value!")
+ this.smokeLatestValue = value
+ this.smoke = value
+ this.currentSmokeValue = value
+ } else if (name.contains("carbonMonoxide")) {
+ println("the carbonMonoxide value of smoke detector with id:$id is triggered to $value!")
+ this.carbonMonoxideLatestValue = value
+ this.carbonMonoxide = value
+ this.currentCarbonMonoxideValue = value
+ } else if (name.contains("battery")) {
+ println("the battery value of smoke detector with id:$id is triggered to $value!")
+ this.batteryLatestValue = value.toInteger()
+ this.battery = value.toInteger()
+ }
+
}
def currentValue(String deviceFeature) {
if (deviceFeature == "smoke") {
return currentSmokeValue
+ } else if (deviceFeature == "carbonMonoxide") {
+ return currentCarbonMonoxideValue
+ } else if (deviceFeature == "battery") {
+ return battery
}
}
def latestValue(String deviceFeature) {
if (deviceFeature == "smoke") {
return smokeLatestValue
+ } else if (deviceFeature == "carbonMonoxide") {
+ return carbonMonoxideLatestValue
+ } else if (deviceFeature == "battery") {
+ return batteryLatestValue
}
}
}
private String smoke = "clear"
private String currentSmokeValue = "clear"
private String smokeLatestValue = "clear"
+ private String carbonMonoxide = "clear"
+ private String currentCarbonMonoxideValue = "clear"
+ private String carbonMonoxideLatestValue = "clear"
+ private int battery = 50
+ private int batteryLatestValue = 50
SmokeDetectors(Closure sendEvent, int deviceNumbers) {
this.deviceNumbers = deviceNumbers
this.smokeDetectors = []
+<<<<<<< HEAD
+ def initBattery = Verify.getIntFromList(30, 50, 70)
+ this.battery = initBattery
+ this.batteryLatestValue = initBattery
+
+ def initSmoke = Verify.getInt(0,2)
+ if (initSmoke == 0) {
+=======
/*def init = Verify.getInt(0,2)
if (init == 0) {
+>>>>>>> a02c9807815a35c0f57241ee6510a3d312499049
this.currentSmokeValue = "clear"
this.smokeLatestValue = "clear"
- } else if (init == 1) {
+ } else if (initSmoke == 1) {
this.currentSmokeValue = "detected"
this.smokeLatestValue = "detected"
} else {
this.currentSmokeValue = "tested"
this.smokeLatestValue = "tested"
+<<<<<<< HEAD
+ }
+
+ def initCarbonMonoxide = Verify.getInt(0,2)
+ if (initCarbonMonoxide == 0) {
+ this.currentCarbonMonoxideValue = "clear"
+ this.carbonMonoxideLatestValue = "clear"
+ } else if (initCarbonMonoxide == 1) {
+ this.currentCarbonMonoxideValue = "detected"
+ this.carbonMonoxideLatestValue = "detected"
+ } else {
+ this.currentCarbonMonoxideValue = "tested"
+ this.carbonMonoxideLatestValue = "tested"
+ }
+ smokeDetectors.add(new SmokeDetector(id, label, displayName, this.currentSmokeValue, this.smokeLatestValue, this.currentCarbonMonoxideValue,
+ this.carbonMonoxideLatestValue, this.battery))
+=======
}*/
smokeDetectors.add(new SmokeDetector(id, label, displayName, this.currentSmokeValue, this.smokeLatestValue))
+>>>>>>> a02c9807815a35c0f57241ee6510a3d312499049
}
//By Model Checker
def setValue(LinkedHashMap eventDataMap) {
- if (eventDataMap["value"] != smokeDetectors[0].currentSmokeValue) {
- smokeDetectors[0].setValue(eventDataMap["value"])
- this.smokeLatestValue = smokeDetectors[0].smokeLatestValue
- this.smoke = smokeDetectors[0].currentSmokeValue
- this.currentSmokeValue = smokeDetectors[0].currentSmokeValue
- sendEvent(eventDataMap)
+ if (eventDataMap["name"].contains("smoke")) {
+ if (eventDataMap["value"] != smokeDetectors[0].currentSmokeValue) {
+ this.smokeLatestValue = eventDataMap["value"]
+ this.smoke = eventDataMap["value"]
+ this.currentSmokeValue = eventDataMap["value"]
+ smokeDetectors[0].setValue(eventDataMap["value"], eventDataMap["name"])
+ sendEvent(eventDataMap)
+ }
+ } else if (eventDataMap["name"].contains("carbonMonoxide")) {
+ if (eventDataMap["value"] != smokeDetectors[0].currentCarbonMonoxideValue) {
+ this.carbonMonoxideLatestValue = eventDataMap["value"]
+ this.carbonMonoxide = eventDataMap["value"]
+ this.currentCarbonMonoxideValue = eventDataMap["value"]
+ smokeDetectors[0].setValue(eventDataMap["value"], eventDataMap["name"])
+ sendEvent(eventDataMap)
+ }
+ } else if (eventDataMap["name"].contains("battery")) {
+ if (eventDataMap["value"].toInteger() != smokeDetectors[0].battery) {
+ this.battery = eventDataMap["value"].toInteger()
+ this.batteryLatestValue = eventDataMap["value"].toInteger()
+ smokeDetectors[0].setValue(eventDataMap["value"], eventDataMap["name"])
+ sendEvent(eventDataMap)
+ }
}
}
def find(Closure Input) {
smokeDetectors.find(Input)
}
+ def sort(Closure Input) {
+ smokeDetectors.sort(Input)
+ }
def collect(Closure Input) {
smokeDetectors.collect(Input)
}
def find(Closure Input) {
speechSynthesises.find(Input)
}
+ def sort(Closure Input) {
+ speechSynthesises.sort(Input)
+ }
def collect(Closure Input) {
speechSynthesises.collect(Input)
}
def setLevel(int level) {
if (level != this.level) {
- speechSynthesises[0].setLevel(level)
this.level = level
+ speechSynthesises[0].setLevel(level)
}
}
//By Model Checker
def setValue(LinkedHashMap eventDataMap) {
if (eventDataMap["name"] == "steps") {
- if (eventDataMap["value"] != stepSensors[0].steps) {
+ if (eventDataMap["value"].toInteger() != stepSensors[0].steps) {
+ this.steps = eventDataMap["value"].toInteger()
stepSensors[0].setValue(eventDataMap["value"], "steps")
- this.steps = stepSensors[0].steps
sendEvent(eventDataMap)
}
- } else if (eventDataMap["value"] == "goal") {
- if (eventDataMap["value"] != stepSensors[0].goal) {
+ } else if (eventDataMap["name"] == "goal") {
+ if (eventDataMap["value"].toInteger() != stepSensors[0].goal) {
+ this.goal = eventDataMap["value"].toInteger()
stepSensors[0].setValue(eventDataMap["value"], "goal")
- this.goal = stepSensors[0].goal
sendEvent(eventDataMap)
}
}
def find(Closure Input) {
stepSensors.find(Input)
}
+ def sort(Closure Input) {
+ stepSensors.sort(Input)
+ }
def collect(Closure Input) {
stepSensors.collect(Input)
}
if (this.currentLevel != level) {
println("the switch with id:$id is setted to level $level!")
this.currentLevel = level
- sendEvent([name: "level", value: "40", deviceId: this.id, descriptionText: "",
+ sendEvent([name: "level", value: "$level", deviceId: this.id, descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
}
}
def on() {
if (this.switchState != "on") {
println("the switch with id:$id is on!")
- this.switchLatestValue = this.switchState
+ this.switchLatestValue = "on"
this.switchState = "on"
this.currentSwitch = "on"
sendEvent([name: "switch", value: "on", deviceId: this.id, descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ sendEvent([name: "switch.on", value: "on", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
}
}
if (this.switchState != "on") {
def task = timers.runAfter(metaData["delay"]) {
println("the switch with id:$id is on!")
- this.switchLatestValue = this.switchState
+ this.switchLatestValue = "on"
this.switchState = "on"
this.currentSwitch = "on"
sendEvent([name: "switch", value: "on", deviceId: this.id, descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ sendEvent([name: "switch.on", value: "on", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
}
}
}
def off() {
if (this.switchState != "off") {
println("the switch with id:$id is off!")
- this.switchLatestValue = this.switchState
+ this.switchLatestValue = "off"
this.switchState = "off"
this.currentSwitch = "off"
sendEvent([name: "switch", value: "off", deviceId: this.id, descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ sendEvent([name: "switch.off", value: "off", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
}
}
if (this.switchState != "off") {
def task = timers.runAfter(metaData["delay"]) {
println("the switch with id:$id is off!")
- this.switchLatestValue = this.switchState
+ this.switchLatestValue = "off"
this.switchState = "off"
this.currentSwitch = "off"
sendEvent([name: "switch", value: "off", deviceId: this.id, descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ sendEvent([name: "switch.off", value: "off", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
}
}
}
//By Model Checker
def setValue(String value) {
println("the switch with id:$id is $value!")
- this.switchLatestValue = this.switchState
+ this.switchLatestValue = value
this.switchState = value
this.currentSwitch = value
}
def find(Closure Input) {
switches.find(Input)
}
+ def sort(Closure Input) {
+ switches.sort(Input)
+ }
def collect(Closure Input) {
switches.collect(Input)
}
//By Apps
def setLevel(int level) {
- switches[0].setLevel(level)
currentLevel = level
+ switches[0].setLevel(level)
}
def on() {
- switches[0].on()
- switchLatestValue = switchState
+ switchLatestValue = "on"
switchState = "on"
currentSwitch = "on"
+ switches[0].on()
}
def on(LinkedHashMap metaData) {
def task = timers.runAfter(metaData["delay"]) {
- switches[0].on()
- switchLatestValue = switchState
+ switchLatestValue = "on"
switchState = "on"
currentSwitch = "on"
+ switches[0].on()
}
}
def off() {
- switches[0].off()
- switchLatestValue = switchState
+ switchLatestValue = "off"
switchState = "off"
currentSwitch = "off"
+ switches[0].off()
}
def off(LinkedHashMap metaData) {
def task = timers.runAfter(metaData["delay"]) {
- switches[0].off()
- switchLatestValue = switchState
+ switchLatestValue = "off"
switchState = "off"
currentSwitch = "off"
+ switches[0].off()
}
}
//By Model Checker
def setValue(LinkedHashMap eventDataMap) {
if (eventDataMap["value"] != switches[0].switchState) {
+ this.switchState = eventDataMap["value"]
+ this.switchLatestValue = eventDataMap["value"]
switches[0].setValue(eventDataMap["value"])
- this.switchState = switches[0].switchState
- this.switchLatestValue = switches[0].switchLatestValue
sendEvent(eventDataMap)
}
}
println("the switch with id:$id is setted to level $level!")
this.level = level
this.rate = level
- sendEvent([name: "level", value: "50", deviceId: this.id, descriptionText: "",
+ sendEvent([name: "level", value: "$level", deviceId: this.id, descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
}
}
def on() {
if (this.switchState != "on") {
println("the switch with id:$id is on!")
- this.switchLatestValue = this.switchState
+ this.switchLatestValue = "on"
this.switchState = "on"
this.currentSwitch = "on"
sendEvent([name: "switch", value: "on", deviceId: this.id, descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ sendEvent([name: "switch.on", value: "on", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
}
}
if (this.switchState != "on") {
def task = timers.runAfter(metaData["delay"]) {
println("the switch with id:$id is on!")
- this.switchLatestValue = this.switchState
+ this.switchLatestValue = "on"
this.switchState = "on"
this.currentSwitch = "on"
sendEvent([name: "switch", value: "on", deviceId: this.id, descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ sendEvent([name: "switch.on", value: "on", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
}
}
}
def off() {
if (this.switchState != "off") {
println("the switch with id:$id is off!")
- this.switchLatestValue = this.switchState
+ this.switchLatestValue = "off"
this.switchState = "off"
this.currentSwitch = "off"
sendEvent([name: "switch", value: "off", deviceId: this.id, descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ sendEvent([name: "switch.off", value: "off", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
}
}
if (this.switchState != "off") {
def task = timers.runAfter(metaData["delay"]) {
println("the switch with id:$id is off!")
- this.switchLatestValue = this.switchState
+ this.switchLatestValue = "off"
this.switchState = "off"
this.currentSwitch = "off"
sendEvent([name: "switch", value: "off", deviceId: this.id, descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ sendEvent([name: "switch.off", value: "off", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
}
}
}
def find(Closure Input) {
switchLevels.find(Input)
}
+ def sort(Closure Input) {
+ switchLevels.sort(Input)
+ }
def collect(Closure Input) {
switchLevels.collect(Input)
}
}
def on() {
- switchLevels[0].on()
- switchLatestValue = switchState
+ switchLatestValue = "on"
switchState = "on"
currentSwitch = "on"
+ switchLevels[0].on()
}
def on(LinkedHashMap metaData) {
def task = timers.runAfter(metaData["delay"]) {
- switchLevels[0].on()
- switchLatestValue = switchState
+ switchLatestValue = "on"
switchState = "on"
currentSwitch = "on"
+ switchLevels[0].on()
}
}
def off() {
- switchLevels[0].off()
- switchLatestValue = switchState
+ switchLatestValue = "off"
switchState = "off"
currentSwitch = "off"
+ switchLevels[0].off()
}
def off(LinkedHashMap metaData) {
def task = timers.runAfter(metaData["delay"]) {
- switchLevels[0].off()
- switchLatestValue = switchState
+ switchLatestValue = "off"
switchState = "off"
currentSwitch = "off"
+ switchLevels[0].off()
}
}
//By Model Checker
def setValue(LinkedHashMap eventDataMap) {
- if (eventDataMap["value"] != switchLevels[0].level) {
+ if (eventDataMap["value"].toInteger() != switchLevels[0].level) {
+ this.level = eventDataMap["value"].toInteger()
+ this.rate = eventDataMap["value"].toInteger()
switchLevels[0].setValue(eventDataMap["value"])
- this.level = switchLevels[0].level
- this.rate = switchLevels[0].level
sendEvent(eventDataMap)
}
}
private String label
private String displayName
private int temperature
+ private int currentTemperature
TemperatureMeasurement(String id, String label, String displayName, int temperature) {
this.id = id
this.label = label
this.displayName = displayName
this.temperature = temperature
+ this.currentTemperature = temperature
}
//By Model Checker
def setValue(String value) {
println("the temperature is changed to $value!")
this.temperature = value.toInteger()
+ this.currentTemperature = value.toInteger()
}
}
private String label = "temperatureMeasurement0"
private String displayName = "temperatureMeasurement0"
private int temperature = 50
+<<<<<<< HEAD
+ private int currentTemperature = 50
+
+=======
+>>>>>>> a02c9807815a35c0f57241ee6510a3d312499049
TemperatureMeasurements(Closure sendEvent, int deviceNumbers) {
this.sendEvent = sendEvent
//By Model Checker
def setValue(LinkedHashMap eventDataMap) {
- if (eventDataMap["value"] != temperatureMeasurements[0].temperature) {
+ if (eventDataMap["value"].toInteger() != temperatureMeasurements[0].temperature) {
+ this.temperature = eventDataMap["value"].toInteger()
+ this.currentTemperature = eventDataMap["value"].toInteger()
temperatureMeasurements[0].setValue(eventDataMap["value"])
- this.temperature = temperatureMeasurements[0].temperature
sendEvent(eventDataMap)
}
}
def find(Closure Input) {
temperatureMeasurements.find(Input)
}
+ def sort(Closure Input) {
+ temperatureMeasurements.sort(Input)
+ }
def collect(Closure Input) {
temperatureMeasurements.collect(Input)
}
private String label
private String displayName
private int temperature
+ private int currentTemperature
private int currentCoolingSetpoint
private int currentHeatingSetpoint
private int coolingSetpoint
+ private int latestCoolingSetPoint
private int thermostatSetpoint
+ private int latestThermostatSetPoint
private int heatingSetpoint
+ private int latestHeatingSetPoint
private List coolingSetpointRange
private List thermostatSetpointRange
private List heatingSetpointRange
private String thermostatMode
private String currentThermostatMode
private String climateName
+ private String thermostatLatestMode
+ private String thermostatLatestOperatingState
+ private String thermostatLatestFanMode
def sendEvent
def timers
Thermostat(Closure sendEvent, String id, String label, String displayName, int temperature, int currentCoolingSetpoint, int currentHeatingSetpoint, int coolingSetpoint,
int thermostatSetpoint, int heatingSetpoint, List coolingSetpointRange, List thermostatSetpointRange, List heatingSetpointRange,
List supportedThermostatFanModes, List supportedThermostatModes, String thermostatOperatingState, String thermostatFanMode, String thermostatMode,
- String climateName) {
+ String climateName, String thermostatLatestMode, String thermostatLatestOperatingState, String thermostatLatestFanMode, int latestCoolingSetPoint,
+ int latestThermostatSetPoint, int latestHeatingSetPoint) {
this.id = id
this.label = label
this.sendEvent = sendEvent
this.temperature = temperature
+ this.currentTemperature = currentTemperature
this.currentCoolingSetpoint = currentCoolingSetpoint
this.currentHeatingSetpoint = currentHeatingSetpoint
this.coolingSetpoint = coolingSetpoint
this.thermostatMode = thermostatMode
this.currentThermostatMode = thermostatMode
this.climateName = climateName
+ this.thermostatLatestMode = thermostatLatestMode
+ this.thermostatLatestOperatingState = thermostatLatestOperatingState
+ this.thermostatLatestFanMode = thermostatLatestFanMode
+ this.latestHeatingSetPoint = latestHeatingSetPoint
+ this.latestThermostatSetPoint = latestThermostatSetPoint
+ this.latestCoolingSetPoint = latestCoolingSetPoint
}
//By Apps
def setCoolingSetpoint(int coolingSetpoint) {
if (this.coolingSetpoint != coolingSetpoint) {
+ this.latestCoolingSetPoint = coolingSetpoint
this.coolingSetpoint = coolingSetpoint
this.currentCoolingSetpoint = currentCoolingSetpoint
println("Cooling set point for the thermostat with id:$id is changed to $coolingSetpoint!")
}
}
+ def setCoolingSetpoint(String coolingSetpoint) {
+ setCoolingSetpoint(coolingSetpoint.toInteger())
+ }
+
def setHeatingSetpoint(int heatingSetpoint) {
if (this.heatingSetpoint != heatingSetpoint) {
+ this.latestHeatingSetPoint = heatingSetpoint
this.heatingSetpoint = heatingSetpoint
this.currentHeatingSetpoint = currentHeatingSetpoint
println("Heating set point for the thermostat with id:$id is changed to $heatingSetpoint!")
}
}
+ def setHeatingSetpoint(String heatingSetpoint) {
+ setHeatingSetpoint(heatingSetpoint.toInteger())
+ }
+
def setSchedule() {
//Not implemented yet
}
def setThermostatFanMode(String thermostatFanMode) {
if (this.thermostatFanMode != thermostatFanMode) {
+ this.thermostatLatestFanMode = thermostatFanMode
this.thermostatFanMode = thermostatFanMode
println("Fan mode of the thermostat with id:$id is changed to $thermostatFanMode!")
sendEvent([name: "thermostatFanMode", value: "$thermostatFanMode", deviceId: this.id, descriptionText: "",
def setThermostatMode(String thermostatMode) {
if (this.thermostatMode != thermostatMode) {
+ this.thermostatLatestMode =thermostatMode
this.thermostatMode = thermostatMode
this.currentThermostatMode = currentThermostatMode
println("Mode of the thermostat with id:$id is changed to $thermostatMode!")
def cool() {
if (this.thermostatMode != "cool") {
+ this.thermostatLatestMode = "cool"
this.thermostatMode = "cool"
this.currentThermostatMode = "cool"
println("Mode of the thermostat with id:$id is changed to cool!")
def heat() {
if (this.thermostatMode != "heat") {
+ this.thermostatLatestMode = "heat"
this.thermostatMode = "heat"
this.currentThermostatMode = "heat"
println("Mode of the thermostat with id:$id is changed to heat!")
def auto() {
if (this.thermostatMode != "auto") {
+ this.thermostatLatestMode = "auto"
this.thermostatMode = "auto"
this.currentThermostatMode = "auto"
println("Mode of the thermostat with id:$id is changed to auto!")
def off() {
if (this.thermostatMode != "off") {
+ this.thermostatLatestMode = "off"
this.thermostatMode = "off"
this.currentThermostatMode = "off"
println("Mode of the thermostat with id:$id is changed to off!")
this.heatingSetpoint = heatingSetpoint
this.currentHeatingSetpoint = currentHeatingSetpoint
println("Heating set point for the thermostat with id:$id is changed to $heatingSetpoint!")
+ sendEvent([name: "heatingSetpoint", value: "$heatingSetpoint", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ sendEvent([name: "coolingSetpoint", value: "$coolingSetpoint", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
}
}
//By Model Checker
def setValue(String value, String name) {
- if ((name == "temperature") && (value != this.temperature)) {
+ if ((name == "temperature") && (value.toInteger() != this.temperature)) {
println("the temperature is $value!")
this.temperature = value.toInteger()
- } else if ((name == "heatingSetpoint") && (value != this.heatingSetpoint)) {
+ this.currentTemperature = value.toInteger()
+ } else if ((name == "heatingSetpoint") && (value.toInteger() != this.heatingSetpoint)) {
println("the heating set point of the thermostat with id:$id is $value!")
+ this.latestHeatingSetPoint = value.toInteger()
this.heatingSetpoint = value.toInteger()
- } else if ((name == "coolingSetpoint") && (value != this.coolingSetpoint)) {
+ } else if ((name == "coolingSetpoint") && (value.toInteger() != this.coolingSetpoint)) {
println("the cooling set point of the thermostat with id:$id is $value!")
+ this.latestCoolingSetPoint = value.toInteger()
this.coolingSetpoint = value.toInteger()
- } else if ((name == "thermostatSetpoint") && (value != this.thermostatSetpoint)) {
+ } else if ((name == "thermostatSetpoint") && (value.toInteger() != this.thermostatSetpoint)) {
println("the set point of the thermostat with id:$id is $value!")
+ this.latestThermostatSetPoint = value.toInteger()
this.thermostatSetpoint = value.toInteger()
} else if ((name == "thermostatMode") && (value != this.thermostatMode)) {
println("the mode of the thermostat with id:$id is $value!")
+ this.thermostatLatestMode = value
this.thermostatMode = value
} else if ((name == "thermostatFanMode") && (value != this.thermostatFanMode)) {
println("the fan mode of the thermostat with id:$id is $value!")
+ this.thermostatLatestFanMode = value
this.thermostatFanMode = value
} else if ((name == "thermostatOperatingState") && (value != this.thermostatOperatingState)) {
println("the operating state of the thermostat with id:$id is $value!")
+ this.thermostatLatestOperatingState = value
this.thermostatOperatingState = value
}
}
+ def currentValue(String deviceFeature) {
+ if (deviceFeature == "thermostatMode")
+ return thermostatMode
+ else if (deviceFeature == "thermostatOperatingState")
+ return thermostatOperatingState
+ else if (deviceFeature == "thermostatFanMode")
+ return thermostatFanMode
+ else if (deviceFeature == "heatingSetpoint")
+ return heatingSetpoint
+ else if (deviceFeature == "coolingSetpoint")
+ return coolingSetpoint
+ else if (deviceFeature == "thermostatSetpoint")
+ return thermostatSetpoint
+ }
+
+ def latestValue(String deviceFeature) {
+ if (deviceFeature == "thermostatMode")
+ return thermostatLatestMode
+ else if (deviceFeature == "thermostatOperatingState")
+ return thermostatLatestOperatingState
+ else if (deviceFeature == "thermostatFanMode")
+ return thermostatLatestFanMode
+ else if (deviceFeature == "heatingSetpoint")
+ return latestHeatingSetPoint
+ else if (deviceFeature == "coolingSetpoint")
+ return latestCoolingSetPoint
+ else if (deviceFeature == "thermostatSetpoint")
+ return latestThermostatSetPoint
+ }
+
}
private String label = "thermostat0"
private String displayName = "thermostat0"
private int temperature = 66
+ private int currentTemperature = 66
private int currentCoolingSetpoint = 70
private int currentHeatingSetpoint = 50
private int coolingSetpoint = 70
private String thermostatMode = "auto"
private String currentThermostatMode = "auto"
private String climateName = ""
+ private String thermostatLatestMode = "auto"
+ private String thermostatLatestOperatingState = "cooling"
+ private String thermostatLatestFanMode = "auto"
+ private int latestCoolingSetPoint = 70
+ private int latestThermostatSetPoint = 60
+ private int latestHeatingSetPoint = 50
+
Thermostats(Closure sendEvent, int deviceNumbers) {
this.sendEvent = sendEvent
/*def initTemperature = Verify.getIntFromList(60, 66, 70)
this.temperature = initTemperature
+ this.currentTemperature = initTemperature
def initCoolingSetpoint = Verify.getIntFromList(70, 80, 90)
this.currentCoolingSetpoint = initCoolingSetpoint
def initFanMode = Verify.getInt(0,4)
if (initFanMode == 0) {
this.thermostatFanMode = "auto"
+ this.thermostatLatestFanMode = "auto"
} else if (initFanMode == 1) {
this.thermostatFanMode = "fanCirculate"
+ this.thermostatLatestFanMode = "fanCirculate"
} else if (initFanMode == 2) {
this.thermostatFanMode = "circulate"
+ this.thermostatLatestFanMode = "circulate"
} else if (initFanMode == 3) {
this.thermostatFanMode = "fanOn"
+ this.thermostatLatestFanMode = "fanOn"
} else {
this.thermostatFanMode = "on"
+ this.thermostatLatestFanMode = "on"
}
def initMode = Verify.getInt(0,4)
if (initMode == 0) {
this.thermostatMode = "auto"
this.currentThermostatMode = "auto"
+ this.thermostatLatestMode = "auto"
} else if (initMode == 1) {
this.thermostatMode = "cool"
this.currentThermostatMode = "cool"
+ this.thermostatLatestMode = "cool"
} else if (initMode == 2) {
this.thermostatMode = "emergencyHeat"
this.currentThermostatMode = "emergencyHeat"
+ this.thermostatLatestMode = "emergencyHeat"
} else if (initMode == 3) {
this.thermostatMode = "heat"
this.currentThermostatMode = "heat"
+ this.thermostatLatestMode = "heat"
} else {
this.thermostatMode = "off"
this.currentThermostatMode = "off"
+<<<<<<< HEAD
+ this.thermostatLatestMode = "off"
+ }
+=======
}*/
+>>>>>>> a02c9807815a35c0f57241ee6510a3d312499049
thermostats.add(new Thermostat(sendEvent, id, label, displayName, this.temperature, this.currentCoolingSetpoint,
this.currentHeatingSetpoint, this.coolingSetpoint, this.thermostatSetpoint, this.heatingSetpoint, this.coolingSetpointRange,
this.thermostatSetpointRange, this.heatingSetpointRange, this.supportedThermostatFanModes, this.supportedThermostatModes,
- this.thermostatOperatingState, this.thermostatFanMode, this.thermostatMode, this.climateName))
+ this.thermostatOperatingState, this.thermostatFanMode, this.thermostatMode, this.climateName,
+ this.thermostatLatestMode, this.thermostatLatestOperatingState, this.thermostatLatestFanMode, this.latestCoolingSetPoint,
+ this.latestThermostatSetPoint, this.latestHeatingSetPoint))
}
//Methods for closures
def find(Closure Input) {
thermostats.find(Input)
}
+ def sort(Closure Input) {
+ thermostats.sort(Input)
+ }
def collect(Closure Input) {
thermostats.collect(Input)
}
//By Apps
def setCoolingSetpoint(int coolingSetpoint) {
if (coolingSetpoint != this.coolingSetpoint) {
- thermostats[0].setCoolingSetpoint(coolingSetpoint)
+ this.latestCoolingSetPoint = coolingSetpoint
this.currentCoolingSetpoint = coolingSetpoint
this.coolingSetpoint = coolingSetpoint
+ thermostats[0].setCoolingSetpoint(coolingSetpoint)
}
}
+ def setCoolingSetpoint(String coolingSetpoint) {
+ setCoolingSetpoint(coolingSetpoint.toInteger())
+ }
+
def setHeatingSetpoint(int heatingSetpoint) {
if (heatingSetpoint != this.heatingSetpoint) {
- thermostats[0].setHeatingSetpoint(heatingSetpoint)
+ this.latestHeatingSetPoint = heatingSetpoint
this.currentHeatingSetpoint = heatingSetpoint
this.heatingSetpoint = heatingSetpoint
+ thermostats[0].setHeatingSetpoint(heatingSetpoint)
}
}
+ def setHeatingSetpoint(String heatingSetpoint) {
+ setHeatingSetpoint(heatingSetpoint.toInteger())
+ }
+
def setSchedule() {
//Not implemented yet
}
def setThermostatFanMode(String thermostatFanMode) {
if (thermostatFanMode != this.thermostatFanMode) {
- thermostats[0].setThermostatFanMode(thermostatFanMode)
+ this.thermostatLatestFanMode = thermostatFanMode
this.thermostatFanMode = thermostatFanMode
+ thermostats[0].setThermostatFanMode(thermostatFanMode)
}
}
def setThermostatMode(String thermostatMode) {
if (thermostatMode != this.thermostatMode) {
- thermostats[0].setThermostatMode(thermostatMode)
+ this.thermostatLatestMode = thermostatMode
this.thermostatMode = thermostatMode
this.currentThermostatMode = currentThermostatMode
+ thermostats[0].setThermostatMode(thermostatMode)
}
}
def cool() {
if (thermostatMode != "cool") {
- thermostats[0].cool()
+ this.thermostatLatestMode = "cool"
this.thermostatMode = "cool"
this.currentThermostatMode = "cool"
+ thermostats[0].cool()
}
}
def heat() {
if (thermostatMode != "heat") {
- thermostats[0].heat()
+ this.thermostatLatestMode = "heat"
this.thermostatMode = "heat"
this.currentThermostatMode = "heat"
+ thermostats[0].heat()
}
}
def auto() {
if (thermostatMode != "auto") {
- thermostats[0].auto()
+ this.thermostatLatestMode = "auto"
this.thermostatMode = "auto"
this.currentThermostatMode = "auto"
+ thermostats[0].auto()
}
}
def off() {
if (thermostatMode != "off") {
- thermostats[0].off()
+ this.thermostatLatestMode = "off"
this.thermostatMode = "off"
this.currentThermostatMode = "off"
+ thermostats[0].off()
}
}
def setClimate(String info, String givenClimateName) {
if (givenClimateName != climateName) {
- thermostats[0].setClimate(info, givenClimateName)
this.climateName = givenClimateName
+ thermostats[0].setClimate(info, givenClimateName)
}
}
def setHold(String info1, int coolingSetpoint, int heatingSetpoint, String info2, String info3) {
if ((coolingSetpoint != this.coolingSetpoint) || (heatingSetpoint != this.heatingSetpoint)) {
- thermostats[0].setHold(info1, coolingSetpoint, heatingSetpoint, info2, info3)
this.currentCoolingSetpoint = coolingSetpoint
this.coolingSetpoint = coolingSetpoint
this.currentHeatingSetpoint = heatingSetpoint
this.heatingSetpoint = heatingSetpoint
+ thermostats[0].setHold(info1, coolingSetpoint, heatingSetpoint, info2, info3)
}
}
//By Model Checker
def setValue(LinkedHashMap eventDataMap) {
if (eventDataMap["name"] == "temperature") {
- if (eventDataMap["value"] != thermostats[0].temperature) {
+ if (eventDataMap["value"].toInteger() != thermostats[0].temperature) {
+ this.temperature = eventDataMap["value"].toInteger()
+ this.currentTemperature = eventDataMap["value"].toInteger()
thermostats[0].setValue(eventDataMap["value"], "temperature")
- this.temperature = thermostats[0].temperature
sendEvent(eventDataMap)
}
} else if (eventDataMap["name"] == "heatingSetpoint") {
- if (eventDataMap["value"] != thermostats[0].heatingSetpoint) {
+ if (eventDataMap["value"].toInteger() != thermostats[0].heatingSetpoint) {
+ this.latestHeatingSetpoint = eventDataMap["value"].toInteger()
+ this.heatingSetpoint = eventDataMap["value"].toInteger()
thermostats[0].setValue(eventDataMap["value"], "heatingSetpoint")
- this.heatingSetpoint = thermostats[0].heatingSetpoint
sendEvent(eventDataMap)
}
} else if (eventDataMap["name"] == "coolingSetpoint") {
- if (eventDataMap["value"] != thermostats[0].coolingSetpoint) {
+ if (eventDataMap["value"].toInteger() != thermostats[0].coolingSetpoint) {
+ this.latestCoolingSetPoint = eventDataMap["value"].toInteger()
+ this.coolingSetpoint = eventDataMap["value"].toInteger()
thermostats[0].setValue(eventDataMap["value"], "coolingSetpoint")
- this.coolingSetpoint = thermostats[0].coolingSetpoint
sendEvent(eventDataMap)
}
} else if (eventDataMap["name"] == "thermostatSetpoint") {
- if (eventDataMap["value"] != thermostats[0].thermostatSetpoint) {
+ if (eventDataMap["value"].toInteger() != thermostats[0].thermostatSetpoint) {
+ this.latestThermostatSetpoint = eventDataMap["value"].toInteger()
+ this.thermostatSetpoint = eventDataMap["value"].toInteger()
thermostats[0].setValue(eventDataMap["value"], "thermostatSetpoint")
- this.thermostatSetpoint = thermostats[0].thermostatSetpoint
sendEvent(eventDataMap)
}
} else if (eventDataMap["name"] == "thermostatMode") {
if (eventDataMap["value"] != thermostats[0].thermostatMode) {
+ this.thermostatLatestMode = eventDataMap["value"]
+ this.thermostatMode = eventDataMap["value"]
+ this.currentThermostatMode = eventDataMap["value"]
thermostats[0].setValue(eventDataMap["value"], "thermostatMode")
- this.thermostatMode = thermostats[0].thermostatMode
- this.currentThermostatMode = thermostats[0].currentThermostatMode
sendEvent(eventDataMap)
}
} else if (eventDataMap["name"] == "thermostatFanMode") {
if (eventDataMap["value"] != thermostats[0].thermostatFanMode) {
+ this.thermostatLatestFanMode = eventDataMap["value"]
+ this.thermostatFanMode = eventDataMap["value"]
thermostats[0].setValue(eventDataMap["value"], "thermostatFanMode")
- this.thermostatFanMode = thermostats[0].thermostatFanMode
sendEvent(eventDataMap)
}
} else if (eventDataMap["name"] == "thermostatOperatingState") {
if (eventDataMap["value"] != thermostats[0].thermostatOperatingState) {
+ this.thermostatLatestOperatingState = eventDataMap["value"]
+ this.thermostatOperatingState = eventDataMap["value"]
thermostats[0].setValue(eventDataMap["value"], "thermostatOperatingState")
- this.thermostatOperatingState = thermostats[0].thermostatOperatingState
sendEvent(eventDataMap)
}
}
}
+ def currentValue(String deviceFeature) {
+ thermostats[0].currentValue(deviceFeature)
+ }
+
+ def latestValue(String deviceFeature) {
+ thermostats[0].latestValue(deviceFeature)
+ }
+
def getAt(int ix) {
thermostats[ix]
}
closure()\r
}\r
\r
+ def runAfter(long delay, Closure closure) {\r
+ /*thread = new Thread() {\r
+ \r
+ @Override\r
+ public void run() {\r
+ Thread.sleep(delay)\r
+ closure()\r
+ }\r
+ }.start()\r
+ return thread*/\r
+ closure()\r
+ }\r
+\r
def cancel() {\r
//if (thread != null)\r
// thread.stop()\r
def open() {
if (valve != "open") {
println("the valve with id:$id is open!")
- this.valveLatestValue = this.valve
+ this.valveLatestValue = "open"
this.valve = "open"
sendEvent([name: "contact", value: "open", deviceId: this.id, descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ sendEvent([name: "contact.open", value: "open", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
}
}
if (valve != "open") {
def task = timers.runAfter(metaData["delay"]) {
println("the valve with id:$id is open!")
- this.valveLatestValue = this.valve
+ this.valveLatestValue = "open"
this.valve = "open"
sendEvent([name: "contact", value: "open", deviceId: this.id, descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ sendEvent([name: "contact.open", value: "open", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
}
}
}
def close() {
if (valve != "closed") {
println("the valve with id:$id is closed!")
- this.valveLatestValue = this.valve
+ this.valveLatestValue = "closed"
this.valve = "closed"
sendEvent([name: "contact", value: "closed", deviceId: this.id, descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ sendEvent([name: "contact.closed", value: "closed", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
}
}
if (valve != "closed") {
def task = timers.runAfter(metaData["delay"]) {
println("the valve with id:$id is closed!")
- this.valveLatestValue = this.valve
+ this.valveLatestValue = "closed"
this.valve = "closed"
sendEvent([name: "contact", value: "closed", deviceId: this.id, descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ sendEvent([name: "contact.closed", value: "closed", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
}
}
}
//By Model Checker
def setValue(String value) {
println("the valve with id:$id is $value!")
- this.valveLatestValue = this.valve
+ this.valveLatestValue = value
this.valve = value
}
def find(Closure Input) {
valves.find(Input)
}
+ def sort(Closure Input) {
+ valves.sort(Input)
+ }
def collect(Closure Input) {
valves.collect(Input)
}
//By Apps
def open() {
- if (valve != "open")
+ if (valve != "open") {
+ this.valve = "open"
+ this.valveLatestValue = "open"
valves[0].open()
+ }
}
def open(LinkedHashMap metaData) {
if (valve != "open") {
def task = timers.runAfter(metaData["delay"]) {
+ this.valve = "open"
+ this.valveLatestValue = "open"
valves[0].open()
}
}
}
def close() {
- if (valve != "closed")
+ if (valve != "closed") {
+ this.valve = "closed"
+ this.valveLatestValue = "closed"
valves[0].close()
+ }
}
def close(LinkedHashMap metaData) {
if (valve != "closed") {
def task = timers.runAfter(metaData["delay"]) {
+ this.valve = "closed"
+ this.valveLatestValue = "closed"
valves[0].close()
}
}
//By Model Checker
def setValue(LinkedHashMap eventDataMap) {
if (eventDataMap["value"] != valves[0].valve) {
+ this.valve = eventDataMap["value"]
valves[0].setValue(eventDataMap["value"])
- this.valve = valves[0].valve
}
}
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
contactObject.setValue([name: "contact", value: "closed", deviceId: "contactSensorID0", descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+contactObject.setValue([name: "tamper.tampered", value: "open", deviceId: "contactSensorID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+contactObject.setValue([name: "tamper.tampered", value: "closed", deviceId: "contactSensorID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
/////
/*events*/
//
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
motionSensorObject.setValue([name: "motion", value: "inactive", deviceId: "motionSensorID0", descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+motionSensorObject.setValue([name: "motion.active", value: "active", deviceId: "motionSensorID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+motionSensorObject.setValue([name: "motion.inactive", value: "inactive", deviceId: "motionSensorID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
/////
/*events*/
//
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
smokeDetectorObject.setValue([name: "smoke", value: "tested", deviceId: "smokeDetectorID0", descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
-smokeDetectorObject.setValue([name: "carbonMonoxide", value: "clear", deviceId: "smokeDetectorID0", descriptionText: "",
+smokeDetectorObject.setValue([name: "smoke.clear", value: "clear", deviceId: "smokeDetectorID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+smokeDetectorObject.setValue([name: "smoke.detected", value: "detected", deviceId: "smokeDetectorID0", descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
-smokeDetectorObject.setValue([name: "carbonMonoxide", value: "detected", deviceId: "smokeDetectorID0", descriptionText: "",
+smokeDetectorObject.setValue([name: "smoke.tested", value: "tested", deviceId: "smokeDetectorID0", descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
-smokeDetectorObject.setValue([name: "carbonMonoxide", value: "tested", deviceId: "smokeDetectorID0", descriptionText: "",
+smokeDetectorObject.setValue([name: "carbonMonoxide.clear", value: "clear", deviceId: "smokeDetectorID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+smokeDetectorObject.setValue([name: "carbonMonoxide.detected", value: "detected", deviceId: "smokeDetectorID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+smokeDetectorObject.setValue([name: "carbonMonoxide.tested", value: "tested", deviceId: "smokeDetectorID0", descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
smokeDetectorObject.setValue([name: "battery", value: "5"/*A number between 0 to 100 as a charge*/, deviceId: "smokeDetectorID0", descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
//For appTouch:
/*events*/
-appObject.setValue([name: "Touched", value: "touched", deviceId: "touchedSensorID0", descriptionText: "",
+appObject.setValue([name: "Touched", value: "touched", deviceId: "appID0", descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
/////
/*events*/
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
accelerationSensorObject.setValue([name: "acceleration", value: "inactive", deviceId: "accelerationSensorID0", descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+accelerationSensorObject.setValue([name: "acceleration.active", value: "active", deviceId: "accelerationSensorID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+accelerationSensorObject.setValue([name: "acceleration.inactive", value: "inactive", deviceId: "accelerationSensorID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
/////
/*events*/
//
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
carbonMonoxideDetectorObject.setValue([name: "carbonMonoxide", value: "tested", deviceId: "carbonMonoxideDetectorID0", descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+carbonMonoxideDetectorObject.setValue([name: "carbonMonoxide.clear", value: "clear", deviceId: "carbonMonoxideDetectorID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+carbonMonoxideDetectorObject.setValue([name: "carbonMonoxide.detected", value: "detected", deviceId: "carbonMonoxideDetectorID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+carbonMonoxideDetectorObject.setValue([name: "carbonMonoxide.tested", value: "tested", deviceId: "carbonMonoxideDetectorID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
/*events*/
//
-------------------------------------------------------------------------------
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
colorControlObject.setValue([name: "saturation", value: "50", deviceId: "colorControlID0", descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+colorControlObject.setValue([name: "level", value: "50", deviceId: "colorControlID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+colorControlObject.setValue([name: "switch", value: "on", deviceId: "colorControlID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+colorControlObject.setValue([name: "switch", value: "off", deviceId: "colorControlID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+colorControlObject.setValue([name: "colorTemperature", value: "50", deviceId: "colorControlID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
/*events*/
//
-------------------------------------------------------------------------------
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
waterSensorObject.setValue([name: "water", value: "wet", deviceId: "waterSensorID0", descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+waterSensorObject.setValue([name: "water.dry", value: "dry", deviceId: "waterSensorID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+waterSensorObject.setValue([name: "water.wet", value: "wet", deviceId: "waterSensorID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
/////
/*events*/
//
//By Model Checker
def setValue(LinkedHashMap eventDataMap) {
if (eventDataMap["value"] != waterSensors[0].water) {
+ this.water = eventDataMap["value"]
waterSensors[0].setValue(eventDataMap["value"])
- this.water = waterSensors[0].water
sendEvent(eventDataMap)
}
}
def find(Closure Input) {
waterSensors.find(Input)
}
+ def sort(Closure Input) {
+ waterSensors.sort(Input)
+ }
def collect(Closure Input) {
waterSensors.collect(Input)
}
public class Touched{
def sendEvent
+ private String id
private int isTouched
private String label
Touched(Closure sendEvent, int isTouched) {
this.sendEvent = sendEvent
this.isTouched = isTouched
- this.label = "App"
+ this.label = "app0"
+ this.id = "appID0"
}
//By Model Checker
--- /dev/null
+ colorControlObject.setValue([name: "color", value: "red", deviceId: "colorControlID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+++ /dev/null
- colorControlObject.setValue([name: "color", value: "red", deviceId: "colorControlID0", descriptionText: "",
- displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
while(true) {
- def eventNumber = Verify.getInt(0,4)
+ def eventNumber = Verify.getInt(0,5)
switch(eventNumber) {
case 0:
def event = Verify.getInt(0,1)
if (event == 0) {
+<<<<<<< HEAD
+ switchObject.setValue([name: "switch", value: "on", deviceId: "switchID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ } else {
+ switchObject.setValue([name: "switch", value: "off", deviceId: "switchID0", descriptionText: "",
+=======
lockObject.setValue([name: "lock", value: "locked", deviceId: "lockID0", descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}']) } else {
lockObject.setValue([name: "lock", value: "unlocked", deviceId: "lockID0", descriptionText: "",
+>>>>>>> a02c9807815a35c0f57241ee6510a3d312499049
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
}
break
case 1:
- lockObject.setValue([name: "unlock", value: "unlocked ", deviceId: "lockID0", descriptionText: "",
- displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
break
case 2:
- contactObject.setValue([name: "contact.open", value: "open", deviceId: "contactSensorID0", descriptionText: "",
+ colorControlObject.setValue([name: "hue", value: "50", deviceId: "colorControlID0", descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
break
case 3:
- contactObject.setValue([name: "contact.closed", value: "closed", deviceId: "contactSensorID0", descriptionText: "",
+ colorControlObject.setValue([name: "saturation", value: "50", deviceId: "colorControlID0", descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
break
case 4:
+<<<<<<< HEAD
+ break
+ case 5:
+=======
appObject.setValue([name: "Touched", value: "touched", deviceId: "touchedSensorID0", descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+>>>>>>> a02c9807815a35c0f57241ee6510a3d312499049
break
}
}
--- /dev/null
+ colorControlObject.setValue([name: "hue", value: "50", deviceId: "colorControlID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+++ /dev/null
- colorControlObject.setValue([name: "hue", value: "50", deviceId: "colorControlID0", descriptionText: "",
- displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ colorControlObject.setValue([name: "saturation", value: "50", deviceId: "colorControlID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+++ /dev/null
- colorControlObject.setValue([name: "saturation", value: "50", deviceId: "colorControlID0", descriptionText: "",
- displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])