Merge branch 'master' of ssh://plrg.eecs.uci.edu/home/git/smartthings-infrastructure
authorrtrimana <rtrimana@uci.edu>
Sun, 11 Aug 2019 21:28:53 +0000 (14:28 -0700)
committerrtrimana <rtrimana@uci.edu>
Sun, 11 Aug 2019 21:28:53 +0000 (14:28 -0700)
ColorControl/ColorControl.groovy
ColorControl/ColorControls.groovy
Event/Event.groovy
Extractor/ExtractorScript.py
Switch/Switches.groovy
eventSimulator/buttonHeldEvent.groovy
eventSimulator/buttonPushedEvent.groovy

index c3d652d1e8aa85090c56c75dcb2d564b368b26b6..f24d274ad61ed0bf98736a9e1d5679e3378ab099 100644 (file)
@@ -121,6 +121,16 @@ public class ColorControl {
                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
+       
+       def setHue(double hue) {
+               if (hue != this.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: "",
+                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+               }
+       }
 
        def setSaturation(int saturation) {
                if (saturation != this.saturation) {
@@ -131,6 +141,17 @@ public class ColorControl {
                                   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) {
index 90223c54bdd233baf3feb1690ed53477676ef9e9..a2c93de0049933825c71eb151b9b857806f20588 100644 (file)
@@ -38,7 +38,7 @@ public class ColorControls {
                        this.currentSaturation = 40
                        this.colorTemperature = 10000
                        this.color = "Red"
-                       this.currentSwitch = "off"
+                       this.currentSwitch = "on"
                } else {
                        this.level = 50
                        this.currentLevel = 50
@@ -48,7 +48,7 @@ public class ColorControls {
                        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))
        }
@@ -188,6 +188,14 @@ public class ColorControls {
                        colorControls[0].setHue(hue)
                }
        }
+       
+       def setHue(double hue) {
+               if (hue != this.hue) {
+                       this.hue = hue
+                       this.currentHue = hue
+                       colorControls[0].setHue((int) hue)
+               }
+       }
 
        def setSaturation(int saturation) {
                if (saturation != this.saturation) {
@@ -196,6 +204,14 @@ public class ColorControls {
                        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) {
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)) {
+                       int dot = value.indexOf('.')
+                       if (dot != -1)
+             value = value.substring(0, dot)
                        this.integerValue = value.toInteger()
                        this.doubleValue = Double.parseDouble(value);           
                }
index 660295dc5aea9944eb261ad96b832232a3b91812..8a888fcf194c6a5ba7364b16e0997606bbab261b 100644 (file)
@@ -462,6 +462,7 @@ def ExtractEvents(extractedEvents):
                                extractedEvents.write(line)
                        event.close()
                elif eventList[i] == "motion":
+                        print("HERE????")
                        #Write two events subsequently
                        event = open("eventSimulator/motionActiveEvent.groovy", "r")                    
                        for line in event:
index c27440d0db938f74d5f062dc95615fa1f7e7a3f6..152096db303471cfc66dfece1098095c9ea6e478 100644 (file)
@@ -51,6 +51,9 @@ public class Switches {
        def each(Closure Input) {
                switches.each(Input)
        }
+       def eachWithIndex(Closure Input) {
+               switches.eachWithIndex(Input)
+       }
        def find(Closure Input) {
                switches.find(Input)
        }
index 76209df0fb9e2302688194ad126daf94c52efca5..4c51ef6e6e0c253f0ddcebc9243b0c8823845140 100644 (file)
@@ -1,2 +1,2 @@
                        buttonObject.setValue([name: "button", value: "held", deviceId: "switchID0", descriptionText: "",
-                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"buttonNumber": 3}'])
+                                        displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"buttonNumber": 1}'])
index 0792d4f888f2db6253d17d9faafc2bb216c5d53c..b14d8e70a58dfd456f3c27bd96a816a6f5356057 100644 (file)
@@ -1,2 +1,2 @@
-                       buttonObject.setValue([name: "button", value: "pushed", deviceId: "switchID0", descriptionText: "",
-                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"buttonNumber": 3}'])
+                        buttonObject.setValue([name: "button", value: "pushed", deviceId: "switchID0", descriptionText: "",
+                                        displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"buttonNumber": 1}'])