Hi @nayelyz
When I manually handle the function capability_handlers.set_color()
in a driver copied from the colorControl default 46.x libraries, an error occurs, but when running the defaults directly in libraries error does not appears.
--- Issue an RGB color set command to the specified device.
---
--- @param driver st.zwave.Driver
--- @param device st.zwave.Device
--- @param command table ST color control capability command
function capability_handlers.set_color(driver, device, command)
local duration = constants.DEFAULT_DIMMING_DURATION
local r, g, b = utils.hsl_to_rgb(command.args.color.hue, command.args.color.saturation)
device:set_field(CAP_CACHE_KEY, command)
local set = SwitchColor:Set({
color_components = {
{ color_component_id=SwitchColor.color_component_id.RED, value=r },
{ color_component_id=SwitchColor.color_component_id.GREEN, value=g },
{ color_component_id=SwitchColor.color_component_id.BLUE, value=b },
{ color_component_id=SwitchColor.color_component_id.WARM_WHITE, value=0 },
{ color_component_id=SwitchColor.color_component_id.COLD_WHITE, value=0 },
},
duration=duration
})
device:send_to_component(set, command.component)
local query_color = function()
-- Use a single RGB color key to trigger our callback to emit a color
-- control capability update.
device:send_to_component(
SwitchColor:Get({ color_component_id=SwitchColor.color_component_id.RED }),
command.component
)
end
device.thread:call_with_delay(constants.MIN_DIMMING_GET_STATUS_DELAY, query_color)
end
2023-02-27T09:33:15.757524306+00:00 TRACE Z-Wave Bulb Mc Received event with handler capability
2023-02-27T09:33:15.758505306+00:00 INFO Z-Wave Bulb Mc <ZwaveDevice: e78f6785-37e1-48bd-a197-ecf8dbc13260 [27] (Dimmer Switch)> received command: {"args":{"color":{"hue":69.19,"saturation":91.11296187999636}},"capability":"colorControl","command":"setColor","component":"main","positional_args":[{"hue":69.19,"saturation":91.11296187999636}]}
2023-02-27T09:33:15.760355306+00:00 TRACE Z-Wave Bulb Mc Found CapabilityCommandDispatcher handler in zwave_bulb -> Fibaro RGBW Controller
2023-02-27T09:33:15.761485639+00:00 PRINT Z-Wave Bulb Mc <<<<<< duration default
2023-02-27T09:33:15.762602306+00:00 ERROR Z-Wave Bulb Mc Dimmer Switch thread encountered error: [string "st/dispatcher.lua"]:233: Error encountered while processing event for <ZwaveDevice: e78f6785-37e1-48bd-a197-ecf8dbc13260 [27] (Dimmer Switch)>:
arg1: table: 0x1a036c0
[string "st/dispatcher.lua"]:233: Error encountered while processing event for <ZwaveDevice: e78f6785-37e1-48bd-a197-ecf8dbc13260 [27] (Dimmer Switch)>:
arg1: table: 0x1a036c0
[string "st/zwave/init.lua"]:340: unrecognized argument 'duration'
I don’t understand why it says that it unrecognize the “duration” argument, am I doing something wrong or is there an error in the 46.x libraries?