Adding missing methods; setting default value to on.
[smartthings-infrastructure.git] / SwitchLevel / SwitchLevels.groovy
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"