//Create a class for step sensor package StepSensor import SmartThing.SmartThing public class StepSensor extends SmartThing { // id, label, and display name of the device StringBuilder id = new StringBuilder() StringBuilder label = new StringBuilder() StringBuilder displayName = new StringBuilder() // Features with numberical values MutableInteger currentGoal = new MutableInteger() MutableInteger currentSteps = new MutableInteger() // Maps from features to values HashMap deviceIntValuesMap = new HashMap() StepSensor(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName, MutableInteger currentSteps, MutableInteger currentGoal) { deviceIntValuesMap = deviceIntValueSmartThing idSmartThing = id labelSmartThing = label displayNameSmartThing = displayName sendEventSmartThings = sendEvent // Initialization this.id = id this.label = label this.displayName = displayName this.currentSteps = currentSteps this.currentGoal = currentGoal deviceIntValuesMap.put("steps", currentSteps) deviceIntValuesMap.put("goal", currentGoal) } // Methods to return values def getCurrentSteps() { return currentSteps.getValue() } def getCurrentGoal() { return currentGoal.getValue() } }