waaren wrote: ↑Tuesday 15 December 2020 23:39
gschmidt wrote: ↑Tuesday 15 December 2020 21:02
If my device is a RGBW dimmer what functions need to be added to control the Color and White?
Can you test this one?
Thanx man, this script is working (I have changed the order of the selector buttons a bit, and set the color to green):
Code: Select all
local ZSelector = 'Woonkamer_Switch' -- change to name of your selector
return
{
on =
{
devices =
{
ZSelector,
},
},
logging =
{
level = domoticz.LOG_DEBUG, -- set to domoticz.LOG_ERROR when all OK
marker = ZSelector,
},
execute = function(dz, item)
-- enter your devices and controls below this line
local group_1 = dz.groups('Kerstverlichting')
local device_2 = dz.devices('Woonkamer_Licht')
local Z =
{-- levelname targetDevice, action, delay, value -- delay and value are optional
['1_single'] = { group_1, 'On' },
['1_double'] = { group_1, 'Off' },
['1_hold'] = {group_1, 'Off', 30 },
['2_single'] = { device_2, 'On' },
['2_double'] = { device_2, 'Off' },
-- R, G, B, dimlevel
['2_hold'] = {device_2, 'setColor', 0, { 0, 255, 0, 70 } },
}
-- No changes required below this line
local function switch(object, action, delay, value)
object.cancelQueuedCommands()
if action == 'Off' then object.switchOff().afterSec(delay)
elseif action == 'On' then object.switchOn().afterSec(delay)
elseif action == 'dimTo' and object.isDevice then object.dimTo(value).afterSec(delay) -- dimTo not available to groups
elseif action == 'setColor' and object.isDevice then object.setColor(value[1], value[2], value[3], value[4]).afterSec(delay)
else
dz.log('unknown action (' .. action ..') for object ' .. object.name .. ' ( a ' .. object.baseType ..'). Please report.', dz.LOG_ERROR)
end
end
local row = Z[item.levelName]
switch(row[1], row[2], ( row[3] or 0 ), row[4] ) -- object (device / group), action, delay, value
end
}
This is the Log:
Code: Select all
2020-12-16 20:02:23.161 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2020-12-16 20:02:30.049 Status: dzVents: Info: Handling events for: "Woonkamer_Switch", value: "2_hold"
2020-12-16 20:02:30.049 Status: dzVents: Info: Woonkamer_Switch: ------ Start internal script: Script #1: Device: "Woonkamer_Switch (Zigbee2MQTT)", Index: 527
2020-12-16 20:02:30.050 Status: dzVents: Debug: Woonkamer_Switch: Processing device-adapter for Kerstverlichting: Group device adapter
2020-12-16 20:02:30.051 Status: dzVents: Debug: Woonkamer_Switch: Processing device-adapter for Woonkamer_Licht: RGB(W) device adapter
2020-12-16 20:02:30.051 Status: dzVents: Debug: Woonkamer_Switch: Processing device-adapter for Woonkamer_Licht: Switch device adapter
2020-12-16 20:02:30.051 Status: dzVents: Debug: Woonkamer_Switch: OpenURL: url = http://127.0.0.1:9090/json.htm?type=command¶m=setcolbrightnessvalue&idx=534&brightness=70&color={"m":3,"t":0,"cw":0,"ww":0,"r":0,"g":255,"b":0}
2020-12-16 20:02:30.051 Status: dzVents: Debug: Woonkamer_Switch: OpenURL: method = GET
2020-12-16 20:02:30.051 Status: dzVents: Debug: Woonkamer_Switch: OpenURL: post data = nil
2020-12-16 20:02:30.051 Status: dzVents: Debug: Woonkamer_Switch: OpenURL: headers = nil
2020-12-16 20:02:30.051 Status: dzVents: Debug: Woonkamer_Switch: OpenURL: callback = nil
2020-12-16 20:02:30.051 Status: dzVents: Info: Woonkamer_Switch: ------ Finished Script #1
2020-12-16 20:02:30.053 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2020-12-16 20:02:30.066 Status: setcolbrightnessvalue: ID: 216, bri: 70, color: '{m: 3, RGB: 00ff00, CWWW: 0000, CT: 0}
The controlled device "dz.devices('Woonkamer_Licht')" is a zigbee2mqtt group which is converted by the domoticz-zigbee2mqtt-plugin to a domoticz RGBWW dimmer device. The last row of the log is the command send by the device:
Code: Select all
2020-12-16 20:02:30.066 Status: setcolbrightnessvalue: ID: 216, bri: 70, color: '{m: 3, RGB: 00ff00, CWWW: 0000, CT: 0}
So this is the Color control example. What about the WW (color temperature)
When I manually change the WW color temperature of the "dz.devices('Woonkamer_Licht')" to the value I want, the log show this:
Code: Select all
2020-12-16 19:49:52.450 Status: setcolbrightnessvalue: ID: 216, bri: 61, color: '{m: 2, RGB: 000000, CWWW: 59a6, CT: 166}'
How can I control the Color_temp of the WW? m:2 is the color temp attribute?