Removing getXXX methods + properties. Adding getProperty feature to SmartThing(s)
[smartthings-infrastructure.git] / Momentary / Momentary.groovy
index 4e72815d45f93348435de768f10c541e94cb99d5..27e49c2d08aa27b806a579c307121d940e5cd98d 100644 (file)
@@ -4,11 +4,11 @@ import SmartThing.SmartThing
 
 public class Momentary extends SmartThing {
        // id, label, and display name of the device
-       StringBuilder id = new StringBuilder()
-       StringBuilder label = new StringBuilder()
-       StringBuilder displayName = new StringBuilder()
+       String id
+       String label
+       String displayName
 
-       Momentary(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName) {
+       Momentary(Closure sendEvent, String id, String label, String displayName) {
                idSmartThing = id
                labelSmartThing = label
                displayNameSmartThing = displayName
@@ -22,8 +22,7 @@ public class Momentary extends SmartThing {
 
        // Methods to set values
        def push() {
-               println("the momentary switch with id:$id is pushed!")
-               sendEvent([name: "momentary", value: "pushed", deviceId: id, descriptionText: "",
-                          displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+               setValue([name: "momentary", value: "pushed", deviceId: id, descriptionText: "",
+                         displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
        }       
 }