// Create a class for acceleration sensor package AccelerationSensor import SmartThing.SmartThing public class AccelerationSensor extends SmartThing { // id, label, and display name of the device StringBuilder id = new StringBuilder() StringBuilder label = new StringBuilder() StringBuilder displayName = new StringBuilder() // Features with string values StringBuilder currentAcceleration = new StringBuilder() // Maps from features to values HashMap deviceValuesMap = new HashMap() // Possible values for eventsSince method List possibleValues = new ArrayList(); AccelerationSensor(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName, StringBuilder currentAcceleration) { deviceValuesMap = deviceValueSmartThing deviceIntValuesMap = deviceIntValueSmartThing idSmartThing = id labelSmartThing = label displayNameSmartThing = displayName sendEventSmartThings = sendEvent possibleValuesSmartThings = possibleValues // Initialization this.id = id this.label = label this.displayName = displayName this.currentAcceleration = currentAcceleration possibleValues.add("active") possibleValues.add("inactive") deviceValuesMap.put("acceleration", currentAcceleration) } // Methods to return values def getCurrentAcceleration() { return currentAcceleration.toString() } }