//Create a class for battery package Battery import SmartThing.SmartThing public class Battery 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 currentBattery = new MutableInteger() // Maps from features to values HashMap deviceIntValuesMap = new HashMap() Battery(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName, MutableInteger currentBattery) { deviceIntValuesMap = deviceIntValueSmartThing idSmartThing = id labelSmartThing = label displayNameSmartThing = displayName sendEventSmartThings = sendEvent // Initialization this.id = id this.label = label this.displayName = displayName this.currentBattery = currentBattery deviceIntValuesMap.put("battery", currentBattery) } // Methods to return values def getCurrentBattery() { return currentBattery.toString() } }