Infrastructure compatible with 2 types of switches.(Normal switches and otherVsGeneri...
[smartthings-infrastructure.git] / MotionSensor / MotionSensors.groovy
index 340e124e19d4484b124109b78d09defc7551d351..5c03ebf677c2cf90700d63c2d859e8129b5966a0 100644 (file)
@@ -19,17 +19,18 @@ public class MotionSensors {
        private String motionLatestValue = "inactive"
 
                
-       MotionSensors(Closure sendEvent, int deviceNumbers) {
+       MotionSensors(Closure sendEvent, int deviceNumbers, boolean init) {
                this.sendEvent = sendEvent              
                this.deviceNumbers = deviceNumbers
                this.motionSensors = []
 
-               def init = Verify.getBoolean()
                if (init) {
                        this.motion = "inactive"
+                       this.currentMotion = "inactive"
                        this.motionLatestValue = "inactive"
                } else {
                        this.motion = "active"
+                       this.currentMotion = "active"
                        this.motionLatestValue = "active"
                }
                motionSensors.add(new MotionSensor(id, label, displayName, this.motion, this.motionLatestValue))
@@ -65,7 +66,10 @@ public class MotionSensors {
        def collect(Closure Input) {
                motionSensors.collect(Input)
        }
-
+       
+       def currentState(String deviceFeature) {
+               currentValue(deviceFeature)
+       }
 
        def currentValue(String deviceFeature) {
                motionSensors[0].currentValue(deviceFeature)//It is called if we have only one device
@@ -76,7 +80,11 @@ public class MotionSensors {
        }
 
        def statesSince(String info, Date dateObj) {
-               return motionSensors[0].statesSince(info, dateObj)
+               return motionSensors[0].statesSince()
+       }
+
+       def eventsSince(Date dateObj) {
+               return motionSensors[0].statesSince()
        }
 
        def getAt(int ix) {