Adding missing methods; setting default value to on.
[smartthings-infrastructure.git] / SwitchLevel / SwitchLevel.groovy
index 24bd7bfa0f3b03aba3b026067cdfaa1171641297..ccd8e9662e8010991e2bba1661b70b6e825d830e 100644 (file)
@@ -38,6 +38,16 @@ public class SwitchLevel {
                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
+       
+       def setLevel(long level) {
+               if (this.level != level) {
+                       println("the switch with id:$id is setted to level $level!")
+                       this.level = level
+                       this.rate = level
+                       sendEvent([name: "level", value: "$level", deviceId: this.id, descriptionText: "",
+                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+               }
+       }
 
        def on() {
                if (this.switchState != "on") {