Perhaps you can help me with a task that I have to accomplish. I'm working with the latest version of HL (2.0.0).
I have to perform an alarm control, and create a log with the last 30 or 40 alarms generated by the system; This system is a solar inverter that communicates via modbus with the HL. This communication is correct.
I attach an image of the book of modbus variables of the manufacturer, where you can observe the operation, as well as the variables already visible in HL.
I have configured the HL so that I ask the modbus interface every 60 seconds, so every 60 seconds I get new information in a loop, the object 1/1/7 is the index -> modbus adress 3001. Every time I ask A modbus read, the rest of variables change to their corresponding register.
The date of the alarm gives me in seconds since 1970 ... I'm not very clear how to do this, when I want to initialize a variable of time in 1970, the system changes it to 2070 ... I'm a little lost.
The ideal would be to visualize by alarms rows, and that these could be on written ones ...
And if I could already send the whole log by email once a week, for example, it would be extraordinary.
I hope someone can advise me a little, you would be grateful.
20.06.2017, 20:11 (This post was last modified: 20.06.2017, 20:25 by Erwin van der Zwart.)
Hi,
Use this as event based script attached to object 1/1/8:
Code:
if event.getvalue() == 1 then -- active
alert('There is a alarm with code ' .. grp.getvalue('1/1/9') .. ' at ' .. os.date("%c", grp.getvalue('1/1/6'))
end
It will generate a alert inside the alert tab, and that will be used in the alert app, can be downloaded from the appstore in FW 2.0.0.
There you will get a audio alert and a list with all available alerts.
To mail the alerts use this script as scheduled once a week: (make sure to enable 'less secure apps' in your gmail account to be able to mail and set DNS and default gateway on NIC)
Code:
--Gmail (smtp) username !IMPORTANT!
user = 'YOUR EMAIL ADRESS'
--Sender for e-mail
from = '<' .. user .. '>'
alias_from = 'YOUR ALIAS'
--Recipient for e-mail
to = '<receiver@domain.com>'
alias_to = 'receiver'
--Subject for e-mail
subjectpart1 = 'Alerts'
subjectpart2 = 'automaticly send by homeLYnk'
--Message on bottom of email (will only be showed when client don't understand attachment)
epilogue = 'End of message'
-- Get all alerts from DB
alerts_table = db:getall('SELECT * FROM alerts')
-- csv buffer
buffer = {}
-- format csv row
csv = string.format('%q,%q,%q', "ID", "ALERT", "ADDED TO LIST")
-- add to buffer
table.insert(buffer, csv)
-- add empty line to buffer
table.insert(buffer, "")
-- Loop through alerts_table
for _, alerts in ipairs(alerts_table) do
-- format csv row
csv = string.format('%q,%q,%q', alerts.id, alerts.alert, os.date("%x %X", alerts.alerttime))
-- add to buffer
table.insert(buffer, csv)
end
--Create table to include mail settings
local settings = {
from = from,
rcpt = to,
user = user,
password = password,
server = 'smtp.gmail.com',
port = 465,
secure = 'sslv23',
}
Use this as event based script attached to object 1/1/8:
Code:
if event.getvalue() == 1 then -- active
alert('There is a alarm with code ' .. grp.getvalue('1/1/9') .. ' at ' .. os.date("%c", grp.getvalue('1/1/6'))
end
It will generate a alert inside the alert tab, and that will be used in the alert app, can be downloaded from the appstore in FW 2.0.0.
There you will get a audio alert and a list with all available alerts.
To mail the alerts use this script as scheduled once a week: (make sure to enable 'less secure apps' in your gmail account to be able to mail and set DNS and default gateway on NIC)
Code:
--Gmail (smtp) username !IMPORTANT!
user = 'YOUR EMAIL ADRESS'
--Sender for e-mail
from = '<' .. user .. '>'
alias_from = 'YOUR ALIAS'
--Recipient for e-mail
to = '<receiver@domain.com>'
alias_to = 'receiver'
--Subject for e-mail
subjectpart1 = 'Alerts'
subjectpart2 = 'automaticly send by homeLYnk'
--Message on bottom of email (will only be showed when client don't understand attachment)
epilogue = 'End of message'
-- Get all alerts from DB
alerts_table = db:getall('SELECT * FROM alerts')
-- csv buffer
buffer = {}
-- format csv row
csv = string.format('%q,%q,%q', "ID", "ALERT", "ADDED TO LIST")
-- add to buffer
table.insert(buffer, csv)
-- add empty line to buffer
table.insert(buffer, "")
-- Loop through alerts_table
for _, alerts in ipairs(alerts_table) do
-- format csv row
csv = string.format('%q,%q,%q', alerts.id, alerts.alert, os.date("%x %X", alerts.alerttime))
-- add to buffer
table.insert(buffer, csv)
end
--Create table to include mail settings
local settings = {
from = from,
rcpt = to,
user = user,
password = password,
server = 'smtp.gmail.com',
port = 465,
secure = 'sslv23',
}