Update gentle-wake-up.groovy
[smartapps.git] / official / gentle-wake-up.groovy
index 139427e420c83552ca562fd6efad548c1858033e..c2b28fc6bfe16a40b86e36c06fc929e58fb3fc71 100755 (executable)
@@ -35,11 +35,11 @@ definition(
 
 preferences {
        page(name: "rootPage")
+       page(name: "numbersPage")
        page(name: "schedulingPage")
        page(name: "completionPage")
-       page(name: "numbersPage")
        page(name: "controllerExplanationPage")
-       page(name: "unsupportedDevicesPage")
+       //page(name: "unsupportedDevicesPage")
 }
 
 def rootPage() {
@@ -48,10 +48,10 @@ def rootPage() {
                section("What to dim") {
                        input(name: "dimmers", type: "capability.switchLevel", title: "Dimmers", description: null, multiple: true, required: true, submitOnChange: true)
                        if (dimmers) {
-                               if (dimmersContainUnsupportedDevices()) {
+                               /*if (dimmersContainUnsupportedDevices()) {
                                        href(name: "toUnsupportedDevicesPage", page: "unsupportedDevicesPage", title: "Some of your selected dimmers don't seem to be supported", description: "Tap here to fix it", required: true)
-                               }
-                               href(name: "toNumbersPage", page: "numbersPage", title: "Duration & Direction", description: numbersPageHrefDescription(), state: "complete")
+                               }*/
+                               href(name: "toNumbersPage", page: "numbersPage", title: "Duration & Direction", state: "complete")
                        }
                }
 
@@ -62,9 +62,9 @@ def rootPage() {
                        }
 
                        section("Rules For Dimming") {
-                               href(name: "toSchedulingPage", page: "schedulingPage", title: "Automation", description: schedulingHrefDescription() ?: "Set rules for when to start", state: schedulingHrefDescription() ? "complete" : "")
-                               input(name: "manualOverride", type: "enum", options: ["cancel": "Cancel dimming", "jumpTo": "Jump to the end"], title: "When one of the dimmers is manually turned off…", description: "dimming will continue", required: false, multiple: false)
-                               href(name: "toCompletionPage", title: "Completion Actions", page: "completionPage", state: completionHrefDescription() ? "complete" : "", description: completionHrefDescription() ?: "Set rules for what to do when dimming completes")
+                               href(name: "toSchedulingPage", page: "schedulingPage", title: "Automation")
+                               input(name: "manualOverride", type: "enum", options: ["Cancel dimming","Jump to the end"], title: "When one of the dimmers is manually turned off…", description: "dimming will continue", required: false, multiple: false)
+                               href(name: "toCompletionPage", title: "Completion Actions", page: "completionPage")
                        }
 
                        section {
@@ -86,9 +86,6 @@ def unsupportedDevicesPage() {
                                        paragraph deviceLabel(it)
                                }
                        }
-                       /*section {
-                               input(name: "dimmers", type: "capability.sensor", title: "Please remove the above devices from this list.", submitOnChange: true, multiple: true)
-                       }*/
                        section {
                                paragraph "If you think there is a mistake here, please contact support."
                        }
@@ -148,8 +145,8 @@ def numbersPage() {
                }
 
                section {
-                       input(name: "startLevel", type: "number", range: "0..99", title: "From this level", defaultValue: defaultStart(), description: "Current Level", required: false, multiple: false)
-                       input(name: "endLevel", type: "number", range: "0..99", title: "To this level", defaultValue: defaultEnd(), description: "Between 0 and 99", required: true, multiple: false)
+                       input(name: "startLevel", type: "number", range: "0..99", title: "From this level", description: "Current Level", required: false, multiple: false)
+                       input(name: "endLevel", type: "number", range: "0..99", title: "To this level", , description: "Between 0 and 99", required: true, multiple: false)
                }
 
                def colorDimmers = dimmersWithSetColorCommand()
@@ -295,13 +292,13 @@ private initialize() {
                subscribe(dimmers, "switch.off", stopDimmersHandler)
        }
 
-       if (!getAllChildDevices()) {
+       /*if (!getAllChildDevices()) {
                // create controller device and set name to the label used here
                def dni = "${new Date().getTime()}"
                log.debug "app.label: ${app.label}"
                addChildDevice("smartthings", "Gentle Wake Up Controller", dni, null, ["label": app.label])
                state.controllerDni = dni
-       }
+       }*/
 }
 
 def appHandler(evt) {
@@ -532,7 +529,7 @@ private increment() {
                def runAgain = stepDuration()
                log.debug "Rescheduling to run again in ${runAgain} seconds"
 
-               runIn(runAgain, 'increment', [overwrite: true])
+               //runIn(runAgain, 'increment', [overwrite: true])
 
        } else {
 
@@ -564,17 +561,14 @@ def updateDimmers(percentComplete) {
 
                        def shouldChangeColors = (colorize && colorize != "false")
 
-                       if (shouldChangeColors && hasSetColorCommand(dimmer)) {
+                       if (shouldChangeColors/*&& hasSetColorCommand(dimmer)*/) {
                                def hue = getHue(dimmer, nextLevel)
                                log.debug "Setting ${deviceLabel(dimmer)} level to ${nextLevel} and hue to ${hue}"
                                dimmer.setColor([hue: hue, saturation: 100, level: nextLevel])
-                       } else if (hasSetLevelCommand(dimmer)) {
+                       } else {
                                log.debug "Setting ${deviceLabel(dimmer)} level to ${nextLevel}"
                                dimmer.setLevel(nextLevel)
-                       } else {
-                               log.warn "${deviceLabel(dimmer)} does not have setColor or setLevel commands."
                        }
-
                }
        }
 
@@ -707,9 +701,9 @@ def canStartAutomatically() {
        def today = new Date().format("EEEE")
        log.debug "today: ${today}, days: ${days}"
 
-       if (!days || days.contains(today)) {// if no days, assume every day
+       //if (!days || days.contains(today)) {// if no days, assume every day
                return true
-       }
+       //}
 
        log.trace "should not run"
        return false
@@ -872,9 +866,9 @@ private hasCommand(device, String command) {
 private dimmersWithSetColorCommand() {
        def colorDimmers = []
        dimmers.each { dimmer ->
-               if (hasSetColorCommand(dimmer)) {
+               //if (hasSetColorCommand(dimmer)) {
                        colorDimmers << dimmer
-               }
+               //}
        }
        return colorDimmers
 }