private String label = "contactSensor0"
private String displayName = "contactSensor0"
private String contactState = "closed"
+ private String currentContact = "closed"
private String latestValue = "closed"
+ private String alarmState = "armed"
ContactSensors(Closure sendEvent, int deviceNumbers) {
this.deviceNumbers = deviceNumbers
this.contacts = []
- contacts.add(new ContactSensor(id, label, displayName, this.contactState, this.latestValue))
+ contacts.add(new ContactSensor(id, label, displayName, this.contactState, this.currentContact, this.alarmState, this.latestValue))
}
//Methods for closures
//By Model Checker
def setValue(LinkedHashMap eventDataMap) {
- contacts[0].setValue(eventDataMap["value"])
- this.latestValue = contacts[0].latestValue
- this.contactState = contacts[0].contactState
- sendEvent(eventDataMap)
+ if (eventDataMap["value"] != contacts[0].contactState) {
+ 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"
+ }
+
+ def off() {
+ contacts[0].off()
+ this.alarmState = "not armed"
}
def currentValue(String deviceFeature) {