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