Infrastructure now works for: locks, alarms, thermostats, and non-hue lights.
[smartthings-infrastructure.git] / SwitchLevel / SwitchLevel.groovy
index ff83a50e86a0c8c51b96499b252f2aa7b4c9943b..24bd7bfa0f3b03aba3b026067cdfaa1171641297 100644 (file)
@@ -96,9 +96,33 @@ public class SwitchLevel {
        }
 
        //By Model Checker
-       def setValue(String value) {
-               println("the switch with id:$id is setted to level $value!")
-               this.level = value.toInteger()
-               this.rate = value.toInteger()
+       def setValue(String value, String name) {
+               if (name == "switch") {
+                       println("the switch with id:$id is $value!")
+                       this.switchLatestValue = value
+                       this.switchState = value
+                       this.currentSwitch = value
+               } else if (name == "level") {
+                       println("the switch with id:$id is setted to level $value!")
+                       this.level = value.toInteger()
+                       this.rate = value.toInteger()
+               }
+       }
+
+
+       def currentValue(String deviceFeature) {
+               if (deviceFeature == "level") {
+                       return level
+               } else if (deviceFeature == "switch") {
+                       return switchState
+               }
+       }
+
+       def latestValue(String deviceFeature) {
+               if (deviceFeature == "level") {
+                       return level
+               } else if (deviceFeature == "switch") {
+                       return switchState
+               }
        }
 }