this.switchState = "on"
this.currentSwitch = "on"
sendEvent([name: "switch", value: "on", deviceId: this.id, descriptionText: "",
this.switchState = "on"
this.currentSwitch = "on"
sendEvent([name: "switch", value: "on", deviceId: this.id, descriptionText: "",
- displayed: true, linkText: "", isStateChange: false, unit: "", data: [value: "on"]])
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
if (switchState != "on") {
def task = timers.runAfter(metaData["delay"]) {
println("the relay switch with id:$id is on!")
if (switchState != "on") {
def task = timers.runAfter(metaData["delay"]) {
println("the relay switch with id:$id is on!")
this.switchState = "on"
this.currentSwitch = "on"
sendEvent([name: "switch", value: "on", deviceId: this.id, descriptionText: "",
this.switchState = "on"
this.currentSwitch = "on"
sendEvent([name: "switch", value: "on", deviceId: this.id, descriptionText: "",
this.switchState = "off"
this.currentSwitch = "off"
sendEvent([name: "switch", value: "off", deviceId: this.id, descriptionText: "",
this.switchState = "off"
this.currentSwitch = "off"
sendEvent([name: "switch", value: "off", deviceId: this.id, descriptionText: "",
if (switchState != "off") {
def task = timers.runAfter(metaData["delay"]) {
println("the relay switch with id:$id is off!")
if (switchState != "off") {
def task = timers.runAfter(metaData["delay"]) {
println("the relay switch with id:$id is off!")
this.switchState = "off"
this.currentSwitch = "off"
sendEvent([name: "switch", value: "off", deviceId: this.id, descriptionText: "",
this.switchState = "off"
this.currentSwitch = "off"
sendEvent([name: "switch", value: "off", deviceId: this.id, descriptionText: "",