Cancelling the changes for field write.
[smartthings-infrastructure.git] / ColorTemperature / ColorTemperature.groovy
index d73ed9bfb713114ca191af771bc024e0f33ee6cd..250ac12ea9690c99978e688fe50076cab50c64a0 100644 (file)
@@ -49,6 +49,16 @@ public class ColorTemperature {
                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
+       
+       def setLevel(long level) {
+               if (level != this.level) {
+                       this.currentLevel = level
+                       this.level = level
+                       println("The level of the light is changed to $level!")
+                       sendEvent([name: "level", value: "$level", deviceId: this.id, descriptionText: "",
+                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+               }
+       }
 
        def setColorTemperature(int colorTemperature) {
                if (colorTemperature != this.colorTemperature) {
@@ -65,8 +75,6 @@ public class ColorTemperature {
                        println("The light is changed to $currentSwitch!")
                        sendEvent([name: "switch", value: "$currentSwitch", deviceId: this.id, descriptionText: "",
                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
-                       sendEvent([name: "switch.on", value: "$currentSwitch", deviceId: this.id, descriptionText: "",
-                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
 
@@ -76,8 +84,6 @@ public class ColorTemperature {
                        println("The light is changed to $currentSwitch!")
                        sendEvent([name: "switch", value: "$currentSwitch", deviceId: this.id, descriptionText: "",
                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
-                       sendEvent([name: "switch.off", value: "$currentSwitch", deviceId: this.id, descriptionText: "",
-                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }