Fixing bugs in infrastructure
[smartthings-infrastructure.git] / Location / LocationVar.groovy
index 986cf78702dadf78052a295b3685b47acd1ce76f..403055d6b6dc331315d6aa2d7de4491a1d1f415f 100755 (executable)
@@ -2,19 +2,14 @@
 package Location
 import SmartThing.SmartThing
 
-//Importing mutable integer class
-import MutableInteger.MutableInteger
-
 public class LocationVar extends SmartThing {
-       // Features with numberical values
-       MutableInteger contactBookEnabled = new MutableInteger()
-       // Features with string values
-       StringBuilder mode = new StringBuilder()
-       StringBuilder locationMode = mode
-       StringBuilder name = new StringBuilder()
-       StringBuilder temperatureScale = new StringBuilder()
+       // id, label, and display name of the device
+       String id
+       String label
+       String displayName
        // Maps from features to values
-       HashMap<String, StringBuilder> deviceValuesMap = new HashMap<String, StringBuilder>()
+       HashMap<String, String> deviceValuesMap = new HashMap<String, String>()
+       HashMap<String, Integer> deviceIntValuesMap = new HashMap<String, Integer>()
        // Other variables
        Phrase helloHome
        TimeZone timeZone
@@ -24,59 +19,34 @@ public class LocationVar extends SmartThing {
        List phoneNumbers
        
        LocationVar(Closure sendEvent, boolean init) {
-                       deviceValuesMap = deviceValueSmartThing
+                       deviceValueSmartThing = deviceValuesMap
+                       deviceIntValueSmartThing = deviceIntValuesMap
+                       idSmartThing = id
+                       labelSmartThing = label
+                       displayNameSmartThing = displayName
                        sendEventSmartThings = sendEvent
 
                        // Initialization
-                       StringBuilder sunset = new StringBuilder("sunset")
-                       StringBuilder sunsetTime = sunset
-                       StringBuilder sunrise = new StringBuilder("sunrise")
-                       StringBuilder sunriseTime = sunrise
-                       hubs = [[id:0, localIP:"128.195.204.105"]]
-                       modes = [[name: "home"],[name: "away"],[name: "night"]]
+                       String mode
                        helloHome = new Phrase()
-                       contactBookEnabled.setValue(1)
                        contacts = ['AJ']
                        phoneNumbers = [9495379373]
-                       name.append("hub0")
-                       temperatureScale.append("F")
+                       modes = [[name: "home"],[name: "away"],[name: "night"]]
                        timeZone = TimeZone.getTimeZone("America/New_York")
-                       
+                       hubs = [[id:0, localIP:"128.195.204.105"]]
 
                        if (init)
-                               mode.append("away")     
+                               mode = "away"   
                        else
-                               mode.append("home")
+                               mode = "home"
 
                        deviceValuesMap.put("mode", mode)
-                       deviceValuesMap.put("Location", mode)
-                       deviceValuesMap.put("sunset", sunset)
-                       deviceValuesMap.put("sunrise", sunrise)
+                       deviceValuesMap.put("name", "hub0")
+                       deviceValuesMap.put("temperatureScale", "F")
+                       deviceValuesMap.put("sunset", "sunset")
+                       deviceValuesMap.put("sunrise", "sunrise")
+                       deviceValuesMap.put("sunsetTime", "sunsetTime")
+                       deviceValuesMap.put("sunriseTime", "sunriseTime")
+                       deviceIntValuesMap.put("contactBookEnabled", 1)
        }
-
-       // Methods to return values
-       def currentValue(String deviceFeature) {
-               if (deviceFeature == "sunsetTime" || deviceFeature == "sunset")
-                       return System.currentTimeMillis()
-       }
-
-       def getMode() {
-               return mode.toString()
-       }
-
-       def getLocationMode() {
-               return locationMode.toString()
-       }
-
-       def getName() {
-               return name.toString()
-       }
-
-       def getTemperatureScale() {
-               return temperatureScale.toString()
-       }
-
-       def getContactBookEnabled() {
-               return contactBookEnabled.getValue()
-       }
 }