RGBWWZ virtual switch to LEDs does not function fully

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
Marque1968
Posts: 60
Joined: Tuesday 03 April 2018 18:41
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

RGBWWZ virtual switch to LEDs does not function fully

Post by Marque1968 »

I have a virtual RGBWWZ switch to set all my RGBWWZ-LEDs (Zigbee) with one action.

This is my DZvents script:

Code: Select all

return {
	on = {
		devices = {
			63,
		}
	},
	execute = function(domoticz, device)
        local lightIds = {}
        for i=1,#domoticz.helpers.SpotsRight do
            lightIds[#lightIds+1] = domoticz.helpers.SpotsRight[i]
        end
        for i=1,#domoticz.helpers.SpotsLeft do
            lightIds[#lightIds+1] = domoticz.helpers.SpotsLeft[i]
        end

        local function color2Params(color)
          return color.r, color.g, color.b, color.brightness, color.cw, color.ww, color.m, color.t
        end

        local function displaycolors(color)
          return 'r:' .. color.r .. ', g:' .. color.g .. ', b:' .. color.b.. ', br:' .. color.brightness .. ', cw:' .. color.cw.. ', ww:' .. color.ww.. ', mm:' .. color.m .. ', tt:' .. color.t
        end

	    for i=1,#lightIds do
	        if not(domoticz.devices(lightIds[i]).state == device.state) then
	          domoticz.devices(lightIds[i]).setState(device.state)
	        end
	        if device.state == 'On' then
     	        	domoticz.devices(lightIds[i]).setColor(color2Params(device.getColor()))
     	    	end
 	    end
	    domoticz.log('Device ' .. device.name .. ' was changed: ' .. displaycolors(device.getColor()), domoticz.LOG_INFO)
	end
}
- Brightness always returns 0. Manually setting it in "color2Params" to 100 does work, but of course I want the given brightness
- Changing from WW to Color and vise versa does not work. Only after switching the LEDs off and on again it shows the correct color.

Is this an Domoticz issue, a dzVents issue, or a Marque issue?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: RGBWWZ virtual switch to LEDs does not function fully

Post by waaren »

Marque1968 wrote: Monday 18 January 2021 8:31 I have a virtual RGBWWZ switch to set all my RGBWWZ-LEDs (Zigbee) with one action.
- Brightness always returns 0. Manually setting it in "color2Params" to 100 does work, but of course I want the given brightness
- Changing from WW to Color and vise versa does not work. Only after switching the LEDs off and on again it shows the correct color.

Is this an Domoticz issue, a dzVents issue, or a Marque issue?
The getColor method in dzVents internally use the rgbtohsb function. In that function the brightness is calculated. If you do not want the calculated value but the measured one, you must use the level attribute of the dimmable device.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Marque1968
Posts: 60
Joined: Tuesday 03 April 2018 18:41
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: RGBWWZ virtual switch to LEDs does not function fully

Post by Marque1968 »

Thank you. Taking it from level did indeed do the trick in regards to the brightness.

However, I still have the issue:

- When selecting an RGB color and press ON, all spots now switch on in this color
- Altering the brightness also works
- When I then select a WW color and press the ON button, all spots now sport the WW color
- Once again I go back to the Domoticz colorpicker and select RGB colors again and press the ON button, nothing happens to the spotlights
- Switching off the virtual lamp will switch the spots off
- Switching the virtual lamp back on again, and now all spots will have the RGB color I set 2 steps ago.

So why doesn't RGB after WW work?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: RGBWWZ virtual switch to LEDs does not function fully

Post by waaren »

Marque1968 wrote: Tuesday 19 January 2021 13:49 However, I still have the issue:
... So why doesn't RGB after WW work?
I see the same and it is comparable with other issues around copying colors from one device to 1 or more other devices.

This is a partly a timing issue. The setRGB function uses an API call to set the color under the surface but the script is triggered immediate and does get color information from a previous state. I have not checked but I can imagine that setting the WW does not change the color field in the database record but just ignore that. Anyway it is not something that can be solved in dzVents other then by coding an extra Off / On cycle to force the color field to be updated with the latest values.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Marque1968
Posts: 60
Joined: Tuesday 03 April 2018 18:41
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: RGBWWZ virtual switch to LEDs does not function fully

Post by Marque1968 »

Ok, thank you for that insight.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest