Logic Machine Forum
Device monitoring and reporting - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: General (https://forum.logicmachine.net/forumdisplay.php?fid=2)
+--- Thread: Device monitoring and reporting (/showthread.php?tid=5099)



Device monitoring and reporting - anve - 18.11.2023

I want to make these functions:

Alarm Functionality: Develop a mechanism to alert when a device is offline or missing.
Email Alert System: Configure an email notification system for device status changes or alarms.

Is there a native functionality in LM5 Lite to support such detailed device monitoring and alerting?

If there is no native support. How do I make this function?


RE: Device monitoring and reporting - Erwin van der Zwart - 18.11.2023

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.


Device monitoring and reporting - anve - 18.11.2023

(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.


Thank you so much for this info.

I am very new to scripting in LM.
Is there any chance you can make a example script for me that i can use as a template, option 1, TP knxlib.ping?


Skickat från min iPhone med Tapatalk


RE: Device monitoring and reporting - Erwin van der Zwart - 18.11.2023

If you search the forum for knxlib.ping you will find enough samples..


Device monitoring and reporting - anve - 18.11.2023

(18.11.2023, 14:58)Erwin van der Zwart Wrote: If you search the forum for knxlib.ping you will find enough samples..


Thanks, I will do that Smile


Skickat från min iPhone med Tapatalk


RE: Device monitoring and reporting - anve - 19.11.2023

(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



RE: Device monitoring and reporting - admin - 20.11.2023

It won't work. grp.getvalue returns the value that is stored in the database, it does not send a read request.

See this thread for a solution with knxlib.ping: https://forum.logicmachine.net/showthread.php?tid=3510


RE: Device monitoring and reporting - Erwin van der Zwart - 20.11.2023

He uses grp.readvalue and in my experience that returns the value of the read action, or am i wrong?


RE: Device monitoring and reporting - admin - 20.11.2023

You are right, I've misread the function name. grp.readvalue can be used for monitoring. Alternatively poll interval can be set for certain objects then updatetime property can be checked using a scheduled script.


RE: Device monitoring and reporting - baggins - 20.11.2023

I use an MDT STC power supply with diagnostic function that can detect failed devices.
It also measures bus traffic.


RE: Device monitoring and reporting - anve - 21.11.2023

(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.


RE: Device monitoring and reporting - Erwin van der Zwart - 21.11.2023

Just TAG your objects and fetch them by the TAG and iterate the table…