Removing getXXX methods + properties. Adding getProperty feature to SmartThing(s)
[smartthings-infrastructure.git] / Momentary / Momentary.groovy
index 6b9f0e0cfd082bdfb3f9d99cefbb2d26f5cc1b4f..27e49c2d08aa27b806a579c307121d940e5cd98d 100644 (file)
@@ -1,31 +1,28 @@
 //Create a class for momentory switch device
 package Momentary
-import Timer.SimulatedTimer
+import SmartThing.SmartThing
 
-public class Momentary {
-       private String id
-       private String label
-       private String displayName
-       def sendEvent   
-       
+public class Momentary extends SmartThing {
+       // id, label, and display name of the device
+       String id
+       String label
+       String displayName
 
        Momentary(Closure sendEvent, String id, String label, String displayName) {
-               this.sendEvent = sendEvent
+               idSmartThing = id
+               labelSmartThing = label
+               displayNameSmartThing = displayName
+               sendEventSmartThings = sendEvent
+
+               // Initialization
                this.id = id
                this.label = label
                this.displayName = displayName
        }
 
-       //By Apps
+       // Methods to set values
        def push() {
-               println("the momentary switch with id:$id is pushed!")
-               sendEvent([name: "momentary", value: "pushed", deviceId: this.id, descriptionText: "",
-                          displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
-       }
-
-       //By Model Checker
-       def setValue(String value) {
-               println("the momentary switch with id:$id is pushed!")
-       }
-       
+               setValue([name: "momentary", value: "pushed", deviceId: id, descriptionText: "",
+                         displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+       }       
 }