Fixing a bug in locks: latestValue should have similar value with currentValue.
[smartthings-infrastructure.git] / Lock / Locks.groovy
index 951020f106508ab90eb94454258cfd3382c60ef4..63d93b41131aced268ce3d6e4fcb6247428d2b5d 100644 (file)
@@ -39,7 +39,8 @@ public class Locks{
        //By Apps
        def lock() {
                if (lockState != "locked") {
-                       lockLatestValue = lockState
+                       //lockLatestValue = lockState
+                       lockLatestValue = "locked"
                        lockState = "locked"
                        currentLock = "locked"
                        locks[0].lock()
@@ -49,7 +50,8 @@ public class Locks{
        def lock(LinkedHashMap metaData) {
                if (lockState != "locked") {
                        def task = timers.runAfter(metaData["delay"]) {
-                               lockLatestValue = lockState
+                               //lockLatestValue = lockState
+                               lockLatestValue = "locked"
                                lockState = "locked"
                                currentLock = "locked"
                                locks[0].lock()
@@ -59,7 +61,8 @@ public class Locks{
 
        def unlock() {
                if (lockState != "unlocked") {
-                       lockLatestValue = lockState
+                       //lockLatestValue = lockState
+                       lockLatestValue = "unlocked"
                        lockState = "unlocked"
                        currentLock = "unlocked"
                        locks[0].unlock()
@@ -70,7 +73,8 @@ public class Locks{
        def unlock(LinkedHashMap metaData) {
                if (lockState != "unlocked") {
                        def task = timers.runAfter(metaData["delay"]) {
-                               lockLatestValue = lockState
+                               //lockLatestValue = lockState
+                               lockLatestValue = "unlocked"
                                lockState = "unlocked"
                                currentLock = "unlocked"
                                locks[0].unlock()