DALI gateway Back

res, err = dalicmd(gwid, cmd, params)

Sends a DALI command to the given gateway. Returns true on success when no reply is expected, string on success when reply is expected, nil plus an error message in case of failure


Params (Lua table):

3 addressing modes are supported

Command types

If command is addressable, you must provide address type and address in params table.

If command expects a reply it must be addressed so only one slave can reply, otherwise a collision will happen. In case of success, reply is a binary string, usually consisting of a single byte. You can convert it to number like this:

-- query status of slave with short address 5 on the internal DALI bus
res, err = dalicmd('internal', 'querystatus', { addrtype = 'short', address = 5 })
-- read ok
if res then
  status = res:byte()

If command has a value range, params table must have a value field which is an integer in the specified range. For example, arc command accepts a value from 0 to 254:

-- set level to 42 for all slave on the internal DALI bus
dalicmd('internal', 'arc', { addrtype = 'broadcast', value = 42 })

Changing internal slave paramaters

Most parameters are changed via DTR (data transfer register), so first you need to set DTR value via setdtr and then set the required parameter via a second request

-- set max level to 200 for slave with short address 5 on the internal DALI bus
dalicmd('internal', 'setdtr', { addrtype = 'short', address = 5, value = 200 })
dalicmd('internal', 'storemax', { addrtype = 'short', address = 5 })

Example (use gateway with id 1, switch all ballasts off, set ballast with short address 5 to full on):


dalicmd(1, 'arc', { addrtype = 'broadcast', value = 0 })
dalicmd(1, 'arc', { addrtype = 'short', address = 5, value = 254 })

DALI commands

Command Description Addressable Reply from slave Value range
arc direct arc power control 0..254
off turn off without fading
up dim up using the selected fade rate
down dim down using the selected fade rate
stepup step up
stepdown step down
recallmax recall max level
recallmin recall min level
stepdownoff step down and off
stepupon on and step up
gotoscene go to scene 0..15
reset reset
storeactual store actual level in the dtr
storemax store the dtr as max level
storemin store the dtr as min level
storesystemfailure store the dtr as system failure level
storepoweron store the dtr as power on level
storefadetime store the dtr as fade time
storefaderate store the dtr as fade rate
storescene store the dtr as scene 0..15
removescene remove from scene 0..15
addtogroup add to group 0..15
removefromgroup remove from group 0..15
storeshortaddress store dtr as short address
querystatus query status
queryballast query ballast
querylampfailure query lamp failure
querylamppoweron query lamp power on
querylimiterror query limit error
queryresetstate query reset state
querymissingshort query missing short address
queryversion query version number
querydtr query content dtr
querydevicetype query device type
queryphysicalmin query physical minimum level
querypowerfailure query power failure
queryactual query actual level
querymax query max level
querymin query min level
querypoweron query power on level
querysystemfailure query system failure level
queryfadetimerate query fade time / fade rate
queryscene query scene level (scenes 0-15) 0..15
querygroupslow query groups 0-7
querygroupshigh query groups 8-15
queryrandomaddrh query random address (high)
queryrandomaddrm query random address (middle)
queryrandomaddrl query random address (low)
terminate terminate
setdtr set data transfer register (dtr) 0..255
initialise initialise
randomise randomise
compare compare
withdraw withdraw
searchaddrh set search address (high) 0..255
searchaddrm set search address (middle) 0..255
searchaddrl set search address (low) 0..255
programshortaddr program short address 0..63
verifyshortaddr verify short address 0..63
queryshortaddr query short address
physicalselection physical selection
enabledevicetype enable device type x 0..255