![]() |
|
KNX connection statuss and device check - Printable Version +- LogicMachine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8) +--- Thread: KNX connection statuss and device check (/showthread.php?tid=1959) |
KNX connection statuss and device check - AlexLV - 11.03.2019 Hi, at Russian FB page found some interesting scripts, I think can be useful, not seen here.. 1. KNX connection status: Code: if not client then
require('genohm-scada.eibdgm')
function statushandler(status)
if status == 0x00 then
grp.write('32/2/1', true)
elseif status == 0xFF then
grp.write('32/2/1', false)
end
end
client = eibdgm:new()
client:sethandler('status', statushandler)
end
client:step()2. KNX device check, if any lost, automatically message can be sent (with russian comments, I added english translation): Code: -- Таблица адресов, которые нужно проверять на доступность на шине
-- Table of addresses which should be checked at KNX line
knx_addrs = {'1.1.2','1.1.4','1.1.5','1.1.6','1.1.7','1.1.8','1.1.9','1.1.10','1.1.11','1.1.12','1.1.13','1.1.14','1.1.15'}
-- Таблица подключенных устройств
-- Table of connected devices
knx_conn = {}
-- Таблица отключенных устройств
-- Table of disconnected devices
knx_disc = {}
-- Проверка доступности устройств на шине KNX
-- Checking devices are alive
for index, value in ipairs(knx_addrs) do
if knxlib.ping(value) then
table.insert(knx_conn, value)
else
table.insert(knx_disc, value)
end
end
-- Перевод таблицы в строку
-- Table translation to string
conn_str = table.concat(knx_conn, ', ')
disc_str = table.concat(knx_disc, ', ')
-- Вывод таблиц и строк в лог для просмотра при отладке.
-- Logging of tables and strings for debugging
--log(#knx_conn, #knx_disc)
--log(conn_str, disc_str)
-- отправляем письмо со списком недоступных устройств, если такие найдены
-- sending message with disconnected devices if any
if (#knx_disc > 0) then
log(disc_str)
--mail('example@email.com', 'Проверка устройств KNX', 'Отключены следующие устройства: ' .. disc_str)
-- translation of russian text above string: "KNX device checking" "These devices are disconnected:"
endBut please check second script, approx. every day I see in my log that some devices are offline, but they are different.. Looks a little strange for me.. But all works. May be something should be improved in script. Alex RE: KNX connection statuss and device check - Daniel - 12.03.2019 Hi I would add some delay in the second script in for loop. During ping quite a lot of telegrams is sent so it is better to do it one by one slowly. Thanks for sharing. BR |