29.09.2017, 14:32
cool, great idea !
Your a genious !
I would not have this idea at all !!!
So for my script if I tag all 6byte with "knxBacnet"
and a script:
and another with tag "bacKnx"
But I don't understant your point of view about the "event.datahex"
Your a genious !
I would not have this idea at all !!!
So for my script if I tag all 6byte with "knxBacnet"
and a script:
Code:
if event.src ~= 'local' then
-- get 3 adress from 6bytes adress
addr = event.dst
last = tonumber(addr:split('/')[3])
off = last * 3
addr1 = '3/2/' .. (off)
addr2 = '3/2/' .. (off + 1)
addr3 = '3/2/' .. (off + 2)
log(addr1, addr2, addr3)
-- -----
-- decode 3 value from 6bytes value
value = event.getvalue()
value = lmcore.strtohex(value)
bytestable = {}
for i = 2, #value, 2 do
bytevalue = string.sub(value, (i-1), i)
table.insert(bytestable, bytevalue)
end
value1 = knxdatatype.decode(bytestable[1] .. bytestable[2], dt.float16)
value2 = knxdatatype.decode(bytestable[3] .. bytestable[4], dt.float16)
value3 = knxdatatype.decode(bytestable[5] .. bytestable[6], dt.float16)
grp.update(addr1 , value1)
grp.update(addr2 , value2)
grp.update(addr3, value3)
end
and another with tag "bacKnx"
Code:
if event.src == 'local' then
-- get 3 adress from 2bytes adress
addr = event.dst
last = tonumber(addr:split('/')[3])
off = math.floor(last / 3)
addr1 = '3/2/' .. (off * 3)
addr2 = '3/2/' .. (off * 3 + 1)
addr3 = '3/2/' .. (off * 3 + 2)
out = '3/1/' .. off
log(addr1, addr2, addr3, out)
-- -----
-- encode 6 bytes value from 3x2bytes value
value1 = grp.find(addr1).datahex
value2 = grp.find(addr2).datahex
value3 = grp.find(addr3).datahex
sixbytevaluestring = lmcore.hextostr(value1 .. value2 .. value3)
oldvalue = grp.getvalue(out)
if oldvalue ~= sixbytevaluestring then
grp.write(out, sixbytevaluestring)
end
end
But I don't understant your point of view about the "event.datahex"
Quote:It can be simplified a bit by using event.datahex instead of using getvalue/strtohex conversion.
-----------
FRANCE SMARTHOME & SMARTBUILDING INTEGRATION
SE ECO EXPERT
FRANCE SMARTHOME & SMARTBUILDING INTEGRATION
SE ECO EXPERT