Removing getXXX methods + properties. Adding getProperty feature to SmartThing(s)
[smartthings-infrastructure.git] / Location / LocationVar.groovy
index e7328c569e6b89513b4139ce94705dc5e36e77e9..6a8e6d3065d6535e60b39f7402ec9f27977cf187 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,24 +19,20 @@ 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"]]
                        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")     
@@ -49,27 +40,12 @@ public class LocationVar extends SmartThing {
                                mode.append("home")
 
                        deviceValuesMap.put("mode", mode)
-                       deviceValuesMap.put("Location", mode)
+                       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 getMode() {
-               return mode.toString()
-       }
-
-       def getLocationMode() {
-               return locationMode.toString()
-       }
-
-       def getName() {
-               return name.toString()
-       }
-
-       def getTemperatureScale() {
-               return temperatureScale.toString()
-       }
-
-       def getContactBookEnabled() {
-               return contactBookEnabled.getValue()
-       }
 }