1 //Create a class for location variable
3 import SmartThing.SmartThing
5 //Importing mutable integer class
6 import MutableInteger.MutableInteger
8 public class LocationVar extends SmartThing {
9 // Features with numberical values
10 MutableInteger contactBookEnabled = new MutableInteger()
11 // Features with string values
12 StringBuilder mode = new StringBuilder()
13 StringBuilder locationMode = mode
14 StringBuilder name = new StringBuilder()
15 StringBuilder temperatureScale = new StringBuilder()
16 // Maps from features to values
17 HashMap<String, StringBuilder> deviceValuesMap = new HashMap<String, StringBuilder>()
26 LocationVar(Closure sendEvent, boolean init) {
27 deviceValuesMap = deviceValueSmartThing
28 sendEventSmartThings = sendEvent
31 StringBuilder sunset = new StringBuilder("sunset")
32 StringBuilder sunsetTime = sunset
33 StringBuilder sunrise = new StringBuilder("sunrise")
34 StringBuilder sunriseTime = sunrise
35 hubs = [[id:0, localIP:"128.195.204.105"]]
36 modes = [[name: "home"],[name: "away"],[name: "night"]]
37 helloHome = new Phrase()
38 contactBookEnabled.setValue(1)
40 phoneNumbers = [9495379373]
42 temperatureScale.append("F")
43 timeZone = TimeZone.getTimeZone("America/New_York")
51 deviceValuesMap.put("mode", mode)
52 deviceValuesMap.put("Location", mode)
53 deviceValuesMap.put("sunset", sunset)
54 deviceValuesMap.put("sunrise", sunrise)
57 // Methods to return values
58 def currentValue(String deviceFeature) {
59 if (deviceFeature == "sunsetTime" || deviceFeature == "sunset")
60 return System.currentTimeMillis()
64 return mode.toString()
67 def getLocationMode() {
68 return locationMode.toString()
72 return name.toString()
75 def getTemperatureScale() {
76 return temperatureScale.toString()
79 def getContactBookEnabled() {
80 return contactBookEnabled.getValue()