This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

4-bit to 1-byte conversion script for DALI, DMX512 etc.
#1
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.
 
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)
Reply
#2
(02.07.2015, 08:32)edgars Wrote: 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.
 
Code:
.....

I just cant make this work. I get an message: Lua syntax error at line 6: '=' expected near 'up'   It might just be too late at night...

edit:
Sorry.. just found the error... When copying your code RAW, and replacing it with my group addresses, something happened with the spaces.. When I deleted all space before code.. It worked.. adding space, still works?.. anyway, some copy-problems, works superb now.. thanks

Dont underestimate the Power of KNX
Darth Paul
Reply
#3
Hello, I've been using this script succesfully for about 2 years to be able to control the volume of my Sonos system directly from KNX Berker pushbuttons.
I now tried to do the same thing to make simulatious dimming of multiple lights from 1 button possible but for some reason I am getting an error message: "bad argument, number expected, got boolean)
I've checked in ETS and address '2/1/17' is defined as 4 bit.

Anybody an idea on what I might be doing wrong here?

Thanks, David

Attached Files Thumbnail(s)
   
Reply
#4
Check that 2/1/17 has 4-bit type in LM Objects tab, ETS settings does not matter
Reply
#5
(06.10.2018, 12:42)admin Wrote: Check that 2/1/17 has 4-bit type in LM Objects tab, ETS settings does not matter

Yep, that did the trick. Thanks a lot. Forgot that I have to define the objects in both ETS and LM  Blush
Reply
#6
Change the +10, -10 in the code as you need
------------------------------
Ctrl+F5
Reply
#7
(03.06.2021, 08:29)Daniel. Wrote: Change the +10, -10 in the code as you need

Thanks.

I think that I missed the os.sleep was at 5sec, so changed it to 1sec. 
Havent been able to try it out, but think that this was my issue Smile


EDIT:
I found that my issu was that I had set up an event based script, so this was just executed once, now I changed it to a resident script insted.
Reply


Forum Jump: