Fixing bug in Mobile Presence class
[smartthings-infrastructure.git] / Location / LocationVar.groovy
1 //Create a class for location variable
2 package Location
3 import SmartThing.SmartThing
4
5 public class LocationVar extends SmartThing {
6         // id, label, and display name of the device
7         String id
8         String label
9         String displayName
10         // Maps from features to values
11         HashMap<String, String> deviceValuesMap = new HashMap<String, String>()
12         HashMap<String, Integer> deviceIntValuesMap = new HashMap<String, Integer>()
13         // Other variables
14         Phrase helloHome
15         TimeZone timeZone
16         def modes
17         def hubs
18         List contacts
19         List phoneNumbers
20         
21         LocationVar(Closure sendEvent, boolean init) {
22                         deviceValueSmartThing = deviceValuesMap
23                         deviceIntValueSmartThing = deviceIntValuesMap
24                         idSmartThing = id
25                         labelSmartThing = label
26                         displayNameSmartThing = displayName
27                         sendEventSmartThings = sendEvent
28
29                         // Initialization
30                         String mode
31                         helloHome = new Phrase()
32                         contacts = ['AJ']
33                         phoneNumbers = [9495379373]
34                         modes = [[name: "home"],[name: "away"],[name: "night"]]
35                         timeZone = TimeZone.getTimeZone("America/New_York")
36                         hubs = [[id:0, localIP:"128.195.204.105"]]
37
38                         if (init)
39                                 mode = "away"   
40                         else
41                                 mode = "home"
42
43                         deviceValuesMap.put("mode", mode)
44                         deviceValuesMap.put("name", "hub0")
45                         deviceValuesMap.put("temperatureScale", "F")
46                         deviceValuesMap.put("sunset", "sunset")
47                         deviceValuesMap.put("sunrise", "sunrise")
48                         deviceValuesMap.put("sunsetTime", "sunsetTime")
49                         deviceValuesMap.put("sunriseTime", "sunriseTime")
50                         deviceIntValuesMap.put("contactBookEnabled", 1)
51         }
52 }