Adjusting setLocationMode for global-variable conflict detection.
[smartthings-infrastructure.git] / Location / LocationVar.groovy
index ca20cff63e615262e02dbc1eed6704091554911b..a114c1f019bf02ee1b8a29beacdf566e62a0b519 100644 (file)
@@ -10,21 +10,39 @@ class LocationVar {
        private String name
        private List contacts
        private List phoneNumbers
+       private String temperatureScale 
        def sendEvent
-    
+       
        private Phrase helloHome
 
-       LocationVar(Closure sendEvent) {
-               this.hubs = [[id:0, localIP:"128.195.204.105"]]
-               this.modes = [[name: "home"],[name: "away"],[name: "night"]]
-               this.mode = "home"
-               this.helloHome = new Phrase()
-               this.contactBookEnabled = 1
-               this.contacts = ['AJ']
-               this.phoneNumbers = [9495379373]
-               this.sendEvent = sendEvent
-               this.timeZone = TimeZone.getTimeZone("America/New_York")
-               this.name = "hub0"
+       LocationVar(Closure sendEvent, boolean init) {
+       
+                       if (init) {
+                               this.hubs = [[id:0, localIP:"128.195.204.105"]]
+                               this.modes = [[name: "home"],[name: "away"],[name: "night"]]
+                               this.mode = "away"
+                               this.helloHome = new Phrase()
+                               this.contactBookEnabled = 1
+                               this.contacts = ['AJ']
+                               this.phoneNumbers = [9495379373]
+                               this.sendEvent = sendEvent
+                               this.timeZone = TimeZone.getTimeZone("America/New_York")
+                               this.name = "hub0"
+                               this.temperatureScale = "F"
+                       } else {
+                               this.hubs = [[id:0, localIP:"128.195.204.105"]]
+                               this.modes = [[name: "home"],[name: "away"],[name: "night"]]
+                               this.mode = "home"
+                               this.helloHome = new Phrase()
+                               this.contactBookEnabled = 1
+                               this.contacts = ['AJ']
+                               this.phoneNumbers = [9495379373]
+                               this.sendEvent = sendEvent
+                               this.timeZone = TimeZone.getTimeZone("America/New_York")
+                               this.name = "hub0"
+                               this.temperatureScale = "F"
+                       
+                       }
        }
 
        //By Model Checker
@@ -34,4 +52,9 @@ class LocationVar {
                this.mode = sentMode
                sendEvent(eventDataMap)
        }
+
+       def currentValue(String deviceFeature) {
+               if (deviceFeature == "sunsetTime" || deviceFeature == "sunset")
+                       return System.currentTimeMillis()
+       }
 }