I thought the same thing but i am totally getting hung up for some reason…
This might help. Was trying not to give out a ton of the code because it technically isn’t mine i’m just trying to “enhance it” I’ll give ya a little more lol.
This is the preferences getting pulled:
location.modes?.each() {
def name = it as String
section("${name} Mode", hideable:true, hidden:false) {
name = name.tr(' !+', '___')
settings.hues?.each() {
input "${it.id}_${name}", "number", title: "${it.displayName} Level", required:false
input "${it.id}_${name}_color", "enum", title: "${it.displayName} Color?", required: false, multiple:false, metadata: [values:
["Normal", "Daylight", "Soft", "Warm", "Red", "Green", "Blue", "Yellow", "Orange", "Purple", "Pink"]]
}
settings.dimmers?.each() {
input "${it.id}_${name}", "number", title: "${it.displayName} Level", required:false
input "${it.id}_${name}_Off", "bool", title: "Turn ${it.displayName} off after setting level?", required: false, defaultValue: false
}
settings.switches?.each() {
input "${it.id}_${name}", "enum", title:it.displayName,
metadata:[values: ["on", "off"]], required:false
}
Below is how i action these. The problem i run into and maybe this is a simpler fix. Basically at the end of the logic below when it sets the dimmer levels i want it to also check for either a enum or bool value and then turn off specific dimmers at that time. For instance if(xyz input == Yes) then turn off the set of lights that match that. I’m having problems with that part.
TRACE("onLocation(${evt.value})")
state.currentMode = evt.value
String mode = state.currentMode
if (state.lastMode != state.currentMode) {
def allSwitches = []
if (settings.hues)
allSwitches.addAll(settings.hues)
if (settings.dimmers)
allSwitches.addAll(settings.dimmers)
if (settings.switches)
allSwitches.addAll(settings.switches)
def name = "${it.id}_${mode.tr(' !+', '___')}"
TRACE("name: ${name}")
def value = settings[name]
TRACE("value: ${value}")
if (value != null) {
if (value == 'on') {
TRACE("Turning '${it.displayName}' on")
it.on()
} else if (value == 'off') {
TRACE("Turning '${it.displayName}' off")
it.off()
} else {
value = value.toInteger()
if (value > 99) value = 98
TRACE("Setting '${it.displayName}' level to ${value}")
it.setLevel(value)
}