I am trying to create the RGB function / colorpicker to control the ledstrips which are running through a LUA script but for some reason it turns
all the colors on and doesn't let me select a color.
I've tried all options RGB and RGBW, and RGBWW but nothing seems to work correctly. The script I am using is the following script:
Code: Select all
local lights = {
['muurbart'] = {ip = '192.168.188.242', red = '15', grn = '13', blu = '12', rgb = true}
}
function setlight (ip, pin, dvalue)
os.execute("curl 'http://" .. ip.. "/control?cmd=PWM,".. pin .."," .. tostring(dvalue) .. ",1028'")
end
commandArray = {}
for deviceName,deviceValue in pairs(devicechanged) do
if (lights[deviceName]) then
if (deviceValue == 'Off') then
dvalue = 0
elseif (deviceValue == 'On') then
dvalue = 1024
else
inputValue = tonumber(otherdevices_svalues[deviceName])
curve = 1.5848931924611
normalizedCurVal = (inputValue - 1.0) / 99.0
rangedValue = (math.pow(normalizedCurVal, curve) * 1023.0) + 1.0
dvalue = math.ceil(rangedValue)
end
if (lights[deviceName]['rgb']) then
setlight(lights[deviceName]["ip"], lights[deviceName]["red"], dvalue)
setlight(lights[deviceName]["ip"], lights[deviceName]["grn"], dvalue)
setlight(lights[deviceName]["ip"], lights[deviceName]["blu"], dvalue)
else
setlight(lights[deviceName]["ip"], lights[deviceName]["pin"], dvalue)
end
end
end
return commandArray