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.

Local bus and sending to MQtt
#2
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:
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
Reply


Messages In This Thread
RE: Local bus and sending to MQtt - by admin - 03.01.2024, 07:31
RE: Local bus and sending to MQtt - by admin - 03.01.2024, 10:57
RE: Local bus and sending to MQtt - by admin - 03.01.2024, 11:13

Forum Jump: