Just sharing code: on alarm trigger upload image every 5 seconds for 50 seconds

Just sharing this code I wrote, when motion armed is tripped, I wanted my cameras to upload image to dropbox (using the awesome app) but not just 1 photo, I wanted to upload a photo every 5 seconds, for up to 50 seconds.

Here is my code that I added to my scene, mind you this is my first code so any comments will be welcomed!

UploadPhoto(“10”)

function UploadPhoto(timesToCall)
luup.call_action(“urn:milliesoft-com:serviceId:WebcamDropboxUploader1”,“SendAllSnapshots”, “”,115)

local ttcNum = tonumber(timesToCall)
if ttcNum > 0 then
local nextTimesToCall = tostring(ttcNum - 1)
luup.call_delay(“UploadPhoto”, 5, nextTimesToCall)
end
end

yeah, ok… it doesn’t work :slight_smile:

if I call luup.call_action(“urn:milliesoft-com:serviceId:WebcamDropboxUploader1”,“SendAllSnapshots”, “”,115) it works, but when it is called from inside the function it doesn’t work…

any ideas? I will post if and when I can fix it

working:

function UploadPhoto(timesToCall)

luup.call_action(“urn:milliesoft-com:serviceId:WebcamDropboxUploader1”,“SendAllSnapshots”, “”,115)

local ttcNum = tonumber(timesToCall)
if ttcNum > 0 then
local nextTimesToCall = tostring(ttcNum - 1)
luup.call_delay(“UploadPhoto”, 5, nextTimesToCall)
end

end

UploadPhoto(“10”)

(I guess you have to call the function after you define it?)