//Create a class for location variable package Location import SmartThing.SmartThing //Importing mutable integer class import MutableInteger.MutableInteger public class LocationVar extends SmartThing { // Features with numberical values MutableInteger contactBookEnabled = new MutableInteger() // Features with string values StringBuilder mode = new StringBuilder() StringBuilder locationMode = mode StringBuilder name = new StringBuilder() StringBuilder temperatureScale = new StringBuilder() // Maps from features to values HashMap deviceValuesMap = new HashMap() // Other variables Phrase helloHome TimeZone timeZone def modes def hubs List contacts List phoneNumbers LocationVar(Closure sendEvent, boolean init) { deviceValuesMap = deviceValueSmartThing sendEventSmartThings = sendEvent // Initialization StringBuilder sunset = new StringBuilder("sunset") StringBuilder sunsetTime = sunset StringBuilder sunrise = new StringBuilder("sunrise") StringBuilder sunriseTime = sunrise hubs = [[id:0, localIP:"128.195.204.105"]] modes = [[name: "home"],[name: "away"],[name: "night"]] helloHome = new Phrase() contactBookEnabled.setValue(1) contacts = ['AJ'] phoneNumbers = [9495379373] name.append("hub0") temperatureScale.append("F") timeZone = TimeZone.getTimeZone("America/New_York") if (init) mode.append("away") else mode.append("home") deviceValuesMap.put("mode", mode) deviceValuesMap.put("Location", mode) deviceValuesMap.put("sunset", sunset) deviceValuesMap.put("sunrise", sunrise) } // Methods to return values def currentValue(String deviceFeature) { if (deviceFeature == "sunsetTime" || deviceFeature == "sunset") return System.currentTimeMillis() } def getMode() { return mode.toString() } def getLocationMode() { return locationMode.toString() } def getName() { return name.toString() } def getTemperatureScale() { return temperatureScale.toString() } def getContactBookEnabled() { return contactBookEnabled.getValue() } }