//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"}'])
+ }
}