This code will send everything it captures to influx, then you can filter whatever you want in grafana. Create resident script with zero delay
Code:
local socket = require('socket')
local http = require('socket.http')
http.TIMEOUT = 5
local dt_cache = {}
function get_value(addr, datahex)
local dt = dt_cache[addr]
if(not dt) then
dt = grp.find(addr)
dt_cache[addr] = dt
end
return knxdatatype.decode(datahex, dt.datatype), dt
end
function knx_callback(event)
local addr = event.dst
local value, dt = get_value(addr, event.datahex)
send_metric('rawdata', dt.name, addr, value)
end
function send_metric(table, name, addr, value)
if(name == nil or name == '') then
return
end
name = string.gsub(name, ' ', '\\ ')
local url = 'http://IP:8086/write?db=knxdb'
local args
if(type(value) == 'boolean') then
args = string.format('%s,name=%s,addr=%s state=%s', table, name, addr, value)
else
-- most likely number
args = string.format('%s,name=%s,addr=%s value=%s', table, name, addr, value)
end
res, err = http.request(url, args)
if(err ~= 204) then
log('error sending to influx', res, err, args)
end
end
function run_loop()
local bus = require('localbus').new(1)
bus:sethandler('groupwrite', knx_callback)
local busfd = socket.fdmaskset(bus:getfd(), 'r')
while(true) do
res, fbus = socket.selectfds(10, busfd)
if(fbus) then
bus:step()
end
end
end
run_loop()