setRGB problem

Moderator: leecollings

Post Reply
jefft
Posts: 75
Joined: Monday 23 January 2017 23:30
Target OS: Linux
Domoticz version: 2023.1
Location: UK
Contact:

setRGB problem

Post by jefft »

I'm using dzVents code to set the colour of a RGB switch, which is ultimately sent to a WLED device by the plugin. When I set the colour, the result is not correct. Often, the blue part seems to be ignored - I specify white and get yellow, etc.

Code:

Code: Select all

    domoticz.devices('WLED Lounge TV').setRGB(255,255,200,100)	-- I've tried many combinations, with and without brightness; same result
    domoticz.log('WLED colour is ' .. domoticz.devices('WLED Lounge TV').color)
That should produce a slightly off-white colour. It gives me yellow. The RGB wheel in the UI shows the position at the edge of the wheel in the yellow segment.

Log:

Code: Select all

2020-12-15 16:47:56.809 Status: User: Admin (IP: 192.168.10.36) initiated a switch command (1731/Test switch 2/On)
2020-12-15 16:47:56.919 Status: dzVents: Info: Handling events for: "Test switch 2", value: "On"
2020-12-15 16:47:56.919 Status: dzVents: Info: ------ Start internal script: TEST2: Device: "Test switch 2 (Scene trigger dummy switches)", Index: 1731
2020-12-15 16:47:56.919 Status: dzVents: Info: ******** TEST2
2020-12-15 16:47:56.920 Status: dzVents: Info: WLED colour is {"b":0,"cw":0,"g":255,"m":3,"r":255,"t":0,"ww":0}
2020-12-15 16:47:56.921 Status: dzVents: Info: ------ Finished TEST2
2020-12-15 16:47:56.922 Status: EventSystem: Script event triggered: /home/domoticz/domoticz/dzVents/runtime/dzVents.lua
2020-12-15 16:47:56.940 Status: setcolbrightnessvalue: ID: a20, bri: 100, color: '{m: 3, RGB: ffff00, CWWW: 0000, CT: 0}'
When I set the colour of the RGB device from the domoticz UI, the WLED goes to the correct colour. However, the dzVents view of the RGB values is once again not correct - e.g., for a slightly blueish white:

Code: Select all

2020-12-15 16:52:18.154 Status: dzVents: Info: WLED colour is {"b":0,"cw":0,"g":255,"m":3,"r":255,"t":0,"ww":0}
Note that in both cases, the reported blue value is ZERO and the red, green are 255.

It's not always b=0; if I set the RGB to a strong blue, I get this reported:

Code: Select all

2020-12-15 16:53:49.569 Status: dzVents: Info: WLED colour is {"b":181,"cw":0,"g":248,"m":3,"r":255,"t":0,"ww":0}
... but here, there is nowhere near that much green in the colour and there's no red at all; I chose almost pure blue.

@waaren, any idea what's going wrong here, please?
Domoticz, Z-Stick Gen.5, zzh Zigbee, rxftrx433XL on Ubuntu 22.04, HP 290 G1.
Node Red, MQTT, 80+ Z-wave, ESP8266 & Shelly, handful of Zigbee bulbs. EMS-ESP gateway for Bosch boiler. Controlicz, until it dies :-(
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: setRGB problem

Post by waaren »

jefft wrote: Tuesday 15 December 2020 17:55 I'm using dzVents code to set the colour of a RGB switch, which is ultimately sent to a WLED device by the plugin. When I set the colour, the result is not correct. Often, the blue part seems to be ignored - I specify white and get yellow, etc.

Code:

Code: Select all

    domoticz.devices('WLED Lounge TV').setRGB(255,255,200,100)	-- I've tried many combinations, with and without brightness; same result
    domoticz.log('WLED colour is ' .. domoticz.devices('WLED Lounge TV').color)
any idea what's going wrong here, please?
the setRGB method has only 3 parms (R, G and B). The 4th parm you supplied here is ignored. If you want to see the effect of this method you cannot do that during the same execution of the script. The way domoticz event scripts work is that they are receiving all attributes of the devices at the start of the script and send all updates back to domoticz when the script has finished. So any updates will take place after the script's execution.

Check the wiki for other methods to update the colour, brightness, colour temperature of an RGB(WW) device type.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
jefft
Posts: 75
Joined: Monday 23 January 2017 23:30
Target OS: Linux
Domoticz version: 2023.1
Location: UK
Contact:

Re: setRGB problem

Post by jefft »

Okay, so the values reported back in the range script aren't right, but there's still the issue of it setting a colour that isn't the one I specified. The UI would be up to date immediately after the script ran and that's showing the wrong colour was set...
Domoticz, Z-Stick Gen.5, zzh Zigbee, rxftrx433XL on Ubuntu 22.04, HP 290 G1.
Node Red, MQTT, 80+ Z-wave, ESP8266 & Shelly, handful of Zigbee bulbs. EMS-ESP gateway for Bosch boiler. Controlicz, until it dies :-(
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: setRGB problem

Post by waaren »

jefft wrote: Tuesday 15 December 2020 21:35 Okay, so the values reported back in the range script aren't right, but there's still the issue of it setting a colour that isn't the one I specified. The UI would be up to date immediately after the script ran and that's showing the wrong colour was set...
I cannot replicate your issue
Tested on devices with type Color Switch, subtype RGBWW and on devices type Color Switch subtype RGBW and colors, after using setRGB, are more or less equal to to the colors I see with these RGB values on this color test site
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
jefft
Posts: 75
Joined: Monday 23 January 2017 23:30
Target OS: Linux
Domoticz version: 2023.1
Location: UK
Contact:

Re: setRGB problem

Post by jefft »

Thanks. I think mine's set up as RGB, not RGBW - no white options in the UI, just the colour wheel.

I'll check further tomorrow: I'll do some tests at the extremes and with mixed colours, see what happens in the UI with a pure dummy device and to the lamps with the real one. I'll also create another event to read back the values for the log, so that it's not affected by the same-script behaviour.
Domoticz, Z-Stick Gen.5, zzh Zigbee, rxftrx433XL on Ubuntu 22.04, HP 290 G1.
Node Red, MQTT, 80+ Z-wave, ESP8266 & Shelly, handful of Zigbee bulbs. EMS-ESP gateway for Bosch boiler. Controlicz, until it dies :-(
jefft
Posts: 75
Joined: Monday 23 January 2017 23:30
Target OS: Linux
Domoticz version: 2023.1
Location: UK
Contact:

Re: setRGB problem

Post by jefft »

So, I've done some more testing with this. It seems that the reported values from device.color are sometimes incorrect after updates from the domoticz UI. Rather a long post, but I've included several examples with a real lamp and a pure dummy.

If I setRGB in code, then use a second event to read back device.color, the results match - set 255,0,255 read 255,0,255, etc.

If I set the colour using the UI colour picker, trigger an event on that light device changing and report the values, they are incorrect - typically, b=255 whatever colour I select!
If I use a separate event, triggered manually by a switch, to read back device.color after setting colour through the UI, it is also reported incorrectly.

Code: Select all

[1] Set UI colour picker to green:
2020-12-27 15:29:53.563 (Scene trigger dummy switches) Color Switch (WLED Lounge TV)
2020-12-27 15:29:53.556 Status: setcolbrightnessvalue: ID: a20, bri: 100, color: '{m: 3, RGB: 0fff37, CWWW: 0000, CT: 0}'
2020-12-27 15:29:53.661 Status: dzVents: Info: Handling events for: "WLED Lounge TV", value: "Set Color"
2020-12-27 15:29:53.661 Status: dzVents: Info: ------ Start internal script: TEST3: Device: "WLED Lounge TV (Scene trigger dummy switches)", Index: 2592
2020-12-27 15:29:53.661 Status: dzVents: Info: WLED colour is {"b":255,"cw":0,"g":0,"m":3,"r":0,"t":0,"ww":0}
... wrong!

Query colour again after a 10+ seconds:
2020-12-27 15:31:09.115 Status: dzVents: Info: ------ Start internal script: TEST3: Device: "Test switch 2 (Scene trigger dummy switches)", Index: 1731
2020-12-27 15:31:09.116 Status: dzVents: Info: WLED colour is {"b":255,"cw":0,"g":0,"m":3,"r":0,"t":0,"ww":0}
... still wrong!

[2] Set UI to white-ish:
020-12-27 15:31:55.446 Status: setcolbrightnessvalue: ID: a20, bri: 100, color: '{m: 3, RGB: f8f2ff, CWWW: 0000, CT: 0}'
2020-12-27 15:31:55.549 Status: dzVents: Info: Handling events for: "WLED Lounge TV", value: "Set Color"
2020-12-27 15:31:55.549 Status: dzVents: Info: ------ Start internal script: TEST3: Device: "WLED Lounge TV (Scene trigger dummy switches)", Index: 2592
2020-12-27 15:31:55.549 Status: dzVents: Info: WLED colour is {"b":55,"cw":0,"g":255,"m":3,"r":15,"t":0,"ww":0}
2020-12-27 15:31:55.549 Status: dzVents: Info: ------ Finished TEST3
... wrong, that would be a green-ish shade, not white.

Query again:
2020-12-27 15:32:39.486 Status: dzVents: Info: WLED colour is {"b":55,"cw":0,"g":255,"m":3,"r":15,"t":0,"ww":0}
... Still wrong.

[3] Set picker to strong blue:
2020-12-27 15:41:36.015 Status: setcolbrightnessvalue: ID: a20, bri: 100, color: '{m: 3, RGB: 0307ff, CWWW: 0000, CT: 0}'
2020-12-27 15:41:36.117 Status: dzVents: Info: Handling events for: "WLED Lounge TV", value: "Set Color"
2020-12-27 15:41:36.117 Status: dzVents: Info: ------ Start internal script: TEST3: Device: "WLED Lounge TV (Scene trigger dummy switches)", Index: 2592
2020-12-27 15:41:36.118 Status: dzVents: Info: WLED colour is {"b":255,"cw":0,"g":242,"m":3,"r":248,"t":0,"ww":0}
2020-12-27 15:41:36.118 Status: dzVents: Info: ------ Finished TEST3
... wrong.  No way is there 242 green or 248 red in the colour I selected, it was near-pure blue.

Query again:
2020-12-27 15:42:42.138 Status: dzVents: Info: WLED colour is {"b":255,"cw":0,"g":242,"m":3,"r":248,"t":0,"ww":0}
... wrong.

Reporting event code:

Code: Select all

return {
	on = {
		devices = {
		    'Test switch 2',
			'WLED Lounge TV'
		},
	},
	execute = function(domoticz, triggeredItem)
        domoticz.log('WLED colour is ' .. domoticz.devices('WLED Lounge TV').color)
	end
}
Some tests with a pure dummy switch (RGBWW), so that the WLED plugin isn't involved:

Code: Select all

[1] Picker to red:
2020-12-27 15:45:29.729 Status: setcolbrightnessvalue: ID: 987, bri: 64, color: '{m: 3, RGB: ff0005, CWWW: 0000, CT: 0}'
2020-12-27 15:45:29.835 Status: dzVents: Info: Handling events for: "Test RGBWW", value: "Set Color"
2020-12-27 15:45:29.835 Status: dzVents: Info: ------ Start internal script: TEST3: Device: "Test RGBWW (Scene trigger dummy switches)", Index: 2439
2020-12-27 15:45:29.836 Status: dzVents: Info: Test RGBWW colour is {"b":0,"cw":126,"g":0,"m":2,"r":0,"t":129,"ww":129}
2020-12-27 15:45:29.836 Status: dzVents: Info: ------ Finished TEST3
... wrong.  We can see 255,0,5 set but we get 0,0,0 read back.

[2] Picker to blue-green:
2020-12-27 15:48:03.774 Status: setcolbrightnessvalue: ID: 987, bri: 64, color: '{m: 3, RGB: 07fff9, CWWW: 0000, CT: 0}'
2020-12-27 15:48:03.879 Status: dzVents: Info: Handling events for: "Test RGBWW", value: "Set Color"
2020-12-27 15:48:03.879 Status: dzVents: Info: ------ Start internal script: TEST3: Device: "Test RGBWW (Scene trigger dummy switches)", Index: 2439
2020-12-27 15:48:03.880 Status: dzVents: Info: Test RGBWW colour is {"b":5,"cw":0,"g":0,"m":3,"r":255,"t":0,"ww":0}
2020-12-27 15:48:03.880 Status: dzVents: Info: ------ Finished TEST3
... wrong. There's almost no red set, 7, yet 255 is read back.

Query again, ~20 seconds later:
2020-12-27 15:48:49.805 Status: dzVents: Info: Test RGBWW colour is {"b":5,"cw":0,"g":0,"m":3,"r":255,"t":0,"ww":0}
... still wrong values.

Any ideas? Looks like device.color is giving results that don't match the UI when the colour picker is used, but when setRGB is used, the UI, the lamp and device.color are in agreement.
Domoticz, Z-Stick Gen.5, zzh Zigbee, rxftrx433XL on Ubuntu 22.04, HP 290 G1.
Node Red, MQTT, 80+ Z-wave, ESP8266 & Shelly, handful of Zigbee bulbs. EMS-ESP gateway for Bosch boiler. Controlicz, until it dies :-(
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest