Get an object to respond to read request on the knx bus. - Printable Version +- Logic Machine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8) +--- Thread: Get an object to respond to read request on the knx bus. (/showthread.php?tid=18) |
Get an object to respond to read request on the knx bus. - rocfusion - 04.07.2015 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 Thanks, Roger RE: Get an object to respond to read request on the knx bus. - admin - 06.07.2015 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 RE: Get an object to respond to read request on the knx bus. - rocfusion - 06.07.2015 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 RE: Get an object to respond to read request on the knx bus. - admin - 06.07.2015 There's virtually no performance difference as both event.getvalue() and grp.find() require a single database query for object lookup. RE: Get an object to respond to read request on the knx bus. - buuuudzik - 24.03.2016 (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.?() ? RE: Get an object to respond to read request on the knx bus. - admin - 24.03.2016 You can do log(event) to see the contents. getvalue is the only function in event table. RE: Get an object to respond to read request on the knx bus. - buuuudzik - 24.03.2016 (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 helpful RE: Get an object to respond to read request on the knx bus. - Thomas - 11.02.2017 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 RE: Get an object to respond to read request on the knx bus. - Erwin van der Zwart - 11.02.2017 Hi, You should already have use the improved version of 06-07-2015 in this thread to avoid your problem (: BR, Erwin |