Adding missing methods; rearranging initial values.
authorrtrimana <rtrimana@uci.edu>
Sun, 11 Aug 2019 06:40:48 +0000 (23:40 -0700)
committerrtrimana <rtrimana@uci.edu>
Sun, 11 Aug 2019 06:40:48 +0000 (23:40 -0700)
ColorControl/ColorControl.groovy
ColorControl/ColorControls.groovy
Event/Event.groovy

index e0a905f4fe554795279983c62d67d6d0876852ec..f24d274ad61ed0bf98736a9e1d5679e3378ab099 100644 (file)
@@ -127,7 +127,7 @@ public class ColorControl {
                        this.hue = hue
                        this.currentHue = hue
                        println("The hue level of the light is changed to $hue!")
                        this.hue = hue
                        this.currentHue = hue
                        println("The hue level of the light is changed to $hue!")
-                       sendEvent([name: "hue", value: "${hue}", deviceId: this.id, descriptionText: "",
+                       sendEvent([name: "hue", value: "$hue", deviceId: this.id, descriptionText: "",
                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
@@ -141,6 +141,17 @@ public class ColorControl {
                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
+       
+       def setSaturation(double saturation) {
+               if (saturation != this.saturation) {
+                       this.currentSaturation = saturation
+                       this.saturation = saturation
+                       println("The saturation level of the light is changed to $saturation!")
+                       sendEvent([name: "saturation", value: "$saturation", deviceId: this.id, descriptionText: "",
+                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+               }
+       }
+
 
        def setLevel(int level) {
                if (level != this.level) {
 
        def setLevel(int level) {
                if (level != this.level) {
index 5eb237bec7fcec7482bc42751373d05c1676885d..a2c93de0049933825c71eb151b9b857806f20588 100644 (file)
@@ -38,7 +38,7 @@ public class ColorControls {
                        this.currentSaturation = 40
                        this.colorTemperature = 10000
                        this.color = "Red"
                        this.currentSaturation = 40
                        this.colorTemperature = 10000
                        this.color = "Red"
-                       this.currentSwitch = "off"
+                       this.currentSwitch = "on"
                } else {
                        this.level = 50
                        this.currentLevel = 50
                } else {
                        this.level = 50
                        this.currentLevel = 50
@@ -48,7 +48,7 @@ public class ColorControls {
                        this.currentSaturation = 50
                        this.colorTemperature = 15000
                        this.color = "Blue"
                        this.currentSaturation = 50
                        this.colorTemperature = 15000
                        this.color = "Blue"
-                       this.currentSwitch = "on"
+                       this.currentSwitch = "off"
                }
                colorControls.add(new ColorControl(sendEvent, id, label, displayName, this.color, this.hue, this.saturation, this.level, this.currentSwitch, this.colorTemperature))
        }
                }
                colorControls.add(new ColorControl(sendEvent, id, label, displayName, this.color, this.hue, this.saturation, this.level, this.currentSwitch, this.colorTemperature))
        }
@@ -193,7 +193,7 @@ public class ColorControls {
                if (hue != this.hue) {
                        this.hue = hue
                        this.currentHue = hue
                if (hue != this.hue) {
                        this.hue = hue
                        this.currentHue = hue
-                       colorControls[0].setHue(hue)
+                       colorControls[0].setHue((int) hue)
                }
        }
 
                }
        }
 
@@ -204,6 +204,14 @@ public class ColorControls {
                        colorControls[0].setSaturation(saturation)                      
                }       
        }
                        colorControls[0].setSaturation(saturation)                      
                }       
        }
+       
+       def setSaturation(double saturation) {
+               if (saturation != this.saturation) {
+                       this.currentSaturation = saturation
+                       this.saturation = saturation
+                       colorControls[0].setSaturation(saturation)                      
+               }       
+       }
 
        def setLevel(int level) {
                if (level != this.level) {
 
        def setLevel(int level) {
                if (level != this.level) {
index 7e834345ac2da8b4b09f47427e99c6f8e806cf4f..15e34589786222b88aaf895c739efc8bb9572d60 100644 (file)
@@ -34,6 +34,9 @@ public class Event {
                this.jsonData = new groovy.json.JsonSlurper().parseText(data)
                this.displayed = displayed
                if (integerValues.contains(name)) {
                this.jsonData = new groovy.json.JsonSlurper().parseText(data)
                this.displayed = displayed
                if (integerValues.contains(name)) {
+                       int dot = value.indexOf('.')
+                       if (dot != -1)
+             value = value.substring(0, dot)
                        this.integerValue = value.toInteger()
                        this.doubleValue = Double.parseDouble(value);           
                }
                        this.integerValue = value.toInteger()
                        this.doubleValue = Double.parseDouble(value);           
                }