[Deprecated] - Lighting Effects

Hey, is there any way to be able to define more colors (hex code) or sequences/interpolation of colors in a certain range i.e. be able to transition between a range of different "Green" colors to get a shimmering effect of some sort?

Im looking for a way to be able to set a "scene" which makes it feel like halloween, or under water, or something like that with quasi-random effects within a certain range.

Sorry, LE won't do this unless you go in and edit the colors yourself. Easy enough to add as many colors as you want.

In addition to Switch can you add a Button do activate a Lighting Effect in the app without having to use a rule. I was thinking a Virtual Button on a dashboard with different buttons activating different Light Effects child apps.

Sorry, I hate buttons! :grin: To simulate a button, use a virtual switch with 'Enable Auto off'.

That's unfortunate, thanks anyways. I will use RM to randomize colors on repeat.

1 Like

Hello, I'm using this app with a Gledopto light strip connected to a Hue hub. I'm trying to use the slow changing color and it's set to a 10 minute interval. What I'm experiencing is that every 10 minutes, it just flips colors. I was expecting it to transition over the 10 minutes from one color to another. Is this the way it's supposed to behave?

Can't be done with this app or any app that I know of. Sorry.

I've added two scenes that existed on Philips hue. This is a modification to the Lighting effects child app. When you create a lighting effect, just pick all the color settings for Artic or Sunset.

image

/**

  • **************** Lighting Effects Child ****************
  • Design Usage:
    • Designed to make static holiday lights dim or flicker randomly.
    • Randomly change colors on color change bulbs, completely separate or all together.
    • Slowly dim a set of dimmable devices, great for night time routines.
    • Slowly raise a set of dimmable devices, great for morning routines.
    • Setup a loop to continually raise and lower dimmable devices.
    • Create a spooky, sparkly or party effect.
  • Copyright 2018-2020 @BPTWorld - Bryan Turcotte
  • This App is free. If you like and use this app, please be sure to mention it on the Hubitat forums! Thanks.
  • Remember...I am not a programmer, everything I do takes a lot of time and research!
  • Donations are never necessary but always appreciated. Donations to support development efforts are accepted via:
  • Paypal at: PayPal.Me
  • Unless noted in the code, ALL code contained within this app is mine. You are free to change, ripout, copy, modify or
  • otherwise use the code in anyway you want. This is a hobby, I'm more than happy to share what I have learned and help
  • the community grow. Have FUN with it!

*-------------------------------------------------------------------------------------------------------------------

  • 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:
  • Apache License, Version 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.

  • If modifying this project, please keep the above header intact and add your comments/credits below - Thank you! - @BPTWorld
  • App and Driver updates can be found at GitHub - bptworld/Hubitat: Apps for use with Hubitat Elevation

  • Changes:
  • 2.0.5 - 11/08/20 - Adjustments
  • 2.0.4 - 08/28/20 - Added App Control options
  • 2.0.3 - 08/16/20 - Added Light Level to Fast_Color_Changing & Slow_Color_Changing, other changes
  • 2.0.2 - 04/27/20 - Cosmetic changes
  • 2.0.1 - 04/12/20 - Major changes

  • 1.0.0 - 10/01/18 - Initial release. This is where it all started for me. By looking at other people work and piecing things
  • together. Learning by example! Next up was Googling everything I could find, reading, trying... reading more, trying again.
  • Before long, BPTWorld apps was born. Didn't know you were going to get a history lesson today, did you! lol.

*/

import groovy.time.TimeCategory
import java.text.SimpleDateFormat

def setVersion(){
state.name = "Lighting Effects"
state.version = "2.0.5"
}

definition(
name: "Lighting Effects Child",
namespace: "BPTWorld",
author: "Bryan Turcotte",
description: "Create a spooky, sparkly or party effect.",
category: "",
parent: "BPTWorld:Lighting Effects",
iconUrl: "",
iconX2Url: "",
iconX3Url: "",
importUrl: "https://raw.githubusercontent.com/bptworld/Hubitat/master/Apps/Lighting%20Effects/LE%20Child.groovy",
)

preferences {
page(name: "pageConfig")
}

def pageConfig() {
dynamicPage(name: "", title: "", install: true, uninstall: true) {
display()
section("Instructions:", hideable: true, hidden: true) {
paragraph "Lighting Effects is designed to work with Hue devices. While other brands may work, nothing is guaranteed. If not using Hue devices, you can try turning on 'Enable Hue in degrees (0-360)' for each device used with this app."
paragraph "Fast Dimming:"
paragraph "For each Child App, multiple devices can be selected. Each device will run sequential, Device 1, then Device 2, Back to device 1, then device 2..etc."
paragraph "To create a random effect, put each device in a separate Child App, using the same switch to turn them on."
paragraph "Fast Color Changing:"
paragraph "Designed for color changing bulbs. This section can control lights individually, or all together within the same child app. Used to change colors between 5 sec and 5 minutes."
paragraph "Slow Color Changing:"
paragraph "Designed for color changing bulbs. This section can control lights individually, or all together within the same child app. Used to change colors between 5 minutes and 3 hours."
paragraph "Slow Off, On and Loop:"
paragraph "Designed to slowly raise or lower any dimmable device. Great for morning or night routines. Also has the ability to setup a loop to continually raise and lower a dimmable device. Note: The dimming is not smooth but rather done in steps."
paragraph "Important:"
paragraph "Be sure to turn off 'Enable descriptionText logging' for each device. Can create a LOT of log entries!"
paragraph "Very Important:"
paragraph "Remember that the more devices you add and the faster you send commands, the more you're flooding the network. If you see 'normal' devices not responded as quickly or not at all, be sure to scale back the lighting effects."
}
section(getFormat("header-green", "${getImage("Blank")}"+" Setup")) {
input "triggerMode", "enum", title: "Select Lights Type", submitOnChange: true, options: ["Fast_Dimmer","Fast_Color_Changing","Slow_Color_Changing", "Slow_Off","Slow_On","Slow_Loop"], required: true, multiple: false
paragraph "Note: When changing Light Type, all selections will be deleted."

        if(state.previousTrigger == null) state.previousTrigger = triggerMode
        log.warn "previousTrigger: ${state.previousTrigger} - triggerMode: ${triggerMode}"
        if(state.previousTrigger == triggerMode) {
            // all good
        } else {
            app.removeSetting("dimmers")
            app.removeSetting("sleepytime")
            
            app.removeSetting("lights")
            app.removeSetting("sleepytime2")
            app.removeSetting("sleepPattern")
            app.removeSetting("seperate")
            app.removeSetting("pattern")
            app.removeSetting("colorSelection")
            app.removeSetting("lightLevel")
            
            app.removeSetting("minutes")
            app.removeSetting("targetLevelLow")
            app.removeSetting("targetLevelHigh")
            
            state.previousTrigger = triggerMode
        } 
    }
    
    if(triggerMode == "Fast_Dimmer"){
  	section(getFormat("header-green", "${getImage("Blank")}"+" Used to change colors between 5 sec and 5 minutes")) {
  		input "dimmers", "capability.switchLevel", title: "Select Dimmable Lights", required: false, multiple: true
  		input "sleepytime", "number", title: "Enter the delay between actions - Big number = Slow, Small number = Fast" , required: true, defaultValue: 6000
    	}
    }
    
   	if(triggerMode == "Fast_Color_Changing"){
        section(getFormat("header-green", "${getImage("Blank")}"+" Select your options")) {
    		input "lights", "capability.colorControl", title: "Select Color Changing Bulbs", required: false, multiple:true
        	input "sleepytime2", "number", title: "Enter the delay between actions in seconds (range 5 to 300)" , required: true, defaultValue: 300, range: '5..300'
  		input "sleepPattern", "enum", title: "Delay constant or random", defaultValue: "constant", options: ["constant","random"], required: true, multiple: false
  		input "seperate", "enum", title: "Cycle each light individually or all together", defaultValue: "individual", options: ["individual","combined"], required: true, multiple: false
            input "pattern", "enum", title: "Cycle or Randomize each color", defaultValue: "randomize", options: ["randomize","cycle"], required: true, multiple: false
            input "colorSelection", "enum", title: "Choose your colors", options: [
                    ["Soft White":"Soft White - Default"],
                    ["White":"White - Concentrate"],
                    ["Daylight":"Daylight - Energize"],
                    ["Warm White":"Warm White - Relax"],
                    "Red","Green","Blue","Yellow","Orange","Purple","Pink", "Artic1", "Artic2", "Artic3", "Sunset1", "Sunset2", "Sunset3", "Sunset4"
                ], required: true, multiple: true
            input "lightLevel", "number", title: "Lighting Level (1 to 99)", required: true, multiple: false, defaultValue: 99, range: '1..99'
        }
  }
    
  if(triggerMode == "Slow_Color_Changing"){
  	section(getFormat("header-green", "${getImage("Blank")}"+" Used to change colors between 5 minutes and 3 hours")) {
    		input "lights", "capability.colorControl", title: "Select Color Changing Bulbs", required: false, multiple:true
        	input "sleepytime2", "number", title: "Enter the delay between actions in minutes (range 5 to 180)" , required: true, defaultValue: 60, range: '5..180'
    		input "seperate", "enum", title: "Cycle each light individually or all together", defaultValue: "individual", options: ["individual","combined"], required: true, multiple: false
            input "pattern", "enum", title: "Cycle or Randomize each color", defaultValue: "randomize", options: ["randomize","cycle"], required: true, multiple: false
  		input "colorSelection", "enum", title: "Choose your colors", options: [
                    ["Soft White":"Soft White - Default"],
                    ["White":"White - Concentrate"],
                    ["Daylight":"Daylight - Energize"],
                    ["Warm White":"Warm White - Relax"],
                    "Red","Green","Blue","Yellow","Orange","Purple","Pink", "Artic1", "Artic2", "Artic3", "Sunset1", "Sunset2", "Sunset3", "Sunset4"
                ], required: true, multiple: true
            input "lightLevel", "number", title: "Lighting Level (1 to 99)", required: true, multiple: false, defaultValue: 99, range: '1..99'
  	}
  }
    
	if(triggerMode == "Slow_On"){
  	section(getFormat("header-green", "${getImage("Blank")}"+" Select your options")) {
        	input "dimmers", "capability.switchLevel", title: "Select dimmer devices to slowly raise", required: true, multiple: true
			input "minutes", "number", title: "Takes how many minutes to raise (1 to 60)", required: true, multiple: false, defaultValue:5, range: '1..60'
			input "targetLevelHigh", "number", title: "Target Level (1 to 99)", required: true, multiple: false, defaultValue: 99, range: '1..99'
  		state.tMode = "Slow_On"
  	}
  	}
    
	if(triggerMode == "Slow_Off"){
		section(getFormat("header-green", "${getImage("Blank")}"+" Select your options")) {
        	input "dimmers", "capability.switchLevel", title: "Select dimmer devices to slowly dim", required: true, multiple: true
			input "minutes", "number", title: "Takes how many minutes to dim (1 to 60)", required: true, multiple: false, defaultValue:5, range: '1..60'
			input "targetLevelLow", "number", title: "Target Level (1 to 99)", required: true, multiple: false, defaultValue: 1, range: '1..99'
  		state.tMode = "Slow_Off"
    	}
  	}
    
	if(triggerMode == "Slow_Loop"){
		section(getFormat("header-green", "${getImage("Blank")}"+" Select your options")) {
    		input "dimmers", "capability.switchLevel", title: "Select dimmer devices to slowly dim", required: true, multiple: true
			input "minutes", "number", title: "Takes how many minutes per dim or raise (1 to 60)", required: true, multiple: false, defaultValue:5, range: '1..60'
			input "targetLevelHigh", "number", title: "Target Level - High(1 to 99)", required: true, multiple: false, defaultValue: 99, range: '1..99'
        	input "targetLevelLow", "number", title: "Target Level - Low(1 to 99)", required: true, multiple: false, defaultValue: 1, range: '1..99'
        	state.tMode = "Slow_Loop"
   		}      
  }
    
  section(getFormat("header-green", "${getImage("Blank")}"+" Activate the Dimming/Color Changing when this switch is on")) {
  	input "switches", "capability.switch", title: "Switch", required: true, multiple: false
  } 
    
    section(getFormat("header-green", "${getImage("Blank")}"+" App Control")) {
        input "pauseApp", "bool", title: "Pause App", defaultValue:false, submitOnChange:true            
        if(pauseApp) {
            if(app.label) {
                if(!app.label.contains(" (Paused)")) {
                    app.updateLabel(app.label + " (Paused)")
                }
            }
        } else {
            if(app.label) {
                app.updateLabel(app.label - " (Paused)")
            }
        }
        paragraph "This app can be enabled/disabled by using a switch. The switch can also be used to enable/disable several apps at the same time."
        input "disableSwitch", "capability.switch", title: "Switch Device(s) to Enable / Disable this app", submitOnChange:true, required:false, multiple:true
    }
    
  section(getFormat("header-green", "${getImage("Blank")}"+" General")) {
        label title: "Enter a name for this automation", required: false
        input "logEnable", "bool", defaultValue: false, title: "Enable Debug Logging", description: "debugging", submitOnChange:true
  }
  display2()

}
}

def installed() {
log.debug "Installed with settings: ${settings}"
initialize()
}

def updated() {
if(logEnable) log.debug "Updated with settings: ${settings}"
unsubscribe()
unschedule()
if(logEnable) runIn(3600, logsOff)
initialize()
}

def initialize() {
checkEnableHandler()
if(pauseApp || state.eSwitch) {
log.info "${app.label} is Paused or Disabled"
} else {
if(triggerMode == "Fast_Dimmer"){subscribe(switches, "switch", fastDimmerHandler)}
if(triggerMode == "Fast_Color_Changing"){
subscribe(switches, "switch", changeHandler)
state.colorOffset=0
}
if(triggerMode == "Slow_Color_Changing"){
subscribe(switches, "switch", slowChangeHandler)
state.colorOffset=0
}
if(triggerMode == "Slow_On"){subscribe(switches, "switch", slowonHandler)}
if(triggerMode == "Slow_Off"){subscribe(switches, "switch", slowoffHandler)}
if(triggerMode == "Slow_Loop"){subscribe(switches, "switch", slowonHandler)}
}
}

def fastDimmerHandler(evt) {
checkEnableHandler()
if(pauseApp || state.eSwitch) {
log.info "${app.label} is Paused or Disabled"
} else {
if(logEnable) log.debug "In fastDimmerHandler (${state.version})"
if(switches.currentValue("switch") == "on") {
if(triggerMode == "Dimmer") {
for (dimmer in dimmers) {
def lowLevel= Math.abs(new Random().nextInt() % 20) + 30
dimmer.setLevel(lowLevel)

                sTime = Math.abs(new Random().nextInt() % sleepytime)
                pauseExecution(sTime)

                def upLevel= Math.abs(new Random().nextInt() % 75) + 24
                dimmer.setLevel(upLevel)

                sTime = Math.abs(new Random().nextInt() % sleepytime)
                pauseExecution(sTime)
            }
        }
        runIn(10, fastDimmerHandler)
    } else if(switches.currentValue("switch") == "off") {
        dimmers.off()
        unschedule()
    }
}

}

def changeHandler(evt) { // Modified code from ST - Kristopher Kubicki
checkEnableHandler()
if(pauseApp || state.eSwitch) {
log.info "${app.label} is Paused or Disabled"
} else {
if(logEnable) log.debug "In changeHandler (${state.version})"
if(switches.currentValue("switch") == "on") {
if(logEnable) log.debug "In changeHandler - Color Selection = ${colorSelection}"
lights.on()
if(logEnable) log.debug " - - - - - - - - - - In changeHandler - triggerMode = ${triggerMode}"
if(triggerMode == "Fast_Color_Changing"){
for (numberoflights in lights) {
if(logEnable) log.debug " - - - - - - - - - - sleepPattern = ${sleepPattern}"
if(sleepPattern == "random"){
slTime = Math.abs(new Random().nextInt() % sleepytime2)
if(logEnable) log.debug " - - - - - - - - - - In random - slTime: ${slTime}"
} else{
slTime = sleepytime2
if(logEnable) log.debug " - - - - - - - - - - In constant - slTime: ${slTime}"
}
def colors =
colors = colorSelection
if(logEnable) log.debug "In changeHandler - Colors: ${colors}"

                def offLights = lights.findAll { light -> light.currentSwitch == "off" }
                if(logEnable) log.debug "In changeHandler - offLights: ${offLights}"

                def onLights = lights.findAll { light -> light.currentSwitch == "on" }
                if(logEnable) log.debug "In changeHandler - onLights: ${onLights}"
                def numberon = onLights.size()
                def numcolors = colors.size()

                if(logEnable) log.debug "In changeHandler - pattern = ${pattern}"
                if (pattern == 'randomize') {
                    randOffset = Math.abs(new Random().nextInt()%numcolors)
                    if(logEnable) log.debug "In changeHandler - Pattern: ${pattern} - Offset: ${randOffset}"
                    if (seperate == 'combined') {
                        sendcolor(onLights,colors[randOffset])
                    } else {
                        for(def i=0;i<numberon;i++) {
                            sendcolor(onLights[i],colors[(randOffset + i) % numcolors])
                        }
                    }
                } else if (pattern == 'cycle') {
                    if (onLights.size() > 0) {
                        if (state.colorOffset >= numcolors) {
                            state.colorOffset = 0
                        }
                        if (seperate == 'combined') {
                            sendcolor(onLights,colors[state.colorOffset])
                            if(logEnable) log.debug "In changeHandler - cycle-combined - onLighgts: ${onLights}, Colors: ${colors[state.colorOffset]}"
                        } else {
                            for(def i=0;i<numberon;i++) {
                                sendcolor(onLights[i],colors[(state.colorOffset + i) % numcolors])
                                if(logEnable) log.debug "In changeHandler - cycle-randomize - onLighgts: ${onLights[i]}, Colors: ${colors[(state.colorOffset + i) % numcolors]}"
                            }
                        }
                        state.colorOffset = state.colorOffset + 1
                    }
                }
            }
        }
        if(logEnable) log.debug "In changeHandler - slTime: ${slTime}"
        runIn(slTime, changeHandler)
    } else if(switches.currentValue("switch") == "off") {
        lights.off()
        unschedule()
    }
}

}

def slowChangeHandler(evt) { // Modified code from ST - Kristopher Kubicki
checkEnableHandler()
if(pauseApp || state.eSwitch) {
log.info "${app.label} is Paused or Disabled"
} else {
if(logEnable) log.debug "In slowChangeHandler (${state.version})"
if(switches.currentValue("switch") == "on") {
if(logEnable) log.debug "In slowChangeHandler - Color Selection: ${colorSelection}"
lights.on()
if(triggerMode == "Slow_Color_Changing"){
for (numberoflights in lights) {
slpTime = (sleepytime2*60)
def colors =
colors = colorSelection
if(logEnable) log.debug "In slowChangeHandler - Colors: ${colors}"

                def offLights = lights.findAll { light -> light.currentSwitch == "off"}
                if(logEnable) log.debug "In slowChangeHandler - offLights: ${offLights}"

                def onLights = lights.findAll { light -> light.currentSwitch == "on"}
                if(logEnable) log.debug "In slowChangeHandler - onLights: ${onLights}"
                def numberon = onLights.size()
                def numcolors = colors.size()

                if(logEnable) log.debug "In slowChangeHandler - pattern: ${pattern}"
                if (pattern == 'randomize') {
                    randOffset = Math.abs(new Random().nextInt()%numcolors)
                    if(logEnable) log.debug "In slowChangeHandler - Pattern: ${pattern} - Offset: ${randOffset}"
                    if (seperate == 'combined') {
                        sendcolor(onLights,colors[randOffset])
                    } else {
                        for(def i=0;i<numberon;i++) {
                            sendcolor(onLights[i],colors[(randOffset + i) % numcolors])
                        }
                    }
                } else if (pattern == 'cycle') {
                    if (onLights.size() > 0) {
                        if (state.colorOffset >= numcolors ) {
                            state.colorOffset = 0
                        }
                        if (seperate == 'combined') {
                            sendcolor(onLights,colors[state.colorOffset])
                            if(logEnable) log.debug "In slowChangeHandler - cycle-combined - onLighgts: ${onLights}, Colors: ${colors[state.colorOffset]}"
                        } else {
                            for(def i=0;i<numberon;i++) {
                                sendcolor(onLights[i],colors[(state.colorOffset + i) % numcolors])
                                if(logEnable) log.debug "In slowChangeHandler - cycle-randomize - onLighgts: ${onLights[i]}, Colors: ${colors[(state.colorOffset + i) % numcolors]}"
                            }
                        }
                        state.colorOffset = state.colorOffset + 1
                    }
                }
            }
        }
        if(logEnable) log.debug "In slowChangeHandler - slpTime: ${slpTime}"
        runIn(slpTime, slowChangeHandler)
    } else if(switches.currentValue("switch") == "off"){
        lights.off()
        unschedule()
    }
}

}

def slowonHandler(evt) { // Modified code from @Bravenel
checkEnableHandler()
if(pauseApp || state.eSwitch) {
log.info "${app.label} is Paused or Disabled"
} else {
if(logEnable) log.debug "In slowonHandler (${state.version})"
if(dimmers[0].currentSwitch == "off") {
dimmers.setLevel(0)
state.currentLevel = 0
} else{
state.currentLevel = dimmers[0].currentLevel
}
if(minutes == 0) return
seconds = minutes * 6
state.dimStep = targetLevelHigh / seconds
state.dimLevel = state.currentLevel
if(logEnable) log.debug "In slowonHandler - tMode: ${state.tMode} - Current Level: ${state.currentLevel} - dimStep: ${state.dimStep} - targetLevel: ${targetLevelHigh}"
dimStepUp()
}
}

def dimStepUp() { // Modified code from @Bravenel
checkEnableHandler()
if(pauseApp || state.eSwitch) {
log.info "${app.label} is Paused or Disabled"
} else {
if(logEnable) log.debug "In dimStepUp (${state.version})"
if(switches.currentValue("switch") == "on") {
if(state.currentLevel < targetLevelHigh) {
state.dimLevel = state.dimLevel + state.dimStep
if(state.dimLevel > targetLevelHigh) {state.dimLevel = targetLevelHigh}
state.currentLevel = state.dimLevel.toInteger()
dimmers.setLevel(state.currentLevel)
if(logEnable) log.debug "dimStepUp - tMode: ${state.tMode} - Current Level: ${state.currentLevel} - dimStep: ${state.dimStep} - targetLevel: ${targetLevelHigh}"
runIn(10,dimStepUp)
} else{
if(logEnable) log.debug "dimStepUp - tMode = ${state.tMode}"
if(state.tMode == "Slow_Loop") {
runIn(1,slowoffHandler)
} else{
switches.off()
if(logEnable) log.debug "dimStepUp - tMode: ${state.tMode} - Current Level: ${state.currentLevel} - targetLevel: ${targetLevelHigh} - Target Level Reached"
}
}
} else{
if(logEnable) log.debug "Current Level: ${state.currentLevel} - Control Switch turned Off"
}
}
}

def slowoffHandler(evt) { // Modified code from @Bravenel
checkEnableHandler()
if(pauseApp || state.eSwitch) {
log.info "${app.label} is Paused or Disabled"
} else {
if(logEnable) log.debug "In slowoffHandler (${state.version})"
if(dimmers[0].currentSwitch == "off") {
dimmers.setLevel(99)
state.currentLevel = 99
} else{
state.currentLevel = dimmers[0].currentLevel
}
if(minutes == 0) return
seconds = minutes * 6
state.dimStep1 = (targetLevelLow / seconds) * 100
state.dimLevel = state.currentLevel
if(logEnable) log.debug "In slowoffHandler - tMode: ${state.tMode} - Current Level: ${state.currentLevel} - dimStep: ${state.dimStep} - targetLevel: ${targetLevelLow}"
dimStepDown()
}
}

def dimStepDown() { // Modified code from @Bravenel
checkEnableHandler()
if(pauseApp || state.eSwitch) {
log.info "${app.label} is Paused or Disabled"
} else {
if(logEnable) log.debug "In dimStepDown (${state.version})"
if(switches.currentValue("switch") == "on") {
if(state.currentLevel > targetLevelLow) {
state.dimStep = state.dimStep1
state.dimLevel = state.dimLevel - state.dimStep
if(state.dimLevel < targetLevelLow) {state.dimLevel = targetLevelLow}
state.currentLevel = state.dimLevel.toInteger()
dimmers.setLevel(state.currentLevel)
if(logEnable) log.debug "In dimStepDown - tMode: ${state.tMode} - Current Level: ${state.currentLevel} - dimStep: ${state.dimStep} - targetLevel: ${targetLevelLow}"
runIn(10,dimStepDown)
} else{
if(logEnable) log.debug "In dimStepDown - tMode = ${state.tMode}"
if(state.tMode == "Slow_Loop") {
runIn(1,slowonHandler)
} else {
switches.off()
if(logEnable) log.debug "In dimStepDown - tMode: ${state.tMode} - Current Level: ${state.currentLevel} - targetLevel: ${targetLevelLow} - Target Level Reached"
}
}
} else{
if(logEnable) log.debug "Current Level: ${state.currentLevel} - Control Switch turned Off"
}
}
}

def sendcolor(lights,color) {
if(logEnable) log.debug "In sendcolor (${state.version})"
def hueColor = 0
def saturation = 100
if(lightLevel) onLevel = lightLevel
switch(color) {
case "White":
hueColor = 52
saturation = 19
break;
case "Daylight":
hueColor = 53
saturation = 91
break;
case "Soft White":
hueColor = 23
saturation = 56
break;
case "Warm White":
hueColor = 20
saturation = 80
break;
case "Blue":
hueColor = 70
break;
case "Green":
hueColor = 39
break;
case "Yellow":
hueColor = 25
break;
case "Orange":
hueColor = 10
break;
case "Purple":
hueColor = 75
break;
case "Pink":
hueColor = 83
break;
case "Red":
hueColor = 100
break;
case "Artic1":
hueColor = 48
saturation = 100
break;
case "Artic2":
hueColor = 58
saturation = 100
break;
case "Artic3":
hueColor = 77
saturation = 70
break;
case "Sunset1":
hueColor = 9
saturation = 80
break;
case "Sunset2":
hueColor = 95
saturation = 76
break;
case "Sunset3":
hueColor = 77
saturation = 66
break;
case "Sunset4":
hueColor = 10
saturation = 76
break;
}
def value = [switch: "on", hue: hueColor, saturation: saturation, level: onLevel as Integer ?: 100]
lights*.setColor(value)
if(logEnable) log.debug "In sendcolor - Setting lights: ${lights} - value: ${value}"
}

// ********** Normal Stuff **********

def logsOff() {
log.info "${app.label} - Debug logging auto disabled"
app?.updateSetting("logEnable",[value:"false",type:"bool"])
}

def checkEnableHandler() {
state.eSwitch = false
if(disableSwitch) {
if(logEnable) log.debug "In checkEnableHandler - disableSwitch: ${disableSwitch}"
disableSwitch.each { it ->
eSwitch = it.currentValue("switch")
if(eSwitch == "on") { state.eSwitch = true }
}
}
}

def setDefaults(){
if(logEnable) log.debug "Initialising defaults..."
if(logEnable == null){logEnable = false}
}

def getImage(type) { // Modified from @Stephack Code
def loc = "<img src=https://raw.githubusercontent.com/bptworld/Hubitat/master/:/images/"
if(type == "Blank") return "${loc}blank.png height=40 width=5}>"
if(type == "checkMarkGreen") return "${loc}checkMarkGreen2.png height=30 width=30>"
if(type == "optionsGreen") return "${loc}options-green.png height=30 width=30>"
if(type == "optionsRed") return "${loc}options-red.png height=30 width=30>"
if(type == "instructions") return "${loc}instructions.png height=30 width=30>"
if(type == "logo") return "${loc}logo.png height=60>"
}

def getFormat(type, myText="") { // Modified from @Stephack Code
if(type == "header-green") return "

${myText}
"
if(type == "line") return "
"
if(type == "title") return "

${myText}

"
}

def display() {
setVersion()
getHeaderAndFooter()
theName = app.label
if(theName == null || theName == "") theName = "New Child App"
section (getFormat("title", "${getImage("logo")}" + " ${state.name} - ${theName}")) {
paragraph "${state.headerMessage}"
paragraph getFormat("line")
}
}

def display2() {
section() {
paragraph getFormat("line")
paragraph "

${state.name} - ${state.version}
"
paragraph "${state.footerMessage}"
}
}

def getHeaderAndFooter() {
timeSinceNewHeaders()
if(state.totalHours > 4) {
if(logEnable) log.debug "In getHeaderAndFooter (${state.version})"
def params = [
uri: "https://raw.githubusercontent.com/bptworld/Hubitat/master/info.json",
requestContentType: "application/json",
contentType: "application/json",
timeout: 30
]

    try {
        def result = null
        httpGet(params) { resp ->
            state.headerMessage = resp.data.headerMessage
            state.footerMessage = resp.data.footerMessage
        }
    }
    catch (e) { }
}
if(state.headerMessage == null) state.headerMessage = "<div style='color:#1A77C9'><a href='https://github.com/bptworld/Hubitat' target='_blank'>BPTWorld Apps and Drivers</a></div>"
if(state.footerMessage == null) state.footerMessage = "<div style='color:#1A77C9;text-align:center'>BPTWorld Apps and Drivers<br><a href='https://github.com/bptworld/Hubitat' target='_blank'>Donations are never necessary but always appreciated!</a><br><a href='https://paypal.me/bptworld' target='_blank'><b>Paypal</b></a></div>"

}

def timeSinceNewHeaders() {
if(state.previous == null) {
prev = new Date()
} else {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ")
prev = dateFormat.parse("${state.previous}".replace("+00:00","+0000"))
}
def now = new Date()
use(TimeCategory) {
state.dur = now - prev
state.days = state.dur.days
state.hours = state.dur.hours
state.totalHours = (state.days * 24) + state.hours
}
state.previous = now
//if(logEnable) log.warn "In checkHoursSince - totalHours: ${state.totalHours}"
}

I just installed hoping to cycle through Red, White & Blue in that order. I updated the app to list the colors in that order. I'm confused, however, about the "Switch devices to enable/disable this app". The device is named Front Spots. I have all 3 device entries set to Front Spots. Is that right? I'm just testing now and then want to add a rule to turn them on at sunset.

What I did is create a virtual switch called 4th Holiday. When it turns on, this app runs. When I turn the virtual switch off, this app stops.

The switch you refer to as "switch devices to enable/disable this app." think of it as an override switch. For example (and I haven't tried it yet) is that I want my front porch light to cycle between red, white and blue. My porch light is tied to a motion detector, so when it senses motion, I turn on a virtual switch that disables this app, turns my porch light to white so the pathway is lit up and then a few minutes later, turn off this virtual switch and the red white and blue starts again. @bptworld (as do others) put these types of things in their apps.

Hope this helps!

Scott

1 Like

Thanks! I figured it out and updated the code the HSL values I wanted.

I setup a virtual switch that starts a color loop when on and stops when off. (This is not the enable/disable app switch). However, when the virtual switch turns off, the app turns the lights completely off. I'd like them to stay on whatever color/level they are at currently. Is there a way to set that up?

Why can't I find the 'Enable Hue in degrees (0-360)' option anywhere?!?

That is an option that used to be in certain color bulbs device page. I think I remember that it has been since removed from all device drivers.

hello all! i have this setup to make my sylvania light bulbs change color during this christmas holidays. For some reason its not working as i expected so i would like to know what is it that im doing wrong. thanks


It's been a long time since I looked at this code but I don't think the Activating Switch can be the same as the switch that's doing the color changing. You'll need to setup a virtual switch to control the bulb, and select it instead.

1 Like

ok i changed the activating switch to another one that also turns on at the same time, and ill see how it goes

it worked now. thanks

1 Like

Create a virtual switch.You can make a virtual switch ( I have one called HL ) ( for Holiday Lights ) set HL as your activation switch. Then HL can have a dashboard button or can be driven by EE or RM for scheduled or conditional activation.

With your Sylvania lights, which device type did you use for Entrance Light? I have a Sylvania set of l ights set as Generic Zigbee RGB (to be able to get the 0-360 hue setting enabled), but the colors are way off - the colors stay around red/orange/yellow/green, but no blues/purples/pinks, etc.

EDIT: After enabling the 0-360 hue setting to get the lights to change color w/ the lighting effects app, I turned the setting off and toggled my activation switch - now the lights accurately represent the colors I chose and change colors w/ the app successfully!