194fc3f1e0617ba844c5b45b13467fac862cef54
[smartthings-infrastructure.git] / MotionSensor / MotionSensors.groovy
1 //Create a class for motion sensor
2 package MotionSensor
3 import SmartThing.SmartThings
4
5 public class MotionSensors extends SmartThings {
6         List motionSensors = new ArrayList()
7                 
8         MotionSensors(Closure sendEvent, boolean init) {
9                 // Only initialize one time since we only have one device for each capability
10                 motionSensors = smartThings
11
12                 // Initialization
13                 StringBuilder id = new StringBuilder("motionSensorID0")
14                 StringBuilder label = new StringBuilder("motion")
15                 StringBuilder displayName = new StringBuilder("motionSensor0")
16                 StringBuilder motion = new StringBuilder()
17
18                 if (init)
19                         motion.append("inactive")
20                 else
21                         motion.append("active")
22
23                 motionSensors.add(new MotionSensor(sendEvent, id, label, displayName, motion))
24         }
25
26         // Methods to return values
27         def getCurrentMotion() {
28                 List tmpValues = new ArrayList()
29                 tmpValues.add(motionSensors[0].getCurrentMotion())
30                 return tmpValues
31         }
32 }