Closed sjorge closed 3 years ago
Looks like utils.gammaCorrectHSV()
is what is causing it, if I skip this step for the RB 250 C the colors look very close to there RGB values when set via XY, with that call colors seems slightly off.
Edit: multiplying by 2.55 instead of 2.54 (with gammaCorrectHSV still) yields even closer results for hue+sat vs xy.
ZCL seems to hint that 2.54 is indeed correct here...
0x0001 CurrentSaturation uint8 0x00 – 0xfe RPS 0x00 M0
Changing https://github.com/Koenkk/zigbee-herdsman-converters/blob/c9ed6bb75a9682cf60b41e4e7647c653480f9a6c/converters/toZigbee.js#L735 to value.saturation = Math.min(255, hsv.s * (2.54));
should fix the error
The issue seems to be the reverse, it’s never 254 so all colors, at least on the RB 250 C, and most notably red, seem to be off visually.
When using hue/sat.
~ sjorge
On 3 Jan 2021, at 20:39, Koen Kanters notifications@github.com wrote:
Changing https://github.com/Koenkk/zigbee-herdsman-converters/blob/c9ed6bb75a9682cf60b41e4e7647c653480f9a6c/converters/toZigbee.js#L735 to value.saturation = Math.min(255, hsv.s * (2.54)); should fix the error
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.
I mean it fixes: RangeError [ERR_OUT_OF_RANGE]: The value of "value" is out of range. It must be >= 0 and <= 255. Received 255.99136000000001
Oh like that, yeah but thats because I was setting it > 100... because I noticed when I use 100 the value was not set to the max range ZCL defined... hence trying 101, 102,... until 108 throws the out of range.
101->107 work... which is because after passing through gammaCorrectHSV... the value is lower.
107 seems to be 254 (which is the max, not 255 btw)... so I'm wondering if we need the util.gammaCorrectHSV when using hue/sat... as without it the colors more close match what they should be.
e.g. hue=0,sat=100 is red, while with gammaCorrectHSV it is more paleish-red
So yeah value.saturation = Math.min(254, hsv.s * (2.54));
would prevent us going out of range. (I'll do a PR for that once I figure out why the gammaCorrectHSV is needed)
I spend most of the week looking at this and there is a clear trend...
I only tested tint, innr, and hue as those are in active use.
Hue | Innr | Tint | |
---|---|---|---|
scene_add (xy) | Looks off | Looks good | Looks good |
set (xy) | Looks good | Looks off (expect red) | Looks off |
scene_add (xy)
set color (xy)
It doesn't show up very well on picture, but in person it's clear in this case the blue LEDs are on.
I did find references to the gamma correct in Hue's developer docs, so perhaps this is only needed for Hue?
I did some more testing:
gamma correction added to scene_add | Hue | Innr | Tint | |
---|---|---|---|---|
scene_add (xy) | Looks good | Looks off | Looks off | |
set (xy) | Looks good | Looks off | Looks off |
gamma correction remove everywhere (also applyRedFix) | Hue | Innr | Tint | |
---|---|---|---|---|
scene_add (xy) | Looks off | Looks good | Looks good | |
set (xy) | Looks off | Looks good | Looks good |
I'm not sure what the right course of action here is...
@Koenkk I'd like to tackle this one next, my preference is for either 4 or 5... any objections to either of those?
TBH I'm a bit confused by this issue. The issue started with off colours when setting via hue/saturation but in https://github.com/Koenkk/zigbee-herdsman-converters/issues/2017#issuecomment-761226518 you mentioned x/y. Also gamma correction is only applied to hue/saturation not x/y. Note that the red fix does not fix off red colors, but fixes setting {x: 0.701, y: 0.299} doing nothing at all (https://github.com/Koenkk/zigbee-herdsman-converters/blob/4f4679631bbef485ccbb6132365a69837e13d4d0/converters/toZigbee.js#L976).
Could you summarise what the problem is here?
I’ll try to clarify later, but it stated with me noticing it with hue/sat.
But it ended up being for both hue/sat, xy, hex,... with any way to set it. Then I got confused as sometimes they looked good. Then I did covered it was because scene_add does not have the gamma correction so colors looked correct when using scenes.
It’s one of those goos chases that leads you down one bit rabbit hole. I’ll close this issues when I am on my computer and file a newer one... or well maybe 2 as I think there are two parts to this.
~ sjorge
On 22 Jan 2021, at 16:36, Koen Kanters notifications@github.com wrote:
TBH I'm a bit confused by this issue. The issue started with off colours when setting via hue/saturation but in #2017 (comment) you mentioned x/y. Also gamma correction is only applied to hue/saturation not x/y. Note that the red fix does not fix off red colors, but fixes setting {x: 0.701, y: 0.299} doing nothing at all (https://github.com/Koenkk/zigbee-herdsman-converters/blob/4f4679631bbef485ccbb6132365a69837e13d4d0/converters/toZigbee.js#L976).
Could you summarise what the problem is here?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.
Perhaps splitting 2128 into two seperate issues would be better even still. I did a bit more retesting and I don't think either solutioned mentioned here are OK so just ignore this entire issue now.
So I was messing with the RB 250 C as this is seems to be an odd bulb in the bunch that does not do enhancedHue... It also needs redfix.
FF0000 -> with redfix applied = dark red
hue:0, sat:100 -> off red, so I guess it also needs the red fix applied somehow... but... I noticed the following
Running the following...
Makes it go from off red, nearly dark red, dark red
The difference between the last 2 is very very tiny and I usually don't even notice it... I wonder if some how our saturation calculation is wrong for non enhancedHue ?