1 //Create a class for location variable
3 import SmartThing.SmartThing
5 public class LocationVar extends SmartThing {
6 // Features with numberical values
7 MutableInteger contactBookEnabled = new MutableInteger()
8 // Features with string values
9 StringBuilder mode = new StringBuilder()
10 StringBuilder locationMode = mode
11 StringBuilder name = new StringBuilder()
12 StringBuilder temperatureScale = new StringBuilder()
13 // Maps from features to values
14 HashMap<String, StringBuilder> deviceValuesMap = new HashMap<String, StringBuilder>()
23 LocationVar(Closure sendEvent, boolean init) {
24 deviceValuesMap = deviceValueSmartThing
25 sendEventSmartThings = sendEvent
28 StringBuilder sunset = new StringBuilder("sunset")
29 StringBuilder sunsetTime = sunset
30 StringBuilder sunrise = new StringBuilder("sunrise")
31 StringBuilder sunriseTime = sunrise
32 hubs = [[id:0, localIP:"128.195.204.105"]]
33 modes = [[name: "home"],[name: "away"],[name: "night"]]
34 helloHome = new Phrase()
35 contactBookEnabled.setValue(1)
37 phoneNumbers = [9495379373]
39 temperatureScale.append("F")
40 timeZone = TimeZone.getTimeZone("America/New_York")
48 deviceValuesMap.put("mode", mode)
49 deviceValuesMap.put("Location", mode)
50 deviceValuesMap.put("sunset", sunset)
51 deviceValuesMap.put("sunrise", sunrise)
54 // Methods to return values
55 def currentValue(String deviceFeature) {
56 if (deviceFeature == "sunsetTime" || deviceFeature == "sunset")
57 return System.currentTimeMillis()
61 return mode.toString()
64 def getLocationMode() {
65 return locationMode.toString()
69 return name.toString()
72 def getTemperatureScale() {
73 return temperatureScale.toString()
76 def getContactBookEnabled() {
77 return contactBookEnabled.getValue()