Page 1 of 1

dzVents and RGBW functions

Posted: Friday 31 January 2020 14:45
by mikkel75
Hi,

I have a dummy RGBW dimmer switch, which I try to set using dzVents.
Maybe I don't use it right, but when I eg. do

Code: Select all

devices('McLighting').setHex(0, 0, 0)
I would expect the RGB value to be set to 0x000000.

However my log says:

Code: Select all

Status: setcolbrightnessvalue: ID: 281, bri: 0, color: '{m: 1, RGB: ffffff, CWWW: 0000, CT: 0}'
I have also tried:

Code: Select all

devices('McLighting').setRGB(0,0,0)
or

Code: Select all

devices('McLightingl').setColor(0, 0, 0, 0, 0, 0, 3, 0)
But nothing works.

Any suggestions?
I'm trying to set the RGB to 000000 and the white to 100.

/M

My Domoticz is:
Version: 4.11657
Build Hash: 1d05ce754-modified
Compile Date: 2020-01-27 09:08:42
dzVents Version: 2.5.7

Re: dzVents and RGBW functions

Posted: Friday 31 January 2020 17:54
by waaren
mikkel75 wrote: Friday 31 January 2020 14:45 I'm trying to set the RGB to 000000 and the white to 100.
Some quick tests.

Code: Select all

dzVents method       : setHex(0, 0, 0 )
dzVents generated URL: json.htm?type=command&param=setcolbrightnessvalue&brightness=0.0&hex=000000&iswhite=false
domoticz response    : Status: setcolbrightnessvalue: bri: 0, color: '{m: 1, RGB: ffffff, CWWW: 0000, CT: 0}'

dzVents method       : setColor(0, 0, 0 )
dzVents generated URL: json.htm?type=command&param=setcolbrightnessvalue&brightness=100&color={"m":3,"t":0,"cw":0,"ww":0,"r":0,"g":0,"b":0}
domoticz response    : Status: setcolbrightnessvalue: bri: 0, color: '{m: 3, RGB: ffffff, CWWW: 0000, CT: 0}'

dzVents method       : setRGB(0, 0, 0 )
dzVents generated URL: json.htm?param=setcolbrightnessvalue&type=command&hue=300&brightness=0&iswhite=true
domoticz response    : Status: setcolbrightnessvalue: bri: 0, color: '{m: 1, RGB: ff00ff, CWWW: 0000, CT: 0}'

dzVents method       : setHue(0, 0)
dzVents generated URL: json.htm?type=command&param=setcolbrightnessvalue&brightness=0&hue=0&iswhite=false
domoticz response    : Status: setcolbrightnessvalue: bri: 0, color: '{m: 3, RGB: ff0000, CWWW: 0000, CT: 0}'

dzVents method       : setColorBrightness(0, 0, 0, 100, 0, 0, 4, 0 )
dzVents generated URL: /json.htm?type=command&setcolbrightnessvalue&brightness=100&color={"m":4,"t":0,"cw":0,"ww":0,"r":0,"g":0,"b":0}
domoticz response    : Status: setcolbrightnessvalue: bri: 100, color: '{m: 4, RGB: 000000, CWWW: 0000, CT: 0}'
so I guess you are looking for

Code: Select all

setColorBrightness(0, 0, 0, 100, 0, 0, 4, 0 )

Re: dzVents and RGBW functions

Posted: Monday 03 February 2020 8:42
by mikkel75
@waaren: Thanks for your reply.
Do you see your tests as successful - ie. the output is as you expect given the input?

I'm sure I see why the setHex(0, 0, 0) function would result in RGB set to ffffff!?
That function also seems to use mode "ColorModeWhite = 1, // White. Valid fields: none", which also seems off, since it's RGB we want to change.

It's a bit the same story with the other functions...

Is it a bug or can someone please explain how this is though to make sens?

Thanks.
M

Re: dzVents and RGBW functions

Posted: Monday 03 February 2020 9:25
by waaren
mikkel75 wrote: Monday 03 February 2020 8:42 @waaren: Thanks for your reply.
Do you see your tests as successful - ie. the output is as you expect given the input?
Yes.

The output (the bulb) worked as expected based on the commands I gave. I tested this with a Yeelight RGBWW bulb.
the setRGB(0, 0, 0) and the setHex(0, 0, 0) both show me the expected white color. How that is internally handled in domoticz or the Yeelight hardware is not something I am willing to investigate. Color theory is too complicated for me.

Re: dzVents and RGBW functions

Posted: Monday 03 February 2020 11:17
by mikkel75
Hi again,

Have you tried with a dummy RGBW switch?

Don't you agree that setHex(0,0,0) resulting in RGB=ffffff seems like a bug?

It's not right to expect 0x000000 to be the same as 0xffffff, 000000 is black and ffffff is white.

/m

Re: dzVents and RGBW functions

Posted: Monday 03 February 2020 11:23
by waaren
mikkel75 wrote: Monday 03 February 2020 11:17 Have you tried with a dummy RGBW switch?
No with a real one
Don't you agree that setHex(0,0,0) resulting in RGB=ffffff seems like a bug?
Yes, I don't agree
It's not right to expect 0x000000 to be the same as 0xffffff, 000000 is black and ffffff is white.
Yes, That is what I expected. But I am happy that my lights turns white when I send that command via dzVents. As stated in my previous post I am no color expert and I don't have the urge to become one :)

Re: dzVents and RGBW functions

Posted: Monday 03 February 2020 13:29
by mikkel75
Well it looks like the setHex() function is actually not setting RGB values dirtectly, but converting them to HSB

from dzVents sources:

Code: Select all

function device.setHex(r,g,b)
			local _ , _ , brightness = domoticz.utils.rgbToHSB(r, g, b)
			local hex = string.format("%02x",r) .. string.format("%02x", g) .. string.format("%02x", b)
			local url = domoticz.settings['Domoticz url'] .. '/json.htm?type=command&param=setcolbrightnessvalue' ..
				'&idx=' .. device.id ..
				'&brightness=' .. brightness ..
				'&hex=' .. hex ..
				'&iswhite=false'
			return domoticz.openURL(url)
		end
So I guess Domoticz handles RGB(W) in HSB format and that the conversion is where the error comes from...

I guess I'll have to find a work-around...

Re: dzVents and RGBW functions

Posted: Monday 03 February 2020 15:00
by boum
mikkel75 wrote: Monday 03 February 2020 13:29 So I guess Domoticz handles RGB(W) in HSB format and that the conversion is where the error comes from...

I guess I'll have to find a work-around...
Well, the RGB to HSV is only used to compute the brightness (value) of the color, the R, G and B components are passed directly (I just wonder why 3 format calls are made instead of local hex = string.format("%02x%02x%02x",r,g,b), but it works too)

The RGB value is changed to ffffff inside domoticz code along with a brightness of 0.

About a workaround, @waaren provided you with one above:

Code: Select all

setColorBrightness(r, g, b, 100, 0, w, 4, 0 )
With all values supposed to be in 0..255 range.

Re: dzVents and RGBW functions

Posted: Monday 03 February 2020 16:48
by mikkel75
You are right :roll: Must have been looking at this before coffee....

Why would it be needed to fix RGB to 0xffffff if brightness is 0?

/M