Adding new default value to thermostat device.
[smartthings-infrastructure.git] / DoorControl / DoorControl.groovy
index 1830070772ab0260773d1cde53eb24cdc915166a..c82587925e93dc58d473a03114673bd0e6ef2119 100644 (file)
@@ -19,13 +19,14 @@ public class DoorControl {
                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"}'])
@@ -36,7 +37,7 @@ public class DoorControl {
                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"}'])
@@ -47,7 +48,7 @@ public class DoorControl {
        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"}'])
@@ -58,7 +59,7 @@ public class DoorControl {
                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"}'])
@@ -69,7 +70,7 @@ public class DoorControl {
        //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
        }