Infrastructure compatible for all groups instead of switches.
[smartthings-infrastructure.git] / AccelerationSensor / AccelerationSensors.groovy
index 8c1992cd4065996444a755ce629826dbc1a2ca02..7df4347f47bea0915b29841bea4374132309c9d9 100644 (file)
@@ -17,6 +17,7 @@ public class AccelerationSensors {
        private String acceleration = "inactive"
        private String currentAcceleration = "inactive"
        private String accelerationLatestValue = "inactive"
+       
 
                
        AccelerationSensors(Closure sendEvent, int deviceNumbers) {
@@ -24,28 +25,37 @@ public class AccelerationSensors {
                this.deviceNumbers = deviceNumbers
                this.accelerationSensors = []
 
-               def init = Verify.getBoolean()
+               /*def init = Verify.getBoolean()
                if (init) {
                        this.acceleration = "inactive"
                        this.accelerationLatestValue = "inactive"
                } else {
                        this.acceleration = "active"
                        this.accelerationLatestValue = "active"
-               }
+               }*/
                accelerationSensors.add(new AccelerationSensor(id, label, displayName, this.acceleration, this.accelerationLatestValue))
        }
 
        //By Model Checker
        def setValue(LinkedHashMap eventDataMap) {
                if (eventDataMap["value"] != accelerationSensors[0].acceleration) {
+                       this.accelerationLatestValue = eventDataMap["value"]
+                       this.acceleration = eventDataMap["value"]
+                       this.currentAcceleration = eventDataMap["value"]
                        accelerationSensors[0].setValue(eventDataMap["value"])
-                       this.accelerationLatestValue = accelerationSensors[0].accelerationLatestValue
-                       this.acceleration = accelerationSensors[0].acceleration
-                       this.currentAcceleration = accelerationSensors[0].acceleration
                        sendEvent(eventDataMap)
                }
        }
 
+       //methods
+       def eventsSince(Date dateObj) {
+               return accelerationSensors[0].eventsSince()
+       }
+               
+       def statesSince(String info, Date dateObj) {
+               return accelerationSensors[0].statesSince()
+       }
+
        //Methods for closures
        def count(Closure Input) {
                accelerationSensors.count(Input)
@@ -56,6 +66,9 @@ public class AccelerationSensors {
        def each(Closure Input) {
                accelerationSensors.each(Input)
        }
+       def sort(Closure Input) {
+               accelerationSensors.each(Input)
+       }
        def find(Closure Input) {
                accelerationSensors.find(Input)
        }
@@ -72,10 +85,6 @@ public class AccelerationSensors {
                accelerationSensors[0].latestValue(deviceFeature)//It is called if we have only one device
        }
 
-       def statesSince(String info, Date dateObj) {
-               return accelerationSensors[0].statesSince(info, dateObj)
-       }
-
        def getAt(int ix) {
                accelerationSensors[ix]
        }