Fix smokedetect file
[smartthings-infrastructure.git] / ContactSensor / ContactSensors.groovy
index b8fba79c363f683418856d43f92300c962b0208c..c691853aad4c3ea157ff65cc8b90ac4ff290f3f0 100644 (file)
@@ -58,6 +58,9 @@ public class ContactSensors {
        def find(Closure Input) {
                contacts.find(Input)
        }
+       def sort(Closure Input) {
+               contacts.sort(Input)
+       }
        def collect(Closure Input) {
                contacts.collect(Input)
        }
@@ -65,28 +68,32 @@ public class ContactSensors {
        //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
        }