@mike.maxwell entering a value in a color_map input then using that input in setColor does not seem to set the color.
input "x", "color_map", title: "color map?"
...
setColor(x)
entered [hue:5, saturation:100, level:100]
for x.
what am i missing?
thank you.
There is no input type of color map.
ahh … ok. what is this color_map
for the generic zigbee rgbw light driver?
I just knew if I didn't check you would prove me wrong....
So what's the value of x when you log it?
someones got to you keep you on your toes
[app:709] 2018-10-16 18:56:55.948:debug [hue:55, saturation:100, level:100]
i understand what you entered, I'm asking what this produces:
log.debug "input x:${x}"
if its a string (not a map) then log.debug "input hue:${x.hue}" will return null, in which case you can build the string back into a map with something like:
def cMap = stringToMap(x)
that was from the log which shows the same as what i entered.
will try stringToMap(…)
I use this in my Lifx driver. It returns a map for me...but I do have to convert the "numbers" to integers.
def setColor(value) {
log("Begin setting groups color to ${value}.", "DEBUG")
def hue = value.hue.toInteger() * 3.6
def sat = value.saturation.toInteger() / 100
def level = value.level.toInteger()
if(level) setLevel(level)
sendLIFXCommand([color: "saturation:${sat} hue:${hue}"])
sendEvent(name: "hue", value: value.hue, displayed: getUseActivityLogDebug())
sendEvent(name: "saturation", value: value.saturation, displayed: getUseActivityLogDebug())
sendEvent(name: "color", value: value.hex, displayed: getUseActivityLogDebug())
sendEvent(name: "switch", value: "on", displayed: getUseActivityLogDebug())
sendEvent(name: "level", value: "${state.level}", displayed: getUseActivityLogDebug())
}
he's having an issue capturing a map from a app input of type "color_map"
bangali
October 17, 2018, 5:45pm
10
stringToMap throws an exception … didnt save the log.
so constructed map assuming the input is string but setColor still does not work nor does it throw an error.
bangali
October 17, 2018, 6:02pm
11
funny part is this never matches:
if (m instanceof Map) log.debug m;
def x = [hue:55, saturation:100, level:100]
log.debug x
if (m == x) log.debug "matched"
[app:709] 2018-10-17 11:00:35.367:debug[hue:55, saturation:100, level:100]
[app:709] 2018-10-17 11:00:35.366:debug[hue:55, saturation:100, level:100]
never logs matched
Maybe
def cMap = evaluate(x)
1 Like
bangali
October 17, 2018, 6:31pm
13
evaluate(userInput) seems to return a map from the user input map string which then works for setColor.
still seems funky why building the map from the string would not work.
f'groovy
with love … that needs to be read as freaking groovy