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.

Device monitoring and reporting
#11
(20.11.2023, 11:52)baggins Wrote: I use an MDT STC power supply with diagnostic function that can detect failed devices.
It also measures bus traffic.

Veri nice suggestion as well! I have exactly this product in another installation. Smile

Code:
-- List of group addresses to monitor
local addresses = {'4/5/2', '2/0/8', '2/0/24', '2/0/22', '1/0/24'}

-- Time in seconds between each full round of checks
local checkInterval = 60

-- Timeout in seconds for each read request to a device
local readTimeout = 5

-- Delay in seconds between consecutive read requests within a round
local delayBetweenReads = 2

-- Function to check a single device
local function checkDevice(address, timeout)
    -- Safely attempt to read from the device at 'address' with 'timeout'
    -- 'pcall' is used for safe function call, it returns status and response
    local status, response = pcall(grp.readvalue, address, timeout)

    -- Check if the read attempt was successful (status is true)
    if status then
        -- Log a message indicating a successful read
        log('OK - Response received from ' .. address)
    else
        -- Log a message indicating a failed read
        log('ERROR - No response from ' .. address)
    end
end

-- Main loop of the script
while true do
    -- Iterate over each address in the 'addresses' list
    for _, address in ipairs(addresses) do
        -- Check each device using the checkDevice function
        checkDevice(address, readTimeout)

        -- Pause for 'delayBetweenReads' seconds before checking the next device
        os.sleep(delayBetweenReads)
    end

    -- Once all devices are checked, pause for 'checkInterval' seconds
    os.sleep(checkInterval)
end

This is my latest code for this solution. entering the group addresses to scan for is the "big" job now. Is it possible to upload a css file with all addresses to check and refer to the csv ?

I also added that the error message should not appear if any other response than true is responding from the bus.
Reply


Messages In This Thread
Device monitoring and reporting - by anve - 18.11.2023, 08:23
RE: Device monitoring and reporting - by anve - 19.11.2023, 20:40
Device monitoring and reporting - by anve - 18.11.2023, 14:28
Device monitoring and reporting - by anve - 18.11.2023, 15:02
RE: Device monitoring and reporting - by anve - 21.11.2023, 21:13

Forum Jump: