(18.11.2023, 10:46)Erwin van der Zwart Wrote: There are several ways to do that..
When the devices are on TP you could use knxlib.ping('1.1.1')
Another option when you also need to check devices on IP is to have on each device at least 1 object with the read flag enabled and set to a grp address where it’s the only object that can respond on a read request and use grp.readvalue('1/1/1'), when you get a response you know the device is online.
A 3th option is to let each device send to a grp address cyclically and monitor the timestamp of that object. When the timestamp updates are stopping your devices is offline. This is the least prevered method as it increases the traffic a bit.
What do you think about this script?
The interval time can be longer, yes. But other than that?
Code:
local deviceAddress = '4/0/13' -- Group address to monitor
local checkInterval = 60 -- Time in seconds between each check
local readTimeout = 5 -- Timeout for read request in seconds
-- Function to check the device
local function checkDevice(address, timeout)
local response = grp.readvalue(address, timeout)
if response then
log('OK - Response received from ' .. address)
else
log('ERROR - No response from ' .. address)
end
end
-- Main loop
while true do
checkDevice(deviceAddress, readTimeout)
os.sleep(checkInterval)
end