8d7c4e06028571d75ba28150718f1c485e076595
[smartthings-infrastructure.git] / RelativeHumidityMeasurement / RelativeHumidityMeasurement.groovy
1 //Create a class for relative humidity measurement
2 package RelativeHumidityMeasurement
3 import SmartThing.SmartThing
4
5 //Importing mutable integer class
6 import MutableInteger.MutableInteger
7
8 public class RelativeHumidityMeasurement 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 currentHumidity = new MutableInteger()
15         // Maps from features to values
16         HashMap<String, MutableInteger> deviceIntValuesMap = new HashMap<String, MutableInteger>()
17
18         RelativeHumidityMeasurement(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName, MutableInteger currentHumidity) {
19                 deviceIntValuesMap = deviceIntValueSmartThing
20                 idSmartThing = id
21                 labelSmartThing = label
22                 displayNameSmartThing = displayName
23                 sendEventSmartThings = sendEvent
24
25                 // Initialization
26                 this.id = id
27                 this.label = label
28                 this.displayName = displayName
29                 this.currentHumidity = currentHumidity
30
31                 deviceIntValuesMap.put("humidity", currentHumidity)
32         }
33
34         // Methods to return values
35         def getCurrentHumidity() {
36                 return currentHumidity.getValue()
37         }
38 }