I like to use this function in more scripts.
Is there a way to make this function 'global' so that i can use this function more times without cut and paste the function in every script?
Like putting this function in a special named dzvents script that functions as a library?
Code: Select all
return {
on = {devices = {'Neemfoto'}},
logging = { level = domoticz.LOG_DEBUG , -- Uncomment to override the dzVents global logging setting
marker = "Security"},
execute = function(dz, device, info)
local function snapshot(idx,subject,delay)
if not dz then dz = domoticz end
if not idx then idx = 1 end
if not subject then
subject = "snapshot_" .. dz.time.rawDate .. "_" .. dz.time.rawTime
else
subject = subject .. "_" .. dz.time.rawDate .. "_" .. dz.time.rawTime
end
if delay and delay > 0 then
local url = dz.settings['Domoticz url'] .. "/json.htm?type=command¶m=emailcamerasnapshot&camidx=".. idx .. "&subject=" .. dz.utils.urlEncode(subject)
dz.openURL(url).afterSec(delay)
else
dz.sendCommand("SendCamera:" .. idx, subject)
end
end
local cameraID = 1
local cameraNAME = 'pvkcam'
local repeats = 1 --- number of repeats
local interval = 1 -- seconds between repeats
for i = 0,(repeats - 1) do
snapshot(cameraID,"Foto (" .. i+1 .."/" .. repeats .. ") van camera (" .. cameraNAME ..
"). Foto is gemaakt ".. (i * interval) .. " seconden na eerste foto ", ( i * interval ))
end
end
}