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.

Get an object to respond to read request on the knx bus.
#1
Hi,

This is a very simple script,  add this to an object as a event script.  In scripting, event based, make sure the script executes on group read.  The data type of the object should match the last parameter in the grp.response line.  When you take this example below,  when the group address 12/0/1 is read on the KNX bus the Logic Machine (LM) will respond to the read telegram with a response telegram containing the current value of the object stored in the LM.


Code:
if (event.type=='groupread') then
  grp.response(event.dst,event.getvalue(),dt.bool)
end



Thanks,


Roger
Reply
#2
Here's an improved version where you don't have to set data type manually. The easiest way for this script to work it to map it on a tag instead of group address. This way you only need a single script for all group adresses that require read-response.


Code:
-- only reply to group read requests
if event.type == 'groupread' then
 obj = grp.find(event.dst)
 
 -- object found and has datatype set
 if obj and obj.decoded then  
   grp.response(event.dst, obj.value, obj.datatype)
 end
end
Reply
#3
Hi,

Thanks that's good to know.   Will your method does take longer to complete?  Given that you have to lookup the address, then create an object from that,  make sure the returned object is valid and only then will you send out a response.


Thanks,


Roger
Reply
#4
There's virtually no performance difference as both event.getvalue() and grp.find() require a single database query for object lookup.
Reply
#5
(06.07.2015, 11:21)admin Wrote: There's virtually no performance difference as both event.getvalue() and grp.find() require a single database query for object lookup.


Can you give some full info (or a source) about possibilities of command event.?() ?
Reply
#6
You can do log(event) to see the contents. getvalue is the only function in event table.
Reply
#7
(24.03.2016, 09:26)admin Wrote: You can do log(event) to see the contents. getvalue is the only function in event table.

Thank you, it is very helpfulWink
Reply
#8
Attention!
This script has stopped working after I updated the firmware to the latest version 2016.12.5.

The problem is event.getvalue() always returns zero when it is triggered by groupread. And as abonus the previous code now sets the group object to zero as a side effect.

Workaround is this small change:
if (event.type=='groupread') then
value = grp.getvalue(event.dst)
grp.response(event.dst,value,event.datatype)
end
LM5Lp, firmware: 2018.08.22 and 2021.12.15, FlashSYS v2, ARMv7 Processor rev 5 (v7l), kernel 4.4.151 and 4.4.259
Reply
#9
Hi,

You should already have use the improved version of 06-07-2015 in this thread to avoid your problem (:

BR,

Erwin
Reply


Forum Jump: