This can be created with SVG and JavaScript, but it's not quite easy to do right now. Wait for next FW with custom JavaScript support, it will be much easier then.
(15.01.2016, 14:41)admin Wrote: This can be created with SVG and JavaScript, but it's not quite easy to do right now. Wait for next FW with custom JavaScript support, it will be much easier then.
Thak you for the answer Do you know when the new FW will be released?
And I have w different new questions: how can I do an autoopening site for example when somebody's calling by the intercom? And is there any solution for taking a screenshot from camera which is connected to LM via LAN and it is visible in "Camera" object?
--***********************************************************----** Email image attachment created by Erwin van der Zwart **----***********************************************************----******************* Start of parameters *******************----***********************************************************----Gmail (smtp) username !IMPORTANT!user = 'YOUR.ADDRESS@GMAIL.COM'--Gmail (smtp) password !IMPORTANT!password = 'YOUR GMAIL PASSWORD'--Sender for e-mailfrom = '<your.address@gmail.com>'alias_from = 'YOUR FULL NAME'--Recipient for e-mailto = '<recipient@domain.com>'alias_to = 'recipient full name'--Subject for e-mailsubject = 'Snapshot from camera automaticly send by homeLYnk'--Attachment and filetype (set filetype as 'gif', 'png', 'bmp', 'jpg' or 'jpeg' according image source)image_type = 'jpeg'image_name_attachment = 'snapshot'source_image_url = 'http://your.camara.ip/snapshot.jpeg'image_description = 'Snapshot from IP Camera'--Message on bottom of email (will only be showed when client don't understand attachment)epilogue = 'End of message'--***********************************************************----******************** End of parameters ********************----***********************************************************----********** DON'T CHANGE ANYTHING UNDER THIS LINE **********----***********************************************************----Get remote (from HTTP) image and put image file to HL (will be deleted when end of script)os.execute('wget -O /www/scada/vis/' .. image_name_attachment .. '.' .. image_type .. ' ' .. source_image_url .. '')
--Create filename and locationlocalfileName = '/www/scada/vis/' .. image_name_attachment .. '.' .. image_type--Create table to include mail settingslocalsettings = {
from = from,
rcpt = to,
user = user,
password = password,
server = 'smtp.gmail.com',
port = 465,
secure = 'sslv23',
}
--Load required modules to send email with attachmentlocalsmtp = require("socket.smtp")
localmime = require("mime")
localltn12 = require("ltn12")
--Create e-mail headersettings.source = smtp.message{
headers = {
from = '' .. alias_from .. ' ' .. from .. '',
to = '' .. alias_to .. ' ' .. to .. '',
subject = subject
},
--Load attachment inside body body = {
preamble = "",
[1] = {
headers = {
["content-type"] = 'image/' .. image_type .. '; name="' .. image_name_attachment .. '.' .. image_type .. '"',
["content-disposition"] = 'attachment; filename="' .. image_name_attachment .. '.' .. image_type .. '"',
["content-description"] = '' .. image_description .. '',
["content-transfer-encoding"] = "BASE64"
},
body = ltn12.source.chain(
ltn12.source.file(io.open(fileName, "rb")),
ltn12.filter.chain(
mime.encode("base64"),
mime.wrap()
)
)
},
epilogue = epilogue
}
}
--Send the emailr, e = smtp.send(settings)
--Create alert when sending gives an error with error messageif (e) thenalert("Could not send email: ", e, "\n")
end--Delete downloaded image file from HLos.remove(fileName)
2. Another script allows to perform a jump to a specific visualization page when call from intercom is received. You need to write page number to the object and visualization will jump to it automatically.
-- * Jump to Page Module Version 1.2 Created by Erwin van der Zwart * ---- * This script perform automaticly all needed actions to support jump to page * ---- After running script once refresh browser and write value to object for result ---- ******************************** SET PARAMETERS ****************************** ---- Group address to trigger the page jump(s)Trigger_Group_Address = '0/0/33'-- !! MUST BE A 2 BYTE UNSIGNED INTEGER OBJECT !!-- Create automaticly iframe with jumps.html on startpageCreate_Automatic = true-- Set to false to disable auto create and run script once-- Delete HTML jump function from controllerDelete_HTML = false-- Set to true to delete this function and run script once-- ******************************** END PARAMETERS ****************************** ---- ********************* DON'T CHANGE ANYTHING UNDER THIS LINE ****************** ---- Create HTML contentpage = [[<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>homeLYnk Page Jumps</title><style type="text/css">body {background-color: transparent;}</style></head><body><script type="text/javascript">// ***** Make link to parent from iframe *****var p = window.parent, root, addr;var ip = location.host;var URL = "http://" + ip + "/scada/resources/img/";if (p && p.objectStore) {addr = p.Scada.encodeGroupAddress(']] .. Trigger_Group_Address .. [['); p.objectStore.addListener(addr, function(obj, type) {/* to avoid jump on opening page */if (type == 'init') {return;}if (obj.value == 0) {return;}if ( p.currentPlanId != obj.value ){p.showPlan(obj.value);}if ( obj.value != 0 ){p.setObjectValue({ address: ']] .. Trigger_Group_Address .. [[', rawdatatype: 7 }, 0, 'text');}});}</script></div></body></html>]]-- Create HTML file to write to controllerio.writefile("/www/scada/resources/img/jumps.html", page)
-- use this as frame URL -> /scada/resources/img/jumps.html-- Check if html must be automaticly created inside iframe with jumps.html on startpageifCreate_Automatic == truethen-- Get default startpagequery = 'SELECT id, usermode_param FROM visfloors'for_, floorinipairs(db:getall(query)) doiffloor.usermode_param == "D"thendefault_startpage = floor.idendend-- Check if default page excists else exit scriptifdefault_startpage == nilthenalert("Default page does not excists, exit HTML creation")
--Exit scriptreturnend-- Check if object already existobject_exists = falsequery = 'SELECT floor, type, name, params FROM visobjects'for_, visobjectinipairs(db:getall(query)) doifvisobject.floor == default_startpageand (visobject.type == 9orvisobject.type == "9") andvisobject.name == "jumps"thenobject_exists = trueendend-- Create if object doesn't existifobject_exists == falsethendb:insert('visobjects', {floor = default_startpage, type = 9, params = '{"source":"url","url":"/scada/resources/img/jumps.html","width":50,"height":50}', locx = 0 , locy = 0, name = "jumps", notouch = 1, nobg = 1,})
endend-- Check if HTML logout function must be deleted from the controllerifDelete_HTML == truethen-- Get default startpagequery = 'SELECT id, usermode_param FROM visfloors'for_, floorinipairs(db:getall(query)) doiffloor.usermode_param == "D"thendefault_startpage = floor.idendend-- Check if default page excists else exit scriptifdefault_startpage == nilthenalert("Default page does not excists, exit HTML deletion")
--Exit scriptreturnend-- Select all entrys from DB inside table 'visobjects'query = 'SELECT id, floor, type, name, params FROM visobjects'for_, visobjectinipairs(db:getall(query)) doifvisobject.floor == default_startpageand (visobject.type == 9orvisobject.type == "9") andvisobject.name == "jumps"thencurrent = visobject.iddb:delete('visobjects', { id = current })
endend--Delete HTML file from HL diros.remove("/www/scada/resources/img/jumps.html")
end-- Disable script when done automaticlyscript.disable(_SCRIPTNAME)
Thanks for the examples. I'm trying to run the first script, the one that sends an email. However I get the following error while trying to execute the script: "Lua syntax error at line 47: '}' expected (to close '{' at line 46) near ' from'" I am quite new to Lua, could you help me out figuring what the error is?
I believe the comma at the end of line 53 should be removed? However it does not change anything with regards to the error message.
(01.02.2016, 13:44)admin Wrote: Looks like another case of copy-paste issue of Google Chrome. Copy the source code to notepad, then copy it from there and paste to LM code editor.
You were right, however copy pasting it into a text editor did not solve the problem. I still had to manually remove blank spaces. I'm now facing a new problem, instead of showing an actual image the sent mail just displays a lot of text. I have tried with both .png, .jpg and .jpeg and still get the same result. Any tips?
I guess this doesn't really matter, but I don't have an actual camera connected to my home network. So I just using some random image urls from the web.
* the image doesn't save in LM - I don't delete it for trying it.
* the email doesn't send itself - I think that it's for the first one. There is no file then error.
My version is 17/9/2015.
I put the os.execute in log - result : * number 0
I've tried but unfortunately widget opens with other dimensions and open not only on page 174 where it is placed but also on homepage where there isn't. I've tried to change a little this script to use only this function which is for opening widget only on load page.
This are widget parameters:
widget ID: "widget-177"
top: 130px
left: 0px
width: 720px
height: 1024px
plan ID: 174
12.09.2016, 12:56 (This post was last modified: 12.09.2016, 13:07 by Erwin van der Zwart.)
Hi Buuuudzik,
Thats correct, in your request you ask to open widget on opening site, that's what happens now (;
If you want to open widget on a specific page we need to add a extra condition.
To avoid miscomunication again, can you discribe exactly what you want to achieve?
PS: All pages are loaded at once, so you need to use a condition to determine current page, the height and width commands you added are correct so should work ..
What kind of notifications do you want to display, do you want them to be visible on every page? It might be easier just to create a div element and show notifications there than to use a widget.
(27.10.2016, 13:24)admin Wrote: What kind of notifications do you want to display, do you want them to be visible on every page? It might be easier just to create a div element and show notifications there than to use a widget.
Hi,
i would like to display a alarm notification independently of the current page. I would like to use in the notification window (widget) controls and also trends.