//Create a class for momentory switch device package Momentary 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() Momentary(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName) { idSmartThing = id labelSmartThing = label displayNameSmartThing = displayName sendEventSmartThings = sendEvent // Initialization this.id = id this.label = label this.displayName = displayName } // 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"}']) } }