Enlarging the size of the parameter value prevents the sending from generating an overflow error in the driver, but it does not work well since the value is interpreted in the device in an erroneous way.
Sending the value with 2’s complement and the correct size does work well to send the value and to configure the device correctly.
For now I will leave it like this in my driver for specific fibaro devices subdrivers.
--- Handle preference changes
---
--- @param driver st.zwave.Driver
--- @param device st.zwave.Device
--- @param event table
--- @param args
local function info_changed(driver, device, event, args)
local preferences = preferencesMap.get_device_parameters(device)
for id, value in pairs(device.preferences) do
if args.old_st_store.preferences[id] ~= value and preferences and preferences[id] then
local new_parameter_value = preferencesMap.to_numeric_value(device.preferences[id])
--2's complement value if needed
if preferences[id].size == 2 and new_parameter_value > 32767 then
new_parameter_value = new_parameter_value - 65536
elseif preferences[id].size == 1 and new_parameter_value > 127 then
new_parameter_value = new_parameter_value - 256
end
device:send(Configuration:Set({parameter_number = preferences[id].parameter_number, size = preferences[id].size, configuration_value = new_parameter_value}))
end
end
end
Maybe if it is implemented in the main init.lua (info_changed function), sending the value with complement 2 for all values that exceed the corresponding positive range of size 1, 2, 4 would be valid for all cases
Thanks