Flatten the structure of event while-loop.
[smartthings-infrastructure.git] / StepSensor / StepSensors.groovy
index cc709fe704b507f0cf161124947767c1aab26f90..021db256317e3006a4bf8b86ecbf2d3f8305604e 100644 (file)
@@ -34,15 +34,15 @@ public class StepSensors {
        //By Model Checker
        def setValue(LinkedHashMap eventDataMap) {
                if (eventDataMap["name"] == "steps") {
-                       if (eventDataMap["value"] != stepSensors[0].steps) {
+                       if (eventDataMap["value"].toInteger() != stepSensors[0].steps) {
+                               this.steps = eventDataMap["value"].toInteger()
                                stepSensors[0].setValue(eventDataMap["value"], "steps")
-                               this.steps = stepSensors[0].steps
                                sendEvent(eventDataMap)
                        }
-               } else if (eventDataMap["value"] == "goal") {
-                       if (eventDataMap["value"] != stepSensors[0].goal) {
+               } else if (eventDataMap["name"] == "goal") {
+                       if (eventDataMap["value"].toInteger() != stepSensors[0].goal) {
+                               this.goal = eventDataMap["value"].toInteger()
                                stepSensors[0].setValue(eventDataMap["value"], "goal")
-                               this.goal = stepSensors[0].goal
                                sendEvent(eventDataMap)
                        }
                }
@@ -61,6 +61,9 @@ public class StepSensors {
        def find(Closure Input) {
                stepSensors.find(Input)
        }
+       def sort(Closure Input) {
+               stepSensors.sort(Input)
+       }
        def collect(Closure Input) {
                stepSensors.collect(Input)
        }