Adding missing methods; setting default value to on.
authorrtrimana <rtrimana@uci.edu>
Mon, 5 Aug 2019 17:48:40 +0000 (10:48 -0700)
committerrtrimana <rtrimana@uci.edu>
Mon, 5 Aug 2019 17:48:40 +0000 (10:48 -0700)
ColorControl/ColorControls.groovy
ColorTemperature/ColorTemperature.groovy
ColorTemperature/ColorTemperatures.groovy
Extractor/Extractor.groovy
Switch/Switches.groovy
SwitchLevel/SwitchLevel.groovy
SwitchLevel/SwitchLevels.groovy

index 7a5498053674d6192b89e391c005a221dc561273..43c71e99d058b1d8e94a4685403517c5e66f95d4 100644 (file)
@@ -16,7 +16,7 @@ public class ColorControls {
        private String displayName = "colorControl0"
        private String color = "red"
        private String currentColor = "red"
-       private String currentSwitch = "off"
+       private String currentSwitch = "on"
        private int level = 50
        private int currentLevel = 50
        private int hue = 50
@@ -31,16 +31,22 @@ public class ColorControls {
                this.deviceNumbers = deviceNumbers
                this.colorControls = []
 
-               def initHue = Verify.getIntFromList(30, 50)
+               /*def initHue = Verify.getIntFromList(30, 50)
                this.hue = initHue
                def initSat = Verify.getIntFromList(40, 50)
                this.saturation = initSat
-               def init = Verify.getInt(0,2)
-               if (init == 0) {
+               def initColor = Verify.getBoolean()
+               if (initColor) {
                        this.color = "red"
                } else {
                        this.color = "blue"
                }
+               def init = Verify.getBoolean()
+               if (init) {
+                       this.currentSwitch = "off"
+               } else {
+                       this.currentSwitch = "on"
+               }*/
 
                colorControls.add(new ColorControl(sendEvent, id, label, displayName, this.color, this.hue, this.saturation, this.level, this.currentSwitch, this.colorTemperature))
        }
index d73ed9bfb713114ca191af771bc024e0f33ee6cd..4956e0499c48139cbbee8e7ed8992009f4949c06 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) {
index a1e19dc44035280258505854e06a71a47fddfd5a..99fe7e6a22f752794f3da630ebac18d2e2c87c99 100644 (file)
@@ -14,7 +14,7 @@ public class ColorTemperatures {
        private String id = "colorTemperatureID0"
        private String label = "colorTemperature0"
        private String displayName = "colorTemperature0"
-       private String currentSwitch = "off"
+       private String currentSwitch = "on"
        private int level = 50
        private int currentLevel = 50
        private int colorTemperature = 15000
@@ -25,7 +25,7 @@ public class ColorTemperatures {
                this.deviceNumbers = deviceNumbers
                this.colorTemperatues = []
 
-               def initLevel = Verify.getIntFromList(50, 70)
+               /*def initLevel = Verify.getIntFromList(50, 70)
                this.level = initLevel 
                def initTemp = Verify.getIntFromList(10000, 15000)
                this.colorTemperature = initTemp 
@@ -34,7 +34,7 @@ public class ColorTemperatures {
                        this.currentSwitch = "off"
                } else {
                        this.currentSwitch = "on"
-               }
+               }*/
 
                colorTemperatues.add(new ColorTemperature(sendEvent, id, label, displayName, this.level, this.currentSwitch, this.colorTemperature))
        }
@@ -85,6 +85,14 @@ public class ColorTemperatures {
 
 
        //methods
+       def setLevel(long level) {
+               if (level != this.level) {
+                       this.currentLevel = level
+                       this.level = level
+                       colorTemperatues[0].setLevel(level)
+               }
+       }
+
        def setLevel(int level) {
                if (level != this.level) {
                        this.currentLevel = level
index e954203f163e6e9e7c2392ad1109d3849b17a16b..19e5016b1d078a1f853420fdabfb62ee80847ed5 100644 (file)
@@ -1555,7 +1555,7 @@ def input(LinkedHashMap metaData) {
                case "mode":
                        //def randomVariable = Math.abs(new Random().nextInt() % 3)
                        def modes = ["away", "home", "night"]
-                       def userInput = modes[0]
+                       def userInput = modes[1]
 
                        if (modeVariables == 0) {
                                mode0 = metaData['name']
index 5a2754042f05a585db006b4cf0326bcc38e457af..a13030a7d71a216344c9edb2fa50677d4189c5fd 100644 (file)
@@ -26,10 +26,10 @@ public class Switches {
                this.deviceNumbers = deviceNumbers
                this.switches = []
 
-               /*def initLevel = Verify.getIntFromList(30, 50, 70)
+               def initLevel = Verify.getIntFromList(30, 50, 70)
                this.currentLevel = initLevel
                def init = Verify.getBoolean()
-               if (init) {
+               /*if (init) {
                        this.switchState = "off"
                        this.currentSwitch = "off"
                        this.switchLatestValue = "off"
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") {
index 1bae6a1c30ccf519b1f7535cefafde160581c251..6ceaf8fb2b0ea51acb62b56a8510331928e0ee62 100644 (file)
@@ -17,9 +17,9 @@ public class SwitchLevels {
        private String displayName = "switchLevel0"
        private int level = 50
        private int rate = 50
-       private String switchState = "off"
-       private String currentSwitch = "off"
-       private String switchLatestValue = "off"
+       private String switchState = "on"
+       private String currentSwitch = "on"
+       private String switchLatestValue = "on"
 
        SwitchLevels(Closure sendEvent, int deviceNumbers) {
                this.sendEvent = sendEvent
@@ -70,6 +70,14 @@ public class SwitchLevels {
                        this.rate = level
                }
        }
+       
+       def setLevel(long level) {
+               if (this.level != level) {
+                       switchLevels[0].setLevel(level)
+                       this.level = level
+                       this.rate = level
+               }
+       }
 
        def on() {
                switchLatestValue = "on"