//Create a class for carbon monoxide detector package CarbonMonoxideDetector import SmartThing.SmartThing public class CarbonMonoxideDetector 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 currentCarbonMonoxideValue = new StringBuilder() // Maps from features to values HashMap deviceValuesMap = new HashMap() CarbonMonoxideDetector(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName, StringBuilder currentCarbonMonoxideValue) { deviceValuesMap = deviceValueSmartThing idSmartThing = id labelSmartThing = label displayNameSmartThing = displayName sendEventSmartThings = sendEvent // Initialization this.id = id this.label = label this.displayName = displayName this.currentCarbonMonoxideValue = currentCarbonMonoxideValue deviceValuesMap.put("carbonMonoxide", currentCarbonMonoxideValue) } // Methods to return values def getCurrentCarbonMonoxideValue() { return currentCarbonMonoxideValue.toString() } }