20.10.2015, 11:53
(19.10.2015, 06:25)admin Wrote: Have you tried this script?
http://forum.logicmachine.net/showthread.php?tid=13
thanks, that works for me.
I added a resident script for dimming:
Code:
lastDali = 1
for i = 0, lastDali do
dimObjects = grp.tag('DALI_DIM_'..i)
for key, object in pairs(dimObjects) do
dimmer = object.data
step = bit.band(dimmer, 0x07)
if step ~= 0 then
lvObjects = grp.tag('DALI_LV_'..i)
for key, lvobject in pairs(lvObjects) do
up = bit.band(dimmer, 0x08) ~= 0
value = lvobject.data
if up then
newvalue = value + 5
else
newvalue = value - 5
end
-- clamp between 0 and 100
newvalue = math.min(newvalue, 100)
newvalue = math.max(newvalue, 0)
if newvalue ~= value then
lvobject:write(newvalue)
end
end
end
end
end
os.sleep(0.1)
And i added a script for setting the status
Code:
require('user.dali')
lastDali = 1
for i = 0, lastDali do
res = dalicmd('internal', 'queryactual', { addrtype = 'short', address = i })
if res then
curr = math.floor(res:byte() / 2.54)
-- set target level status
targetObjects = grp.tag('DALI_SLV_'..i)
for key, object in pairs(targetObjects) do
prev = object.data
if curr ~= prev then
targetObjects:response(curr)
end
end
-- set target on/off status
targetObjects = grp.tag('DALI_STAT_'..i)
for key, object in pairs(targetObjects) do
prev = object.data
if (curr>0) ~= prev then
targetObjects:response( curr > 0 )
end
end
end
end
os.sleep(0.1)
Next todo is a scene handler for DALI, see other thread
