Slow Raiser (for Aquariums)

smartapp_lighting
project_pets

(Bruce) #1

Here is a small app that slowly raises the level of a dimmer, possible over an extended period of time, to a target level.

/**
 *  Slow Raiser
 *
 *  Copyright 2015 Bruce Ravenel
 *
 *  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 *  in compliance with the License. You may obtain a copy of the License at:
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
 *  on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
 *  for the specific language governing permissions and limitations under the License.
 *
 */
definition(
    name: "Slow Raiser",
    namespace: "bravenel",
    author: "Bruce Ravenel",
    description: "Slowly raise dim level",
    category: "My Apps",
    iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
    iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png",
    iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png")


preferences {
    section("Select dimmers to slowly raise...") {
	input "dimmers", "capability.switchLevel", title: "Which?", required: true, multiple: true
    }

    section("Over how many minutes to raise...") {
    	input "minutes", "number", title: "Minutes?", required: true, multiple: false
    }
    
    section("To what dimmer level...") {
    	input "targetLevel", "number", defaultValue: 99, multiple: false, required: true
    }

    section("Select momentary button to launch...") {
    	input "trigger", "capability.momentary", title: "Which?", required: true
    }
}

def installed() {
    initialize()
}

def updated() {
    unsubscribe()
    initialize()
}

def initialize() {
    subscribe(trigger, "switch.on", triggerHandler)
}

def triggerHandler(evt) {
    if(dimmers[0].currentSwitch == "off") state.currentLevel = 0
    else state.currentLevel = dimmers[0].currentLevel
    if(minutes == 0) return
    state.dimStep = targetLevel / minutes
    state.dimLevel = state.currentLevel
    dimStep()
}

def dimStep() {
    if(state.currentLevel < targetLevel) {
        state.dimLevel = state.dimLevel + state.dimStep
        state.currentLevel = state.dimLevel.toInteger()
    	dimmers.setLevel(state.currentLevel)
        runIn(60,dimStep)
    }
}

Dimming Slowly... every 5 minutes
Rule machine - as per the app developer, this app is no longer available for new installs, distribution, or support
(Bruce) #2

There was a typo, now fixed in this code. Re copy it if you haven’t found the typo already.


(Tim Slagle) #3

Hate when that happens :frowning:


(Bruce) #4

Ya, it’s embarrassing!

Like you guys should be about:
No lock notifications or SHM support for Locks – very basic
Smart Lights blowing motion-off events
"Power Allowance" as a name for "Turn off after some minutes"
Smart Lights not having stand-alone “Turn off after motion stops”


(James K) #5

Is there a way to use Rule Machine to kick this off at a specific time? Also, do you have a reverse of this app (start high dim down)?

Or maybe I should just ask has this been baked into RM and I missed it?


(Mark) #6

Not sure about making Rule Machine do this but there is a Slow dimmer here:


#7

I’ve set this up to raise the level over an hour. But I’d like to cancel the slow Raise if the dimmer switch is manually adjusted. Any idea how to do that? Thanks!