Commit #9: More classes + Extractor with Rahmadi's editions + Fixing some bugs
[smartthings-infrastructure.git] / ContactSensor / ContactSensor.groovy
index 05e961d5ab0990fa8678e1922c20ec621760638c..d13993ae3231095369a8a0fdabe74bba220ae7eb 100644 (file)
@@ -7,20 +7,36 @@ public class ContactSensor {
        private String label
        private String displayName
        private String contactState
+       private String currentContact   
        private String latestValue
+       private String alarmState
+       
 
-       ContactSensor(String id, String label, String displayName, String contactState, String latestValue) {
+       ContactSensor(String id, String label, String displayName, String contactState, String currentContact, String alarmState, String latestValue) {
                this.id = id
                this.label = label
                this.displayName = displayName
                this.contactState = contactState
+               this.currentContact = currentContact
                this.latestValue = latestValue
+               this.alarmState = alarmState
        }
 
        def setValue(String value) {
                this.latestValue = contactState
                println("the contact sensor with id:$id is triggered to $value!")
                this.contactState = value
+               this.currentContact = value
+       }
+       
+       def on() {
+               println("the contact sensor with id:$id is armed!")
+               this.alarmState = "armed"
+       }
+
+       def off() {
+               println("the contact sensor with id:$id is not armed!")
+               this.alarmState = "not armed"
        }
        
        def currentValue(String deviceFeature) {