Removing getXXX methods + properties. Adding getProperty feature to SmartThing(s)
[smartthings-infrastructure.git] / Location / LocationVar.groovy
old mode 100644 (file)
new mode 100755 (executable)
index cfaa308..6a8e6d3
@@ -1,21 +1,51 @@
 //Create a class for location variable
 package Location
+import SmartThing.SmartThing
 
-class LocationVar {
-       private int contactBookEnabled
-       private String modes
-       private String mode
-       private List contacts
-       private List phoneNumbers
-    
-       private Phrase helloHome
+public class LocationVar extends SmartThing {
+       // id, label, and display name of the device
+       String id
+       String label
+       String displayName
+       // Maps from features to values
+       HashMap<String, String> deviceValuesMap = new HashMap<String, String>()
+       HashMap<String, Integer> deviceIntValuesMap = new HashMap<String, Integer>()
+       // Other variables
+       Phrase helloHome
+       TimeZone timeZone
+       def modes
+       def hubs
+       List contacts
+       List phoneNumbers
+       
+       LocationVar(Closure sendEvent, boolean init) {
+                       deviceValueSmartThing = deviceValuesMap
+                       deviceIntValueSmartThing = deviceIntValuesMap
+                       idSmartThing = id
+                       labelSmartThing = label
+                       displayNameSmartThing = displayName
+                       sendEventSmartThings = sendEvent
 
-       LocationVar() {
-               this.modes = "'home', 'away', 'night'"
-               this.mode = "home"
-               this.helloHome = new Phrase()
-               this.contactBookEnabled = 1
-               this.contacts = ['AJ']
-               this.phoneNumbers = [9495379373]
+                       // Initialization
+                       helloHome = new Phrase()
+                       contacts = ['AJ']
+                       phoneNumbers = [9495379373]
+                       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")     
+                       else
+                               mode.append("home")
+
+                       deviceValuesMap.put("mode", 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)
        }
 }