02.07.2015, 08:32
Resident script (sleep interval = 0), which is doing conversion from 4-bit to 1-byte
4-bit dimmer object adress is 1/1/1
1-byte output object adress is 1/1/2
By default, script will change value by 10% every 0.2 seconds when any kind of up/down telegram is received.
4-bit dimmer object adress is 1/1/1
1-byte output object adress is 1/1/2
By default, script will change value by 10% every 0.2 seconds when any kind of up/down telegram is received.
Code:
dimmer = grp.getvalue('1/1/1')
step = bit.band(dimmer, 0x07)
if step ~= 0 then
addr = '1/1/2'
up = bit.band(dimmer, 0x08) ~= 0
value = grp.getvalue(addr)
if up then
newvalue = value + 10
else
newvalue = value - 10
end
-- clamp between 0 and 100
newvalue = math.min(newvalue, 100)
newvalue = math.max(newvalue, 0)
if newvalue ~= value then
grp.write(addr, newvalue)
end
end
os.sleep(0.2)