//Create a class for sleep sensor package SleepSensor import SmartThing.SmartThing public class SleepSensor 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 currentSleeping = new StringBuilder() // Maps from features to values HashMap deviceValuesMap = new HashMap() SleepSensor(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName, StringBuilder currentSleeping) { deviceValuesMap = deviceValueSmartThing idSmartThing = id labelSmartThing = label displayNameSmartThing = displayName sendEventSmartThings = sendEvent // Initialization this.id = id this.label = label this.displayName = displayName this.currentSleeping = currentSleeping deviceValuesMap.put("sleeping", currentSleeping) } // Methods to return values def getCurrentSleeping() { return currentSleeping.toString() } }