1 //Create a class for step sensor
3 import SmartThing.SmartThing
5 //Importing mutable integer class
6 import MutableInteger.MutableInteger
8 public class StepSensor extends SmartThing {
9 // id, label, and display name of the device
10 StringBuilder id = new StringBuilder()
11 StringBuilder label = new StringBuilder()
12 StringBuilder displayName = new StringBuilder()
13 // Features with numberical values
14 MutableInteger currentGoal = new MutableInteger()
15 MutableInteger currentSteps = new MutableInteger()
16 // Maps from features to values
17 HashMap<String, MutableInteger> deviceIntValuesMap = new HashMap<String, MutableInteger>()
19 StepSensor(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName, MutableInteger currentSteps, MutableInteger currentGoal) {
20 deviceIntValuesMap = deviceIntValueSmartThing
22 labelSmartThing = label
23 displayNameSmartThing = displayName
24 sendEventSmartThings = sendEvent
29 this.displayName = displayName
30 this.currentSteps = currentSteps
31 this.currentGoal = currentGoal
33 deviceIntValuesMap.put("steps", currentSteps)
34 deviceIntValuesMap.put("goal", currentGoal)
37 // Methods to return values
38 def getCurrentSteps() {
39 return currentSteps.getValue()
42 def getCurrentGoal() {
43 return currentGoal.getValue()