Merge branch 'master' of ssh://plrg.eecs.uci.edu/home/git/smartthings-infrastructure
[smartthings-infrastructure.git] / RelaySwitch / RelaySwitch.groovy
index b418477477944dc7c93dd4a68af616cde5ec5bbd..7239f9d396faf1c5c8ad50e18f67974bff7d6ad2 100644 (file)
@@ -28,11 +28,11 @@ public class RelaySwitch {
        def on() {
                if (switchState != "on") {
                        println("the relay switch with id:$id is on!")
-                       this.switchLatestValue = this.switchState
+                       this.switchLatestValue = "on"
                        this.switchState = "on"
                        this.currentSwitch = "on"
                        sendEvent([name: "switch", value: "on", deviceId: this.id, descriptionText: "",
-                                 displayed: true, linkText: "", isStateChange: false, unit: "", data: [value: "on"]])
+                                 displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
 
@@ -40,7 +40,7 @@ public class RelaySwitch {
                if (switchState != "on") {
                        def task = timers.runAfter(metaData["delay"]) {
                                println("the relay switch with id:$id is on!")
-                               this.switchLatestValue = this.switchState
+                               this.switchLatestValue = "on"
                                this.switchState = "on"
                                this.currentSwitch = "on"
                                sendEvent([name: "switch", value: "on", deviceId: this.id, descriptionText: "",
@@ -52,7 +52,7 @@ public class RelaySwitch {
        def off() {
                if (switchState != "off") {
                        println("the relay switch with id:$id is off!")
-                       this.switchLatestValue = this.switchState
+                       this.switchLatestValue = "off"
                        this.switchState = "off"
                        this.currentSwitch = "off"
                        sendEvent([name: "switch", value: "off", deviceId: this.id, descriptionText: "",
@@ -64,7 +64,7 @@ public class RelaySwitch {
                if (switchState != "off") {
                        def task = timers.runAfter(metaData["delay"]) {
                                println("the relay switch with id:$id is off!")
-                               this.switchLatestValue = this.switchState
+                               this.switchLatestValue = "off"
                                this.switchState = "off"
                                this.currentSwitch = "off"
                                sendEvent([name: "switch", value: "off", deviceId: this.id, descriptionText: "",
@@ -76,7 +76,7 @@ public class RelaySwitch {
        //By Model Checker
        def setValue(String value) {
                println("the relay switch with id:$id is $value!")
-               this.switchLatestValue = this.switchState
+               this.switchLatestValue = value
                this.switchState = value
                this.currentSwitch = value
        }