Fixing bugs in classes
[smartthings-infrastructure.git] / SwitchLevel / SwitchLevel.groovy
index ff83a50e86a0c8c51b96499b252f2aa7b4c9943b..8782365c322147d3d01655b98b77c51419f8e860 100644 (file)
@@ -96,9 +96,16 @@ 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()
+               }
        }
 }