Posts: 264
Threads: 39
Joined: Feb 2016
Reputation:
1
27.09.2017, 10:15
(This post was last modified: 27.09.2017, 10:19 by domotiqa.)
Hello,
I need to handle a 6 bytes value from KNX CIAT heating actuator (3 setpoint in one variable confort/eco/standby).
Then to put it to Bacnet for comptible Bacnet device.
I want to use Spacelynk for that (Schneider project), but this datatype missed !
Can I use bigger datatype ??
Waht solution ?
regards
http://dz.prosyst.com/pdoc/mBS_SH_SDK_7....etF16.html
Code: DPT_TEMPROOM_SETP_SETF16_MINOR
DPT minor type 222.100
-----------
FRANCE SMARTHOME & SMARTBUILDING INTEGRATION
SE ECO EXPERT
Posts: 264
Threads: 39
Joined: Feb 2016
Reputation:
1
Maybe I can use something like this with dstraw:
Code: require('genohm-scada.eibdgm')
local dpt = datatypes[ event.dstraw ]
if dpt then
local value = knxdatatype.decode(event.datahex, dpt)
end
then put decoded 6 byte value to 3 different 2 bytes value (in new varaible) and to check export for bacnet.
However, how can I do from bacnet, then reencode to 6 bytes....
-----------
FRANCE SMARTHOME & SMARTBUILDING INTEGRATION
SE ECO EXPERT
Posts: 1764
Threads: 6
Joined: Jul 2015
Reputation:
117
27.09.2017, 18:02
(This post was last modified: 27.09.2017, 20:53 by Erwin van der Zwart.)
Hi,
Create a 255 byte object (1/1/1 in this sample) and link it to the address of your 6 byte value that you use in the ETS and attached this script to it:
Code: if event.src ~= 'local' then
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('32/1/1', value1)
grp.update('32/1/2', value2)
grp.update('32/1/3', value3)
end
That will give you the 3x 2 byte float objects that you can export to BACnet.
Attach a tag to the 3x 2 byte float objects and create a event based script attached to that tag and paste this script in it:
Code: if event.src == 'local' then
value1 = grp.find('32/1/1').datahex
value2 = grp.find('32/1/2').datahex
value3 = grp.find('32/1/3').datahex
sixbytevaluestring = lmcore.hextostr(value1 .. value2 .. value3)
oldvalue = grp.getvalue('1/1/1')
if oldvalue ~= sixbytevaluestring then
grp.write('1/1/1', sixbytevaluestring)
end
end
This will write the (BACnet side) changed value back to your 6 byte object. Because i added event.src you can use the same 255 byte object for incomming and outgoing telegrams and avoid triggering a loop.
BR,
Erwin
Posts: 264
Threads: 39
Joined: Feb 2016
Reputation:
1
Ok thank you a lot, your product still has surprise ;-))
First solution (only put the variable without process on Spacelynk)
So if I understand well I could also use the 255 byte object for my 6 bytes knx object from CIAT. Then I just put it as export (for bacnet), the high level supervision could use this variable (and process it self to separate byte) ! What I don't know is when sending on knx bus, we send 256 bytes object, is it not a problem on KNX device Ciat which is waiting for a 6 bytes value ?
Second solution:
use your script then divide in 3 variable exported in bacnet
I don't understand your trick:
This will write the (BACnet side) changed value back to your 6 byte object. Because i added event.src you can use the same 255 byte object for incomming and outgoing telegrams and avoid triggering a loop.
-----------
FRANCE SMARTHOME & SMARTBUILDING INTEGRATION
SE ECO EXPERT
Posts: 1764
Threads: 6
Joined: Jul 2015
Reputation:
117
28.09.2017, 10:50
(This post was last modified: 28.09.2017, 10:51 by Erwin van der Zwart.)
Hi,
1) No i checked this in the ETS monitor and the value is a 6 byte value like $0C $D2 $0C $D3 $0D $C2 and not like $00 $00 .. $0C $D2 $0C $D3 $0D $C2 so all unused bytes in the 255 bytes are not send at all, making it a valid value (in 222.100 format) for your 6 byte object.
2) Because you send the value from KNX to the 6 byte it will only repond to split it to 3 bytes when it's from KNX and not when comming from local source (not from spaceLYnk), when you update the 255 byte object by the write from BACnet action it normaly would split the values again and create a loop, now it doesn't (:
BR,
Erwin
Posts: 264
Threads: 39
Joined: Feb 2016
Reputation:
1
28.09.2017, 11:20
(This post was last modified: 28.09.2017, 11:20 by domotiqa.)
great,
I prefer to use the Spacelynk only as bridge without processing (for maintenance issue), and let Schneider process variable on AS automate server (used in CVC).
I have the second solution with your script as backup if it fail !!
Thank you again !
-----------
FRANCE SMARTHOME & SMARTBUILDING INTEGRATION
SE ECO EXPERT
Posts: 1764
Threads: 6
Joined: Jul 2015
Reputation:
117
28.09.2017, 17:55
(This post was last modified: 28.09.2017, 17:56 by Erwin van der Zwart.)
Hi,
I don't think you can do it without my script, there is no way to set the string object (or any other higher then 4 byte object) directly to the AS-P by BACnet as it only supports analog and binary values.
This means you need to use the split to the 2 byte float objects in the spaceLYnk to get them in the Automation Server...
BR,
Erwin
Posts: 264
Threads: 39
Joined: Feb 2016
Reputation:
1
good to know...
So I will have to automate script for the 50 CIAT HVAC
cool lol
-----------
FRANCE SMARTHOME & SMARTBUILDING INTEGRATION
SE ECO EXPERT
Posts: 7758
Threads: 42
Joined: Jun 2015
Reputation:
447
If you have some specific addressing rules you only need two scripts mapped to tags
Posts: 264
Threads: 39
Joined: Feb 2016
Reputation:
1
you mean something like this:
ga = event.dst
value = event.getvalue()
then use adress+1 , adress +2, adress +3 for the separate byte ??
With knx->bacnet ok use tag knxBac
and for bacnet->knx use tag bacKnx (but to know the original 6 Byte address, it will be hard)
-----------
FRANCE SMARTHOME & SMARTBUILDING INTEGRATION
SE ECO EXPERT
Posts: 1764
Threads: 6
Joined: Jul 2015
Reputation:
117
29.09.2017, 06:16
(This post was last modified: 29.09.2017, 06:32 by Erwin van der Zwart.)
Hi,
I think we can do it with a single tag for each thermostat and a smart object structure, or with a triple tag on the object like ‘SPLIT, T1, 6B’ and ‘SPLIT, T1, SP1’ so SPLIT is event, T1 defines thermostat and 6B, SP1, SP2, SP3 defines object , i think we also can merge the 2 scripts to one that way, i will check this later (:
BR,
Erwin
Posts: 7758
Threads: 42
Joined: Jun 2015
Reputation:
447
My idea was to have 6-byte objects addressed starting from 3/1/0 and 2-byte object addressed starting from 3/2/0.
Then you can get 2-byte addresses from 6-byte address like this:
Code: 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)
And get 2-byte addresses and 6-byte address from 2-byte address like this:
Code: 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)
Then you just map different tags to 2-byte and 6-byte objects and use Erwin's conversion script. It can be simplified a bit by using event.datahex instead of using getvalue/strtohex conversion.
Posts: 264
Threads: 39
Joined: Feb 2016
Reputation:
1
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:
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
Posts: 7758
Threads: 42
Joined: Jun 2015
Reputation:
447
You can replace this:
Code: value = event.getvalue()
value = lmcore.strtohex(value)
With just this:
Code: value = event.datahex
Posts: 264
Threads: 39
Joined: Feb 2016
Reputation:
1
cool,
and my script above look's right ?
-----------
FRANCE SMARTHOME & SMARTBUILDING INTEGRATION
SE ECO EXPERT
Posts: 7758
Threads: 42
Joined: Jun 2015
Reputation:
447
Yes, but remove log() calls as they are not needed.
Posts: 264
Threads: 39
Joined: Feb 2016
Reputation:
1
thank for helping
-----------
FRANCE SMARTHOME & SMARTBUILDING INTEGRATION
SE ECO EXPERT
Posts: 1764
Threads: 6
Joined: Jul 2015
Reputation:
117
29.09.2017, 19:39
(This post was last modified: 29.09.2017, 19:39 by Erwin van der Zwart.)
Nice end result (:
Thanks Admin for filling in the final perfection!
BR,
Erwin
Posts: 264
Threads: 39
Joined: Feb 2016
Reputation:
1
Thanks both of you.
LM still is surprising after 5 year I'm using it ;-))
-----------
FRANCE SMARTHOME & SMARTBUILDING INTEGRATION
SE ECO EXPERT
Posts: 264
Threads: 39
Joined: Feb 2016
Reputation:
1
Looks like the import from ESF file of the 6 byte doesn't process.
Do you have idea to import all of them to 256 bytes ?
Should I create another project, put known datatype object tempory to the group adress , thenimport or do you have a trick
-----------
FRANCE SMARTHOME & SMARTBUILDING INTEGRATION
SE ECO EXPERT
|