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.

Creating a KNx point for Modbus Device Communication Error Situation
#1
Hello ,
When we have a communication problem in Logic Machine, In modbus section of LM, modbus device turns red color and we can understand there is a communication problem. I would like to transfer this information as a Bacnet point but I need first , I need to transfer this communication failure in to KNX data point.

How could i do that ?

Regards,
Reply
#2
Hi Savaskorkmaz,

I don't know if there is a function for this in the system, but i solved it once with a little resident script.

Put your actions on the position where the logging is now (replace them with your action).

Code:
-- Check all modbus meters for connection
query = 'SELECT * FROM modbus_devices'
meter_state = db:getall(query)
previous_state = storage.get('meterstate')
if previous_state == nil then
 for _, device in ipairs(meter_state) do
   if device.active == 0 then
     log(device.name .. " = down")
   else
     log(device.name .. " = active")
   end
 end
 storage.set('meterstate', meter_state)
else
 for _, device in ipairs(meter_state) do
   if device.active ~= previous_state[_].active then
     log(device.name .. ' is changed to ' .. device.active)
   end    
 end
 storage.set('meterstate', meter_state)
end

BR,

Erwin van der Zwart
Reply
#3
For now Erwin's script is the only solution, but we have this feature in our to-do list Smile
Reply
#4
Hi,

Here is a version with writing to KNX objects:

Code:
-- Check all modbus meters for connection

-- Function to send changes to KNX
function writetoknx(name,active)
    if name == 'Meter 1' then  -- name must match modbus device name
   grp.write('1/1/1', toboolean(active))
 elseif name == 'Meter 2' then
   grp.write('1/1/2', toboolean(active))
 elseif name == 'Meter 3' then
   grp.write('1/1/3', toboolean(active))
 elseif name == 'Meter 4' then
   grp.write('1/1/4', toboolean(active))
 elseif name == 'Meter 5' then
   grp.write('1/1/5', toboolean(active))
 end
end

-- Get meter status
query = 'SELECT * FROM modbus_devices'
meter_state = db:getall(query)
previous_state = storage.get('meterstate')
if previous_state == nil then
 for _, device in ipairs(meter_state) do
     writetoknx(device.name,device.active)
 end
 storage.set('meterstate', meter_state)
else
 for _, device in ipairs(meter_state) do
   if device.active ~= previous_state[_].active then
        writetoknx(device.name,device.active)
   end    
 end
 storage.set('meterstate', meter_state)
end
 
BR,
Erwin
Reply


Forum Jump: