Merge branch 'master' of ssh://plrg.eecs.uci.edu/home/git/smartthings-infrastructure
[smartthings-infrastructure.git] / Alarm / Alarms.groovy
index 1e8e68e226263d79acfd2c68ff046cb166f91cae..30c55d9b537ac70d6e9a7a3c3507b6da344914e2 100644 (file)
@@ -41,10 +41,10 @@ public class Alarms {
        //By Model Checker
        def setValue(LinkedHashMap eventDataMap) {
                if (eventDataMap["value"] != alarms[0].alarm) {
+                       this.alarmLatestValue = eventDataMap["value"]
+                       this.alarm = eventDataMap["value"]
+                       this.currentAlarm = eventDataMap["value"]
                        alarms[0].setValue(eventDataMap["value"])
-                       this.alarmLatestValue = alarms[0].alarmLatestValue
-                       this.alarm = alarms[0].alarm
-                       this.currentAlarm = alarms[0].alarm
                        sendEvent(eventDataMap)
                }
        }
@@ -62,6 +62,9 @@ public class Alarms {
        def find(Closure Input) {
                alarms.find(Input)
        }
+       def sort(Closure Input) {
+               alarms.sort(Input)
+       }
        def collect(Closure Input) {
                alarms.collect(Input)
        }
@@ -69,19 +72,19 @@ public class Alarms {
        //By Apps
        def both() {
                if (alarm != "both") {
-                       alarms[0].both()
-                       alarmLatestValue = alarm
+                       alarmLatestValue = "both"
                        alarm = "both"
                        currentAlarm = "both"
+                       alarms[0].both()
                }
        }
 
        def off() {
                if (alarm != "off") {
-                       alarms[0].off()
-                       alarmLatestValue = alarm
+                       alarmLatestValue = "off"
                        alarm = "off"
                        currentAlarm = "off"
+                       alarms[0].off()
                }
        }
 
@@ -91,19 +94,19 @@ public class Alarms {
 
        def siren() {
                if (alarm != "siren") {
-                       alarms[0].siren()
-                       alarmLatestValue = alarm
+                       alarmLatestValue = "siren"
                        alarm = "siren"
                        currentAlarm = "siren"
+                       alarms[0].siren()
                }
        }
 
        def strobe() {
                if (alarm != "strobe") {
-                       alarms[0].strobe()
-                       alarmLatestValue = alarm
+                       alarmLatestValue = "strobe"
                        alarm = "strobe"
                        currentAlarm = "strobe"
+                       alarms[0].strobe()
                }
        }