The function below is from st.zwave.defaults.switchLevel
:
--- Issue a level-set command to the specified device.
---
--- @param driver st.zwave.Driver
--- @param device st.zwave.Device
--- @param command table ST level capability command
function capability_handlers.switch_level_set(driver, device, command)
local set
local get
local delay = constants.MIN_DIMMING_GET_STATUS_DELAY -- delay in seconds
local level = utils.round(command.args.level)
level = utils.clamp_value(level, 1, 99)
if device:is_cc_supported(cc.SWITCH_MULTILEVEL) then
local dimmingDuration = command.args.rate or constants.DEFAULT_DIMMING_DURATION -- dimming duration in seconds
-- delay shall be at least 5 sec.
delay = math.max(dimmingDuration + constants.DEFAULT_POST_DIMMING_DELAY, delay) -- delay in seconds
get = SwitchMultilevel:Get({})
set = SwitchMultilevel:Set({ value=level, duration=dimmingDuration })
elseif device:is_cc_supported(cc.BASIC) then
get = Basic:Get({})
set = Basic:Set({ value=level})
end
device:send_to_component(set, command.component)
local query_level = function()
device:send_to_component(get, command.component)
end
device.thread:call_with_delay(delay, query_level)
end
The line below sets dimming duration to either the rate passed by the switchLevel capability or a default of 1 second. However, many dimmers have default dimming rates built in. Those device-specific default dimming rates would be prefereable to defaulting to a 1-second duration since they may be user configurable. Having the handler for switchLevel send a 1-second duration overrides those dimming settings programmed on the device.
local dimmingDuration = command.args.rate or constants.DEFAULT_DIMMING_DURATION -- dimming duration in seconds
To compound matters, there is currently no way for a user to specify that the device’s default dimming duration should be used. The setLevel capability allows a second argument (rate, a non-negative integer) to be passed. However, the ST app currently provides no way through device controls, routines, or scenes to specify what that rate should be.
Even if the rate argument could be passed, the duration
parameter for z-wave commands (see here as an example) is set up to expect the string “default” to be passed in order for the device to use its default rate settings. Since setLevel’s rate argument is an integer, there is no way for the user to send “default”.
@nayelyz Could the default handler be changed to use “default” as the dimming duration, instead of 1 second, when rate is not specified in the setLevel command? If a user desired a 1 second dimming duration, they would still be able to specify that using the rate argument (assuming the app is modified to allow that argument to be used).