- def on(LinkedHashMap metaData) {
- def task = timers.runAfter(metaData["delay"]) {
- switchLatestValue = "on"
- switchState = "on"
- currentSwitch = "on"
- switchLevels[0].on()
- }
- }
-
- def off() {
- switchLatestValue = "off"
- switchState = "off"
- currentSwitch = "off"
- switchLevels[0].off()
- }
-
- def off(LinkedHashMap metaData) {
- def task = timers.runAfter(metaData["delay"]) {
- switchLatestValue = "off"
- switchState = "off"
- currentSwitch = "off"
- switchLevels[0].off()
- }
- }
-
- //By Model Checker
- def setValue(LinkedHashMap eventDataMap) {
- if (eventDataMap["name"] == "switch") {
- if (eventDataMap["value"] != switchLevels[0].switchState) {
- this.switchState = eventDataMap["value"]
- this.switchLatestValue = eventDataMap["value"]
- this.currentSwitch = eventDataMap["value"]
- switchLevels[0].setValue(eventDataMap["value"], "switch")
- sendEvent(eventDataMap)
- }
- } else if (eventDataMap["name"] == "level") {
- if (eventDataMap["value"].toInteger() != switchLevels[0].level) {
- this.level = eventDataMap["value"].toInteger()
- this.currentLevel = eventDataMap["value"].toInteger()
- this.currentRate = eventDataMap["value"].toInteger()
- this.rate = eventDataMap["value"].toInteger()
- switchLevels[0].setValue(eventDataMap["value"], "level")
- sendEvent(eventDataMap)
- }
- }
- }
-
- def currentValue(String deviceFeature) {
- switchLevels[0].currentValue(deviceFeature)
- }
-
- def latestValue(String deviceFeature) {
- switchLevels[0].latestValue(deviceFeature)