03.01.2024, 07:31
Calling grp.gettags/grp.find for each value change is very inefficient. You should cache all tagged objects and respective names, datatypes etc when the script starts. The cache is a table where each key is object group address and value is a table with required properties.
Then the callback can be similar to this:
Then the callback can be similar to this:
Code:
function localbus_onmessage(event)
-- find cached object
local obj = objects[ event.dst ]
if not obj then
return
end
local value = busdatatype.decode(event.datahex, obj.datatype, event.dstraw)
if type(value) == 'boolean' then
value = value and 1 or 0
end
mqtt_send:publish('from_knx_tag/'.. obj.topic, obj.prefix ..' '.. value)
end