Infrastructure compatible with 2 types of switches.(Normal switches and otherVsGeneri...
[smartthings-infrastructure.git] / Location / LocationVar.groovy
1 //Create a class for location variable
2 package Location
3
4 class LocationVar {
5         private int contactBookEnabled
6         private def modes
7         private def timeZone
8         private def hubs
9         private String mode
10         private String name
11         private List contacts
12         private List phoneNumbers
13         private String temperatureScale 
14         def sendEvent
15         
16         private Phrase helloHome
17
18         LocationVar(Closure sendEvent) {
19                 this.hubs = [[id:0, localIP:"128.195.204.105"]]
20                 this.modes = [[name: "home"],[name: "away"],[name: "night"]]
21                 this.mode = "home"
22                 this.helloHome = new Phrase()
23                 this.contactBookEnabled = 1
24                 this.contacts = ['AJ']
25                 this.phoneNumbers = [9495379373]
26                 this.sendEvent = sendEvent
27                 this.timeZone = TimeZone.getTimeZone("America/New_York")
28                 this.name = "hub0"
29                 this.temperatureScale = "F"
30         }
31
32         //By Model Checker
33         def setValue(LinkedHashMap eventDataMap) {
34                 def sentMode = eventDataMap['value']
35                 println("The location is changed to $sentMode!")
36                 this.mode = sentMode
37                 sendEvent(eventDataMap)
38         }
39 }