65f1ce0d99bf1209a2988e8888753d287fb1b6fc
[smartthings-infrastructure.git] / CarbonMonoxideDetector / CarbonMonoxideDetector.groovy
1 //Create a class for carbon monoxide detector
2 package CarbonMonoxideDetector
3 import SmartThing.SmartThing
4
5 public class CarbonMonoxideDetector extends SmartThing {
6         // id, label, and display name of the device
7         StringBuilder id = new StringBuilder()
8         StringBuilder label = new StringBuilder()
9         StringBuilder displayName = new StringBuilder()
10         // Features with string values
11         StringBuilder currentCarbonMonoxideValue = new StringBuilder()
12         // Maps from features to values
13         HashMap<String, StringBuilder> deviceValuesMap = new HashMap<String, StringBuilder>()
14
15         CarbonMonoxideDetector(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName, StringBuilder currentCarbonMonoxideValue) {
16                 deviceValuesMap = deviceValueSmartThing
17                 idSmartThing = id
18                 labelSmartThing = label
19                 displayNameSmartThing = displayName
20                 sendEventSmartThings = sendEvent
21
22                 // Initialization
23                 this.id = id
24                 this.label = label
25                 this.displayName = displayName
26                 this.currentCarbonMonoxideValue = currentCarbonMonoxideValue
27
28                 deviceValuesMap.put("carbonMonoxide", currentCarbonMonoxideValue)
29         }
30
31         // Methods to return values
32         def getCurrentCarbonMonoxideValue() {
33                 return currentCarbonMonoxideValue.toString()
34         }
35 }