06.07.2021, 10:58
Use this, change gateway number and short address as needed:
Code:
gateway = 'internal'
addr = 12
require('user.dali')
value = event.getvalue()
function setRGBWAF(gateway, addr, r, g, b, w, a, f)
if r == nil then r = 0 end
if g == nil then g = 0 end
if b == nil then b = 0 end
if w == nil then w = 0 end
if a == nil then a = 0 end
if f == nil then f = 0 end
res, err = dalicmd(gateway, 'setdtr0', { addrtype = 'short', address = addr, value = math.min(r, 254) })
if err then return nil, 'setdtr0 error: ' .. err end
res, err = dalicmd(gateway, 'setdtr1', { addrtype = 'short', address = addr, value = math.min(g, 254) })
if err then return nil, 'setdtr1 error: ' .. err end
res, err = dalicmd(gateway, 'setdtr2', { addrtype = 'short', address = addr, value = math.min(b, 254) })
if err then return nil, 'setdtr2 error: ' .. err end
res, err = dalicmd(gateway, 'enabledevicetype', { addrtype = 'short', address = addr, value = 8 })
if err then return nil, 'enabledevicetype error: ' .. err end
res, err = dalicmd(gateway, 'setrgbdimlevel', { addrtype = 'short', address = addr })
if err then return nil, 'setrgbdimlevel error: ' .. err end
res, err = dalicmd(gateway, 'setdtr0', { addrtype = 'short', address = addr, value = math.min(w, 254) })
if err then return nil, 'setdtr0 error: ' .. err end
res, err = dalicmd(gateway, 'setdtr1', { addrtype = 'short', address = addr, value = math.min(a, 254) })
if err then return nil, 'setdtr1 error: ' .. err end
res, err = dalicmd(gateway, 'setdtr2', { addrtype = 'short', address = addr, value = math.min(f, 254) })
if err then return nil, 'setdtr2 error: ' .. err end
res, err = dalicmd(gateway, 'enabledevicetype', { addrtype = 'short', address = addr, value = 8 })
if err then return nil, 'enabledevicetype error: ' .. err end
res, err = dalicmd(gateway, 'setwafdimlevel', { addrtype = 'short', address = addr })
if err then return nil, 'setwafdimlevel error: ' .. err end
res, err = dalicmd(gateway, 'enabledevicetype', { addrtype = 'short', address = addr, value = 8 })
if err then return nil, 'enabledevicetype error: ' .. err end
res, err = dalicmd(gateway, 'activate', { addrtype = 'short', address = addr })
return res, err
end
setRGBWAF(gateway, addr, value.red, value.green, value.blue, value.white)