6a8e6d3065d6535e60b39f7402ec9f27977cf187
[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                         helloHome = new Phrase()
31                         contacts = ['AJ']
32                         phoneNumbers = [9495379373]
33                         modes = [[name: "home"],[name: "away"],[name: "night"]]
34                         timeZone = TimeZone.getTimeZone("America/New_York")
35                         hubs = [[id:0, localIP:"128.195.204.105"]]
36
37                         if (init)
38                                 mode.append("away")     
39                         else
40                                 mode.append("home")
41
42                         deviceValuesMap.put("mode", mode)
43                         deviceValuesMap.put("name", "hub0")
44                         deviceValuesMap.put("temperatureScale", "F")
45                         deviceValuesMap.put("sunset", "sunset")
46                         deviceValuesMap.put("sunrise", "sunrise")
47                         deviceValuesMap.put("sunsetTime", "sunsetTime")
48                         deviceValuesMap.put("sunriseTime", "sunriseTime")
49                         deviceIntValuesMap.put("contactBookEnabled", 1)
50         }
51 }