Infrastructure that works for all the locks' group!
[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 String mode
9         private List contacts
10         private List phoneNumbers
11         def sendEvent
12     
13         private Phrase helloHome
14
15         LocationVar(Closure sendEvent) {
16                 this.modes = [[name: "home"],[name: "away"],[name: "night"]]
17                 this.mode = "home"
18                 this.helloHome = new Phrase()
19                 this.contactBookEnabled = 1
20                 this.contacts = ['AJ']
21                 this.phoneNumbers = [9495379373]
22                 this.sendEvent = sendEvent
23                 this.timeZone = TimeZone.getTimeZone("America/New_York")
24         }
25
26         //By Model Checker
27         def setValue(LinkedHashMap eventDataMap) {
28                 def sentMode = eventDataMap['value']
29                 println("The location is changed to $sentMode!")
30                 this.mode = sentMode
31                 sendEvent(eventDataMap)
32         }
33 }