A little modification for location.mode.
[smartthings-infrastructure.git] / Location / LocationVar.groovy
index eeaa9472c381f35eb5350a349bc67eb0c55b6f67..88f34d6a4c0578be1766c8994900fbe2d30d9069 100755 (executable)
@@ -53,8 +53,19 @@ class LocationVar {
                if (this.mode != eventDataMap['value']) {
                        def sentMode = eventDataMap['value']
                        println("The location is changed to $sentMode!")
                if (this.mode != eventDataMap['value']) {
                        def sentMode = eventDataMap['value']
                        println("The location is changed to $sentMode!")
-                       this.mode = sentMode
-                       this.locationMode = sentMode
+                       if (sentMode == "home") {
+                               this.mode = "home"
+                               this.locationMode = "home"
+                       } else if (sentMode == "away") {
+                               this.mode = "away"
+                               this.locationMode = "away"
+                       } else if (sentMode == "night") {
+                               this.mode = "night"
+                               this.locationMode = "night"
+                       } else {
+                               this.mode = sentMode
+                               this.locationMode = sentMode
+                       }
                        sendEvent(eventDataMap)
                }
        }
                        sendEvent(eventDataMap)
                }
        }