04.01.2021, 09:59
(This post was last modified: 04.01.2021, 10:02 by davidchispas.)
(03.06.2020, 06:11)admin Wrote: You need to use queryactual instead of querystatus command.
Try this script:
Code:require('user.dali')
function queryactual(short, addr)
local res, err = dalicmd('internal', 'queryactual', { addrtype = 'short', address = short })
if res then
local val = res:byte()
if val > 0 then
val = math.floor(val / 2.54 + 0.5)
val = math.max(1, val)
end
grp.checkupdate(addr, val)
end
end
queryactual(0, '11/1/103')
queryactual(1, '11/1/104')
I need your opinion on how it is advisable to obtain the status of the ballasts in group.
For example, a group of 60 ballasts linked to the same control object. To visualize the real state I need to obtain at least the state of one of them, but in the event that in the future that ballast fails, could I assign the same address to the 60 ballasts?
To visualize the On / Off status, I added another line to the script, is that fine, or is it recommended to do it in another way?
Code:
require('user.dali')
function queryactual(short, addr)
local res, err = dalicmd('internal', 'queryactual', { addrtype = 'short', address = short })
if res then
local val = res:byte()
if val > 0 then
val = math.floor(val / 2.54 + 0.5)
val = math.max(1, val)
end
grp.checkupdate(addr, val)
end
end
queryactual(0, '1/1/0') --Porcentage
queryactual(0, '1/2/0') --1Bit
queryactual(1, '1/1/0') --Porcentage
queryactual(1, '1/2/0') --1Bit
queryactual(2, '1/1/0') --Porcentage
queryactual(2, '1/2/0') --1Bit