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