Infrastruction modification
[smartthings-infrastructure.git] / RelativeHumidityMeasurement / RelativeHumidityMeasurement.groovy
1 //Create a class for relative humidity measurement
2 package RelativeHumidityMeasurement
3 import SmartThing.SmartThing
4
5 public class RelativeHumidityMeasurement 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 numberical values
11         MutableInteger currentHumidity = new MutableInteger()
12         // Maps from features to values
13         HashMap<String, MutableInteger> deviceIntValuesMap = new HashMap<String, MutableInteger>()
14
15         RelativeHumidityMeasurement(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName, MutableInteger currentHumidity) {
16                 deviceIntValuesMap = deviceIntValueSmartThing
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.currentHumidity = currentHumidity
27
28                 deviceIntValuesMap.put("humidity", currentHumidity)
29         }
30
31         // Methods to return values
32         def getCurrentHumidity() {
33                 return currentHumidity.getValue()
34         }
35 }