Does anyone have sample code on converting the ColorMap chooser into a r,g,b,w code ?
Thats not possible, hue saturation and level can be converted to RGB and back.
The w channel has nothing to do with color.
We have some internal library's now for some of this, I'll add them to the docs in the morning.
There is also some conversion code posted in this forum somewhere. If you don’t find it then I’ll try and find a link tomorrow for you.
There’s this from Adam Kempenich
I had an issue with the equality tests that were designed to find the max values.. due to rounding IIRC
One way is to do HSV (HSL) to RGB (Hubitat tools pending), then use the min of R, G, B. Finally, allow you user to have a separate white level adjustment (like hue, saturation, and level). To go back, do the RGB to HSL conversion and use white as an independent variable. Saw the basics of this on in Stack Overflow.
I am getting an RGBW string tomorrow for my bleBox RGBW controller. I will play with this versus the native (blebox app) version and adjust accordingly.
Dave
Are you saying that it doesn't round to the whole number and still returns a decimal ?
Any status on this Mike ?
I'm not at home just at the moment but from memory at some point it compares two different numeric types and they differed in the 8th decimal place or thereabouts so I rounded them both to 2 decimal places which then always worked. I never quite understood why we aren't using integers but maybe it's because of the dual option for 255 | 100
The function doesn't return integers.
That's odd... I'm getting negative numbers
info [0, 40, -1]
Pretty sure I'm doing this right
To return the data.....
def setColor( parameters ){
rgbColors = hsvToRGB( parameters.hue, parameters.saturation, parameters.level )
byte[] data = [ rgbColors.red, rgbColors.green, rgbColors.blue ]
//sendCommand( data )
log.info "${data}"
}
Try logging parameters the same way you log rgbColors to make sure the sending method is passing what you expect to be passed. Remember the old expression garbage in/garbage out?
Didn't get it completed today.
Excellent suggestion !
[info] 0,-1,-17
[info] [red:0.0, green:255.0, blue:239.70001]
So how do I make whole numbers from that last line ? @djgutheinz or @Cobra
I got it !!
toIntege() and beyond !!
def setColor( parameters ){
rgbColors = hsvToRGB( parameters.hue, parameters.saturation, parameters.level )
red = rgbColors.red
green = rgbColors.green
blue = rgbColors.blue
r = red.toInteger()
g = green.toInteger()
b = blue.toInteger()
w = 0
log.info "Red:${r}, Green:${g}, Blue:${b}"
CustomRGBwColor(r,g,b,w)
}
r ...no
glad it's working
You're amazing.
Does this use java.awt.color, or is this something else? I'm pretty stoked to get it implemented...
Edit: Those 4 converters will be so useful, no more of my janky code that requires integers.
Edit 2: Since you named those classes the same as the ones I was using, implementing this is super easy.
Edit 3: 5 minutes of editing and I managed to get all of the drivers at our office updated ... I can't wait to roll this out.
Thanks Mike. As I received this notice, I had spent 1 minute starting the color conversion utilities.
Dave
yeah, it uses a couple of methods from that library.
Thanks Mike !! Now I have to change code again LOL
I wouldn't call it janky... it works with what we had at the time.