Minor change in classes
[smartthings-infrastructure.git] / IlluminanceMeasurement / IlluminanceMeasurements.groovy
1 //Create a class for illuminance measurement
2 package IlluminanceMeasurement
3 import SmartThing.SmartThings
4
5 //Importing mutable integer class
6 import MutableInteger.MutableInteger
7
8 public class IlluminanceMeasurements extends SmartThings {
9         List illuminanceMeasurements = new ArrayList()
10                 
11         IlluminanceMeasurements(Closure sendEvent, boolean init) {
12                 // Only initialize one time since we only have one device for each capability
13                 illuminanceMeasurements = smartThings
14
15                 // Initialization
16                 StringBuilder id = new StringBuilder("illuminanceID0")
17                 StringBuilder label = new StringBuilder("illuminance")
18                 StringBuilder displayName = new StringBuilder("illuminance0")
19                 MutableInteger illuminance = new MutableInteger()
20
21                 if (init)
22                         illuminance.setValue(20000)
23                 else
24                         illuminance.setValue(5)
25
26                 illuminanceMeasurements.add(new IlluminanceMeasurement(sendEvent, id, label, displayName, illuminance))
27         }
28
29         // Methods to return values
30         def getCurrentIlluminance() {
31                 List tmpValues = new ArrayList()
32                 tmpValues.add(illuminanceMeasurements[0].getCurrentIlluminance())
33                 return tmpValues
34         }
35 }