Some minor changes in events' format
[smartthings-infrastructure.git] / Switch / Switch.groovy
index d01d27be361b5268d7b8dcc1e7a21ec44e8cd748..b924d21d3ec3af148d91211fc041ad8db1c57253 100644 (file)
@@ -28,8 +28,12 @@ public class Switch {
 
        //By Apps
        def setLevel(int level) {
-               println("the switch with id:$id is setted to level $level!")
-               this.currentLevel = level
+               if (this.currentLevel != level) {
+                       println("the switch with id:$id is setted to level $level!")
+                       this.currentLevel = level
+                       sendEvent([name: "level", value: "40", deviceId: this.id, descriptionText: "",
+                           displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+               }
        }
 
        def on() {