Fixing some bugs
[smartthings-infrastructure.git] / Switch / Switch.groovy
index 8bea530..e017b55 100644 (file)
@@ -26,6 +26,44 @@ public class Switch {
                this.switchLatestValue = switchLatestValue
        }
 
+       def eventsSince() {
+               def evtOn = [[name: "switch", value: "on", deviceId: "switchID0", descriptionText: "",
+                               displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}']]
+               def evtOff = [[name: "switch", value: "off", deviceId: "switchID0", descriptionText: "",
+                                 displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}']]
+               def init = Verify.getInt(0,4)
+               def evtToSend = []
+               if (init == 0) {//return empty set
+                       return evtToSend
+               } else if (init == 1) {//send one open event
+                       evtOn.each{
+                               evtToSend.add(it)
+                       }
+                       return evtToSend
+               } else if (init == 2) {//send two open events
+                       evtOn.each{
+                               evtToSend.add(it)
+                       }
+                       evtOn.each{
+                               evtToSend.add(it)
+                       }
+                       return evtToSend
+               } else if (init == 3) {//send one closed event
+                       evtOff.each{
+                               evtToSend.add(it)
+                       }
+                       return evtToSend
+               } else if (init == 4) {//send two closed events
+                       evtOff.each{
+                               evtToSend.add(it)
+                       }
+                       evtOff.each{
+                               evtToSend.add(it)
+                       }
+                       return evtToSend
+               }
+       }
+
        //By Apps
        def setLevel(int level) {
                if (this.currentLevel != level) {